diff mbox

[media] stk1160: Check *nplanes in queue_setup

Message ID 1462849574-15334-1-git-send-email-helen.koike@collabora.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Helen Koike May 10, 2016, 3:06 a.m. UTC
If *nplanes is not zero, it should use the requested size if valid

Signed-off-by: Helen Koike <helen.koike@collabora.co.uk>
---
 drivers/media/usb/stk1160/stk1160-v4l.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Hans Verkuil May 10, 2016, 6:29 a.m. UTC | #1
On 05/10/2016 05:06 AM, Helen Koike wrote:
> If *nplanes is not zero, it should use the requested size if valid

*nplanes is never 0 since the create_buffers ioctl isn't implemented in
this driver.

Adding support for it (simply use vb2_create_buffers) would make sense.

Regards,

	Hans

> 
> Signed-off-by: Helen Koike <helen.koike@collabora.co.uk>
> ---
>  drivers/media/usb/stk1160/stk1160-v4l.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
> index 77131fd..7ddbc02 100644
> --- a/drivers/media/usb/stk1160/stk1160-v4l.c
> +++ b/drivers/media/usb/stk1160/stk1160-v4l.c
> @@ -680,6 +680,9 @@ static int queue_setup(struct vb2_queue *vq,
>  	*nbuffers = clamp_t(unsigned int, *nbuffers,
>  			STK1160_MIN_VIDEO_BUFFERS, STK1160_MAX_VIDEO_BUFFERS);
>  
> +	if (*nplanes)
> +		return sizes[0] < size ? -EINVAL : 0;
> +
>  	/* This means a packed colorformat */
>  	*nplanes = 1;
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
index 77131fd..7ddbc02 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -680,6 +680,9 @@  static int queue_setup(struct vb2_queue *vq,
 	*nbuffers = clamp_t(unsigned int, *nbuffers,
 			STK1160_MIN_VIDEO_BUFFERS, STK1160_MAX_VIDEO_BUFFERS);
 
+	if (*nplanes)
+		return sizes[0] < size ? -EINVAL : 0;
+
 	/* This means a packed colorformat */
 	*nplanes = 1;