[media] media/videobuf2-dma-contig: Save output from dma_map_sg
authorRicardo Ribalda <ricardo.ribalda@gmail.com>
Wed, 29 Apr 2015 12:00:46 +0000 (09:00 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 30 May 2015 14:29:06 +0000 (11:29 -0300)
dma_map_sg returns the number of areas mapped by the hardware,
which could be different than the areas given as an input.
The output must be saved to nent.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/v4l2-core/videobuf2-dma-contig.c

index 620c4aa78881844b16484c6cb157944e5c1d077d..369df95af5c74fa4c5b1869763063935914c5f41 100644 (file)
@@ -299,7 +299,6 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
        /* stealing dmabuf mutex to serialize map/unmap operations */
        struct mutex *lock = &db_attach->dmabuf->lock;
        struct sg_table *sgt;
-       int ret;
 
        mutex_lock(lock);
 
@@ -318,8 +317,9 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
        }
 
        /* mapping to the client with new direction */
-       ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dma_dir);
-       if (ret <= 0) {
+       sgt->nents = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
+                               dma_dir);
+       if (!sgt->nents) {
                pr_err("failed to map scatterlist\n");
                mutex_unlock(lock);
                return ERR_PTR(-EIO);