aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-06-22 04:44:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-06 16:29:14 -0400
commitf05393d2eb45b3cc9663223c3709134ccef51290 (patch)
treebb4f0fd983a8454a872dfa41df441ff9458991f9 /drivers
parent37d9ed94b97efdacf1cbff91216920d1a620b8cd (diff)
[media] vb2-core: add support for count == 0 in create_bufs
This also fixes incorrect error handling in create_bufs: the return code of __vb2_queue_alloc is the number of allocated buffers, and not a traditional error code. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/videobuf2-core.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index 60e7bc78d190..ed38eb748357 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -669,9 +669,9 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
669 /* Finally, allocate buffers and video memory */ 669 /* Finally, allocate buffers and video memory */
670 ret = __vb2_queue_alloc(q, create->memory, num_buffers, 670 ret = __vb2_queue_alloc(q, create->memory, num_buffers,
671 num_planes); 671 num_planes);
672 if (ret < 0) { 672 if (ret == 0) {
673 dprintk(1, "Memory allocation failed with error: %d\n", ret); 673 dprintk(1, "Memory allocation failed\n");
674 return ret; 674 return -ENOMEM;
675 } 675 }
676 676
677 allocated_buffers = ret; 677 allocated_buffers = ret;
@@ -702,7 +702,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
702 702
703 if (ret < 0) { 703 if (ret < 0) {
704 __vb2_queue_free(q, allocated_buffers); 704 __vb2_queue_free(q, allocated_buffers);
705 return ret; 705 return -ENOMEM;
706 } 706 }
707 707
708 /* 708 /*
@@ -726,6 +726,8 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
726 int ret = __verify_memory_type(q, create->memory, create->format.type); 726 int ret = __verify_memory_type(q, create->memory, create->format.type);
727 727
728 create->index = q->num_buffers; 728 create->index = q->num_buffers;
729 if (create->count == 0)
730 return ret != -EBUSY ? ret : 0;
729 return ret ? ret : __create_bufs(q, create); 731 return ret ? ret : __create_bufs(q, create);
730} 732}
731EXPORT_SYMBOL_GPL(vb2_create_bufs); 733EXPORT_SYMBOL_GPL(vb2_create_bufs);