Skip to content

Commit ba4fafb

Browse files
ribaldahverkuil
authored andcommitted
media: uvcvideo: Return the number of processed controls
If we let know our callers that we have not done anything, they will be able to optimize their decisions. Cc: stable@kernel.org Fixes: b401200 ("[media] uvcvideo: Add support for control events") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Message-ID: <20250224-uvc-data-backup-v2-1-de993ed9823b@chromium.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
1 parent d1b618e commit ba4fafb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2101,12 +2101,17 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain)
21012101
return mutex_lock_interruptible(&chain->ctrl_mutex) ? -ERESTARTSYS : 0;
21022102
}
21032103

2104+
/*
2105+
* Returns the number of uvc controls that have been correctly set, or a
2106+
* negative number if there has been an error.
2107+
*/
21042108
static int uvc_ctrl_commit_entity(struct uvc_device *dev,
21052109
struct uvc_fh *handle,
21062110
struct uvc_entity *entity,
21072111
int rollback,
21082112
struct uvc_control **err_ctrl)
21092113
{
2114+
unsigned int processed_ctrls = 0;
21102115
struct uvc_control *ctrl;
21112116
unsigned int i;
21122117
int ret;
@@ -2141,6 +2146,9 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
21412146
else
21422147
ret = 0;
21432148

2149+
if (!ret)
2150+
processed_ctrls++;
2151+
21442152
if (rollback || ret < 0)
21452153
memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
21462154
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP),
@@ -2159,7 +2167,7 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
21592167
}
21602168
}
21612169

2162-
return 0;
2170+
return processed_ctrls;
21632171
}
21642172

21652173
static int uvc_ctrl_find_ctrl_idx(struct uvc_entity *entity,
@@ -2206,6 +2214,7 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
22062214

22072215
if (!rollback)
22082216
uvc_ctrl_send_events(handle, ctrls->controls, ctrls->count);
2217+
ret = 0;
22092218
done:
22102219
mutex_unlock(&chain->ctrl_mutex);
22112220
return ret;

0 commit comments

Comments
 (0)