Merge tag 'drm-misc-next-2020-10-27' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / drivers / media / common / videobuf2 / videobuf2-vmalloc.c
index 11ba0eb1315b391814f8001bece80809a2a251b0..83f95258ec8c68e4443d898a356786bd8a4f7e50 100644 (file)
@@ -229,7 +229,7 @@ static int vb2_vmalloc_dmabuf_ops_attach(struct dma_buf *dbuf,
                kfree(attach);
                return ret;
        }
-       for_each_sg(sgt->sgl, sg, sgt->nents, i) {
+       for_each_sgtable_sg(sgt, sg, i) {
                struct page *page = vmalloc_to_page(vaddr);
 
                if (!page) {
@@ -259,8 +259,7 @@ static void vb2_vmalloc_dmabuf_ops_detach(struct dma_buf *dbuf,
 
        /* release the scatterlist cache */
        if (attach->dma_dir != DMA_NONE)
-               dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
-                       attach->dma_dir);
+               dma_unmap_sgtable(db_attach->dev, sgt, attach->dma_dir, 0);
        sg_free_table(sgt);
        kfree(attach);
        db_attach->priv = NULL;
@@ -285,15 +284,12 @@ static struct sg_table *vb2_vmalloc_dmabuf_ops_map(
 
        /* release any previous cache */
        if (attach->dma_dir != DMA_NONE) {
-               dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
-                       attach->dma_dir);
+               dma_unmap_sgtable(db_attach->dev, sgt, attach->dma_dir, 0);
                attach->dma_dir = DMA_NONE;
        }
 
        /* mapping to the client with new direction */
-       sgt->nents = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
-                               dma_dir);
-       if (!sgt->nents) {
+       if (dma_map_sgtable(db_attach->dev, sgt, dma_dir, 0)) {
                pr_err("failed to map scatterlist\n");
                mutex_unlock(lock);
                return ERR_PTR(-EIO);