[PATCH v3 3/8] media: uvcvideo: Return -EACCES for Wrong state error

From: Ricardo Ribalda
Date: Tue Jan 03 2023 - 09:37:28 EST


Error 2 is defined by UVC as:
Wrong State: The device is in a state that disallows the specific
request. The device will remain in this state until a specific action
from the host or the user is completed.

This is documented as happening when attempting to set the value of a
manual control when the device is in auto mode. While V4L2 allows this,
the closest error code defined by VIDIOC_S_CTRL is indeed EACCES:
EACCES: Attempt to set a read-only control or to get a write-only control.
Or if there is an attempt to set an inactive control and the driver
is not capable of caching the new value until the control is active
again.

Replace EILSEQ with EACCES.

Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
Suggested-by: Hans Verkuil <hans.verkuil@xxxxxxxxx>
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
drivers/media/usb/uvc/uvc_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 6b20a23bc3cf..e56ccde9bd10 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -108,7 +108,7 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
case 1: /* Not ready */
return -EBUSY;
case 2: /* Wrong state */
- return -EILSEQ;
+ return -EACCES;
case 3: /* Power */
return -EREMOTE;
case 4: /* Out of range */

--
2.39.0.314.g84b9a713c41-goog-b4-0.11.0-dev-696ae