aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-08-24 20:59:36 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-09-21 15:42:31 -0400
commit6b831d78477c9bbfbcb4cb60af13e13bd2c7467e (patch)
tree2549759d70611afb0608ec30f57a0f2590b174a5
parent3cf0c6bd68915aee3b5827b960e485de201e42c1 (diff)
[media] airspy: fix error handling on start streaming
Free all reserved USB buffers and URBs on failure. Return all queued buffers to vb2 with state queued on error case. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/usb/airspy/airspy.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index cb0e515d80ae..56a1ae05ea7b 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -540,27 +540,49 @@ static int airspy_start_streaming(struct vb2_queue *vq, unsigned int count)
540 540
541 mutex_lock(&s->v4l2_lock); 541 mutex_lock(&s->v4l2_lock);
542 542
543 set_bit(POWER_ON, &s->flags);
544
545 s->sequence = 0; 543 s->sequence = 0;
546 544
545 set_bit(POWER_ON, &s->flags);
546
547 ret = airspy_alloc_stream_bufs(s); 547 ret = airspy_alloc_stream_bufs(s);
548 if (ret) 548 if (ret)
549 goto err; 549 goto err_clear_bit;
550 550
551 ret = airspy_alloc_urbs(s); 551 ret = airspy_alloc_urbs(s);
552 if (ret) 552 if (ret)
553 goto err; 553 goto err_free_stream_bufs;
554 554
555 ret = airspy_submit_urbs(s); 555 ret = airspy_submit_urbs(s);
556 if (ret) 556 if (ret)
557 goto err; 557 goto err_free_urbs;
558 558
559 /* start hardware streaming */ 559 /* start hardware streaming */
560 ret = airspy_ctrl_msg(s, CMD_RECEIVER_MODE, 1, 0, NULL, 0); 560 ret = airspy_ctrl_msg(s, CMD_RECEIVER_MODE, 1, 0, NULL, 0);
561 if (ret) 561 if (ret)
562 goto err; 562 goto err_kill_urbs;
563err: 563
564 goto exit_mutex_unlock;
565
566err_kill_urbs:
567 airspy_kill_urbs(s);
568err_free_urbs:
569 airspy_free_urbs(s);
570err_free_stream_bufs:
571 airspy_free_stream_bufs(s);
572err_clear_bit:
573 clear_bit(POWER_ON, &s->flags);
574
575 /* return all queued buffers to vb2 */
576 {
577 struct airspy_frame_buf *buf, *tmp;
578
579 list_for_each_entry_safe(buf, tmp, &s->queued_bufs, list) {
580 list_del(&buf->list);
581 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED);
582 }
583 }
584
585exit_mutex_unlock:
564 mutex_unlock(&s->v4l2_lock); 586 mutex_unlock(&s->v4l2_lock);
565 587
566 return ret; 588 return ret;