[PATCH v3 18/24] iio: buffer: convert to use the SGT mapping type

From: Alistair Popple

Date: Fri Nov 20 2026 - 01:00:50 EST


From: Jason Gunthorpe <jgg@xxxxxxxxxx>

These importer helper functions should call dma_buf_sgt_dma_device() as
they are always working with SGTs.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Signed-off-by: Alistair Popple <apopple@xxxxxxxxxx>
---
drivers/iio/industrialio-buffer.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4a1063e4891f..f907fb6ca936 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -16,6 +16,7 @@
#include <linux/export.h>
#include <linux/device.h>
#include <linux/dma-buf.h>
+#include <linux/dma-buf-mapping.h>
#include <linux/dma-fence.h>
#include <linux/dma-resv.h>
#include <linux/file.h>
@@ -1676,7 +1677,7 @@ iio_buffer_find_attachment(struct iio_dev_buffer_pair *ib,
guard(mutex)(&buffer->dmabufs_mutex);

list_for_each_entry(priv, &buffer->dmabufs, entry) {
- if (priv->attach->dev == dma_dev
+ if (dma_buf_sgt_dma_device(priv->attach) == dma_dev
&& priv->attach->dmabuf == dmabuf) {
attach = priv->attach;
break;
@@ -1760,7 +1761,7 @@ static int iio_buffer_attach_dmabuf(struct iio_dev_buffer_pair *ib,
* combo. If we do, refuse to attach.
*/
list_for_each_entry(each, &buffer->dmabufs, entry) {
- if (each->attach->dev == dma_dev
+ if (dma_buf_sgt_dma_device(each->attach) == dma_dev
&& each->attach->dmabuf == dmabuf) {
/*
* We unlocked the reservation object, so going through
@@ -1814,7 +1815,7 @@ static int iio_buffer_detach_dmabuf(struct iio_dev_buffer_pair *ib,
guard(mutex)(&buffer->dmabufs_mutex);

list_for_each_entry(priv, &buffer->dmabufs, entry) {
- if (priv->attach->dev == dma_dev
+ if (dma_buf_sgt_dma_device(priv->attach) == dma_dev
&& priv->attach->dmabuf == dmabuf) {
list_del(&priv->entry);


--
2.54.0