diff mbox series

[2/5] drm/i915/dmabuf: Use scatterlist for_each_sg API

Message ID 20200422212519.36276-3-michael.j.ruhl@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/5] drm/i915/dmabuf: dmabuf cleanup | expand

Commit Message

Michael J. Ruhl April 22, 2020, 9:25 p.m. UTC
Update open coded for loop to use the standard scatterlist
for_each_sg API.

Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 0d9124ad549a..7ea4abb6a896 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -7,6 +7,7 @@ 
 #include <linux/dma-buf.h>
 #include <linux/highmem.h>
 #include <linux/dma-resv.h>
+#include <linux/scatterlist.h>
 
 #include "i915_drv.h"
 #include "i915_gem_object.h"
@@ -40,12 +41,10 @@  static struct sg_table *i915_gem_map_dma_buf(struct dma_buf_attachment *attach,
 	if (ret)
 		goto err_free;
 
-	src = obj->mm.pages->sgl;
 	dst = sgt->sgl;
-	for (i = 0; i < obj->mm.pages->nents; i++) {
+	for_each_sg(obj->mm.pages->sgl, src, obj->mm.pages->nents, i) {
 		sg_set_page(dst, sg_page(src), src->length, 0);
 		dst = sg_next(dst);
-		src = sg_next(src);
 	}
 
 	if (!dma_map_sg_attrs(attach->dev,