Skip to content

Commit d9fecd0

Browse files
ribaldamchehab
authored andcommitted
media: uvcvideo: Only save async fh if success
Now we keep a reference to the active fh for any call to uvc_ctrl_set, regardless if it is an actual set or if it is a just a try or if the device refused the operation. We should only keep the file handle if the device actually accepted applying the operation. Cc: [email protected] Fixes: e5225c8 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives") Suggested-by: Hans de Goede <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 4c2367d commit d9fecd0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,10 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain)
18111811
}
18121812

18131813
static int uvc_ctrl_commit_entity(struct uvc_device *dev,
1814-
struct uvc_entity *entity, int rollback, struct uvc_control **err_ctrl)
1814+
struct uvc_fh *handle,
1815+
struct uvc_entity *entity,
1816+
int rollback,
1817+
struct uvc_control **err_ctrl)
18151818
{
18161819
struct uvc_control *ctrl;
18171820
unsigned int i;
@@ -1859,6 +1862,10 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
18591862
*err_ctrl = ctrl;
18601863
return ret;
18611864
}
1865+
1866+
if (!rollback && handle &&
1867+
ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
1868+
ctrl->handle = handle;
18621869
}
18631870

18641871
return 0;
@@ -1895,8 +1902,8 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
18951902

18961903
/* Find the control. */
18971904
list_for_each_entry(entity, &chain->entities, chain) {
1898-
ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
1899-
&err_ctrl);
1905+
ret = uvc_ctrl_commit_entity(chain->dev, handle, entity,
1906+
rollback, &err_ctrl);
19001907
if (ret < 0) {
19011908
if (ctrls)
19021909
ctrls->error_idx =
@@ -2046,9 +2053,6 @@ int uvc_ctrl_set(struct uvc_fh *handle,
20462053
mapping->set(mapping, value,
20472054
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
20482055

2049-
if (ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
2050-
ctrl->handle = handle;
2051-
20522056
ctrl->dirty = 1;
20532057
ctrl->modified = 1;
20542058
return 0;
@@ -2377,7 +2381,7 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
23772381
ctrl->dirty = 1;
23782382
}
23792383

2380-
ret = uvc_ctrl_commit_entity(dev, entity, 0, NULL);
2384+
ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0, NULL);
23812385
if (ret < 0)
23822386
return ret;
23832387
}

0 commit comments

Comments
 (0)