[PATCH RFC 14/26] iio: buffer: convert to use the SGT mapping type

Jason Gunthorpe
2026-02-18T00:12:14Z

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

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
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 c6259213e15035..7daac53c502e50 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>
@@ -1642,7 +1643,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;
@@ -1727,7 +1728,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
@@ -1781,7 +1782,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.43.0