aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2014-08-04 06:29:59 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-01-29 15:27:03 -0500
commit80b0963e1698e10a58451f0508058fc20e48334a (patch)
treeb925dc546153cbdf086b6c67b467591770fa01d8
parenta4bca4c7ad36a4cdafc87d1dce3758cdccef1ca7 (diff)
[media] pwc: fix WARN_ON
If start_streaming fails, then the buffers must be given back to vb2 with state QUEUED, not ERROR. Otherwise a WARN_ON will be generated. In the disconnect it is pointless to call pwc_cleanup_queued_bufs() as stop_streaming() will be called anyway. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/usb/pwc/pwc-if.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 15b754da4a2c..702267e208ba 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -508,7 +508,8 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev)
508} 508}
509 509
510/* Must be called with vb_queue_lock hold */ 510/* Must be called with vb_queue_lock hold */
511static void pwc_cleanup_queued_bufs(struct pwc_device *pdev) 511static void pwc_cleanup_queued_bufs(struct pwc_device *pdev,
512 enum vb2_buffer_state state)
512{ 513{
513 unsigned long flags = 0; 514 unsigned long flags = 0;
514 515
@@ -519,7 +520,7 @@ static void pwc_cleanup_queued_bufs(struct pwc_device *pdev)
519 buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf, 520 buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf,
520 list); 521 list);
521 list_del(&buf->list); 522 list_del(&buf->list);
522 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); 523 vb2_buffer_done(&buf->vb, state);
523 } 524 }
524 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags); 525 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
525} 526}
@@ -674,7 +675,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
674 pwc_set_leds(pdev, 0, 0); 675 pwc_set_leds(pdev, 0, 0);
675 pwc_camera_power(pdev, 0); 676 pwc_camera_power(pdev, 0);
676 /* And cleanup any queued bufs!! */ 677 /* And cleanup any queued bufs!! */
677 pwc_cleanup_queued_bufs(pdev); 678 pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_QUEUED);
678 } 679 }
679 mutex_unlock(&pdev->v4l2_lock); 680 mutex_unlock(&pdev->v4l2_lock);
680 681
@@ -692,7 +693,9 @@ static void stop_streaming(struct vb2_queue *vq)
692 pwc_isoc_cleanup(pdev); 693 pwc_isoc_cleanup(pdev);
693 } 694 }
694 695
695 pwc_cleanup_queued_bufs(pdev); 696 pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_ERROR);
697 if (pdev->fill_buf)
698 vb2_buffer_done(&pdev->fill_buf->vb, VB2_BUF_STATE_ERROR);
696 mutex_unlock(&pdev->v4l2_lock); 699 mutex_unlock(&pdev->v4l2_lock);
697} 700}
698 701
@@ -1125,7 +1128,6 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
1125 if (pdev->vb_queue.streaming) 1128 if (pdev->vb_queue.streaming)
1126 pwc_isoc_cleanup(pdev); 1129 pwc_isoc_cleanup(pdev);
1127 pdev->udev = NULL; 1130 pdev->udev = NULL;
1128 pwc_cleanup_queued_bufs(pdev);
1129 1131
1130 v4l2_device_disconnect(&pdev->v4l2_dev); 1132 v4l2_device_disconnect(&pdev->v4l2_dev);
1131 video_unregister_device(&pdev->vdev); 1133 video_unregister_device(&pdev->vdev);