Skip to content

Commit b52dc88

Browse files
ribaldagregkh
authored andcommitted
media: uvcvideo: Return the number of processed controls
commit ba4fafb upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0ee9469 commit b52dc88

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
@@ -1830,12 +1830,17 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain)
18301830
return mutex_lock_interruptible(&chain->ctrl_mutex) ? -ERESTARTSYS : 0;
18311831
}
18321832

1833+
/*
1834+
* Returns the number of uvc controls that have been correctly set, or a
1835+
* negative number if there has been an error.
1836+
*/
18331837
static int uvc_ctrl_commit_entity(struct uvc_device *dev,
18341838
struct uvc_fh *handle,
18351839
struct uvc_entity *entity,
18361840
int rollback,
18371841
struct uvc_control **err_ctrl)
18381842
{
1843+
unsigned int processed_ctrls = 0;
18391844
struct uvc_control *ctrl;
18401845
unsigned int i;
18411846
int ret;
@@ -1870,6 +1875,9 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
18701875
else
18711876
ret = 0;
18721877

1878+
if (!ret)
1879+
processed_ctrls++;
1880+
18731881
if (rollback || ret < 0)
18741882
memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
18751883
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP),
@@ -1888,7 +1896,7 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
18881896
uvc_ctrl_set_handle(handle, ctrl, handle);
18891897
}
18901898

1891-
return 0;
1899+
return processed_ctrls;
18921900
}
18931901

18941902
static int uvc_ctrl_find_ctrl_idx(struct uvc_entity *entity,
@@ -1935,6 +1943,7 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
19351943

19361944
if (!rollback)
19371945
uvc_ctrl_send_events(handle, ctrls->controls, ctrls->count);
1946+
ret = 0;
19381947
done:
19391948
mutex_unlock(&chain->ctrl_mutex);
19401949
return ret;

0 commit comments

Comments
 (0)