V4L/DVB (11323): pxa-camera: simplify the .buf_queue path by merging two loops
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Tue, 31 Mar 2009 06:44:22 +0000 (03:44 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 7 Apr 2009 00:43:46 +0000 (21:43 -0300)
pxa_dma_update_sg_tail() is called only once, runs exactly the same loop as the
caller and has to recalculate the last element in an sg-list, that the caller
has already calculated. Eliminate redundancy by merging the two loops and
re-using the calculated pointer. This also saves a bit of performance which is
always good during video-capture.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/pxa_camera.c

index cfa113cedd3edd115d82b163095186dfa3f6ec29..c639845460fff8df6a327bf1f7e21ebbb954ac34 100644 (file)
@@ -566,15 +566,6 @@ static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev)
        }
 }
 
-static void pxa_dma_update_sg_tail(struct pxa_camera_dev *pcdev,
-                                  struct pxa_buffer *buf)
-{
-       int i;
-
-       for (i = 0; i < pcdev->channels; i++)
-               pcdev->sg_tail[i] = buf->dmas[i].sg_cpu + buf->dmas[i].sglen;
-}
-
 static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
                                 struct pxa_buffer *buf)
 {
@@ -585,12 +576,13 @@ static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
                buf_last_desc = buf->dmas[i].sg_cpu + buf->dmas[i].sglen;
                buf_last_desc->ddadr = DDADR_STOP;
 
-               if (!pcdev->sg_tail[i])
-                       continue;
-               pcdev->sg_tail[i]->ddadr = buf->dmas[i].sg_dma;
-       }
+               if (pcdev->sg_tail[i])
+                       /* Link the new buffer to the old tail */
+                       pcdev->sg_tail[i]->ddadr = buf->dmas[i].sg_dma;
 
-       pxa_dma_update_sg_tail(pcdev, buf);
+               /* Update the channel tail */
+               pcdev->sg_tail[i] = buf_last_desc;
+       }
 }
 
 /**