[PATCH RFC 15/26] functionfs: convert to use the SGT mapping type

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

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/usb/gadget/function/f_fs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 05c6750702b609..5c81ea9afa1249 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -16,6 +16,7 @@

#include <linux/blkdev.h>
#include <linux/dma-buf.h>
+#include <linux/dma-buf-mapping.h>
#include <linux/dma-fence.h>
#include <linux/dma-resv.h>
#include <linux/pagemap.h>
@@ -1467,7 +1468,7 @@ ffs_dmabuf_find_attachment(struct ffs_epfile *epfile, struct dma_buf *dmabuf)
mutex_lock(&epfile->dmabufs_mutex);

list_for_each_entry(priv, &epfile->dmabufs, entry) {
- if (priv->attach->dev == dev
+ if (dma_buf_sgt_dma_device(priv->attach) == dev
&& priv->attach->dmabuf == dmabuf) {
attach = priv->attach;
break;
@@ -1569,7 +1570,7 @@ static int ffs_dmabuf_detach(struct file *file, int fd)
mutex_lock(&epfile->dmabufs_mutex);

list_for_each_entry_safe(priv, tmp, &epfile->dmabufs, entry) {
- if (priv->attach->dev == dev
+ if (dma_buf_sgt_dma_device(priv->attach) == dev
&& priv->attach->dmabuf == dmabuf) {
/* Cancel any pending transfer */
spin_lock_irq(&ffs->eps_lock);
--
2.43.0