linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] v4l2-ctrls.c: allow empty control handlers
@ 2017-09-25  9:41 Hans Verkuil
  2017-09-25 10:01 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2017-09-25  9:41 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Dave Stevenson

If you have a control handler that does not contain any controls, then
currently calling VIDIOC_G/S/TRY_EXT_CTRLS with count == 0 will return
-EINVAL in the class_check() function.

This is not correct, there is no reason why this should return an error.

The purpose of setting count to 0 is to test if the ioctl can mix controls
from different control classes. And this is possible. The fact that there
are not actually any controls defined is another matter that is unrelated
to this test.

This caused v4l2-compliance to fail, so that is fixed with this patch applied.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index dd1db678718c..4e53a8654690 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2818,7 +2818,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
 static int class_check(struct v4l2_ctrl_handler *hdl, u32 which)
 {
 	if (which == 0 || which == V4L2_CTRL_WHICH_DEF_VAL)
-		return list_empty(&hdl->ctrl_refs) ? -EINVAL : 0;
+		return 0;
 	return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] v4l2-ctrls.c: allow empty control handlers
  2017-09-25  9:41 [PATCH] v4l2-ctrls.c: allow empty control handlers Hans Verkuil
@ 2017-09-25 10:01 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2017-09-25 10:01 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Dave Stevenson

On Mon, Sep 25, 2017 at 11:41:02AM +0200, Hans Verkuil wrote:
> If you have a control handler that does not contain any controls, then
> currently calling VIDIOC_G/S/TRY_EXT_CTRLS with count == 0 will return
> -EINVAL in the class_check() function.
> 
> This is not correct, there is no reason why this should return an error.
> 
> The purpose of setting count to 0 is to test if the ioctl can mix controls
> from different control classes. And this is possible. The fact that there
> are not actually any controls defined is another matter that is unrelated
> to this test.
> 
> This caused v4l2-compliance to fail, so that is fixed with this patch applied.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> Reported-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.org>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-25 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25  9:41 [PATCH] v4l2-ctrls.c: allow empty control handlers Hans Verkuil
2017-09-25 10:01 ` Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).