V4L/DVB: buf-dma-sg.c: don't assume nr_pages == sglen
authorArnout Vandecappelle <arnout@mind.be>
Wed, 17 Mar 2010 22:53:04 +0000 (19:53 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:58:40 +0000 (12:58 -0300)
videobuf_pages_to_sg() and videobuf_vmalloc_to_sg() happen to create
a scatterlist element for every page.  However, this is not true for
bus addresses, so other functions shouldn't rely on the length of the
scatter list being equal to nr_pages.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf-dma-sg.c

index b49f1e23298acb2d3a13d31994f3d59cd09dddae..8359e6badd36789b9380c6a83ccca153e0d2cb71 100644 (file)
@@ -286,7 +286,7 @@ int videobuf_dma_unmap(struct videobuf_queue *q, struct videobuf_dmabuf *dma)
        if (!dma->sglen)
                return 0;
 
-       dma_unmap_sg(q->dev, dma->sglist, dma->nr_pages, dma->direction);
+       dma_unmap_sg(q->dev, dma->sglist, dma->sglen, dma->direction);
 
        vfree(dma->sglist);
        dma->sglist = NULL;
@@ -537,7 +537,7 @@ static int __videobuf_sync(struct videobuf_queue *q,
        MAGIC_CHECK(mem->dma.magic, MAGIC_DMABUF);
 
        dma_sync_sg_for_cpu(q->dev, mem->dma.sglist,
-                           mem->dma.nr_pages, mem->dma.direction);
+                           mem->dma.sglen, mem->dma.direction);
 
        return 0;
 }