]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[media] media: blackfin: bfin_capture: release buffers in case start_streaming()...
authorLad, Prabhakar <prabhakar.csengg@gmail.com>
Sun, 8 Mar 2015 14:40:38 +0000 (11:40 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 2 Apr 2015 21:11:09 +0000 (18:11 -0300)
this patch adds support to release the buffer by calling
vb2_buffer_done(), with state marked as VB2_BUF_STATE_QUEUED
if start_streaming() call back fails.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/blackfin/bfin_capture.c

index c6d8b95b91fffc74dbda520d5d3cb028143db133..2c720bc4cb8fd8ee68e777d9bfc134f5fc673177 100644 (file)
@@ -345,6 +345,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
        struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
        struct ppi_if *ppi = bcap_dev->ppi;
+       struct bcap_buffer *buf, *tmp;
        struct ppi_params params;
        int ret;
 
@@ -352,7 +353,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
        ret = v4l2_subdev_call(bcap_dev->sd, video, s_stream, 1);
        if (ret && (ret != -ENOIOCTLCMD)) {
                v4l2_err(&bcap_dev->v4l2_dev, "stream on failed in subdev\n");
-               return ret;
+               goto err;
        }
 
        /* set ppi params */
@@ -391,7 +392,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
        if (ret < 0) {
                v4l2_err(&bcap_dev->v4l2_dev,
                                "Error in setting ppi params\n");
-               return ret;
+               goto err;
        }
 
        /* attach ppi DMA irq handler */
@@ -399,12 +400,21 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
        if (ret < 0) {
                v4l2_err(&bcap_dev->v4l2_dev,
                                "Error in attaching interrupt handler\n");
-               return ret;
+               goto err;
        }
 
        reinit_completion(&bcap_dev->comp);
        bcap_dev->stop = false;
+
        return 0;
+
+err:
+       list_for_each_entry_safe(buf, tmp, &bcap_dev->dma_queue, list) {
+               list_del(&buf->list);
+               vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED);
+       }
+
+       return ret;
 }
 
 static void bcap_stop_streaming(struct vb2_queue *vq)