From e54532e591cd5b9ce77dbc8d9786ae9f600f101a Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 23 Jan 2010 07:07:53 -0300 Subject: V4L/DVB: uvcvideo: Clamp control values to the minimum and maximum values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting a control, the V4L2 specification requires drivers to either clamp the control value to the [minimum, maximum] range or return the -ERANGE error. Fix the driver to clamp control values to the valid range in uvc_ctrl_set() and make sure the value differs from the minimum by an integer multiple of step. Signed-off-by: Laurent Pinchart Tested-by: Márton Németh Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/uvc/uvc_v4l2.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/media/video/uvc/uvc_v4l2.c') diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index 23239a4adef..bf1fc7f29ca 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c @@ -549,6 +549,8 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) return ret; } ret = uvc_ctrl_commit(chain); + if (ret == 0) + ctrl->value = xctrl.value; break; } -- cgit v1.2.3-70-g09d2 From 8d55662512127c84ac90873fb68ba44842e2c426 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 4 Feb 2010 21:43:37 -0300 Subject: V4L/DVB: uvcvideo: Check uvc_ctrl_begin return value in VIDIOC_S_CTRL The function return value wasn't checked due to a missing variable assignment. Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/uvc/uvc_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/video/uvc/uvc_v4l2.c') diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index bf1fc7f29ca..43152aa5222 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c @@ -539,7 +539,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) xctrl.id = ctrl->id; xctrl.value = ctrl->value; - uvc_ctrl_begin(chain); + ret = uvc_ctrl_begin(chain); if (ret < 0) return ret; -- cgit v1.2.3-70-g09d2