Message ID | 20220621043506.1142851-1-yunkec@google.com |
---|---|
State | New |
Headers | show |
Series | [v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set | expand |
Hi Yunke, Thank you for the patch. On Tue, Jun 21, 2022 at 01:35:06PM +0900, Yunke Cao wrote: > Entity controls should get_cur using an entity-defined function > instead of via a query. Fix this in uvc_ctrl_set. > > Fixes: 65900c581d01 ("media: uvcvideo: Allow entity-defined get_info and get_cur") > Signed-off-by: Yunke Cao <yunkec@google.com> > --- > drivers/media/usb/uvc/uvc_ctrl.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c > index 0e78233fc8a0..54c047019313 100644 > --- a/drivers/media/usb/uvc/uvc_ctrl.c > +++ b/drivers/media/usb/uvc/uvc_ctrl.c > @@ -1787,15 +1787,21 @@ int uvc_ctrl_set(struct uvc_fh *handle, > if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0) { > memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), > 0, ctrl->info.size); > + } else if (ctrl->entity->get_cur) { > + ret = ctrl->entity->get_cur(chain->dev, > + ctrl->entity, > + ctrl->info.selector, > + uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), > + ctrl->info.size); > } else { > ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, > ctrl->entity->id, chain->dev->intfnum, > ctrl->info.selector, > uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), > ctrl->info.size); > - if (ret < 0) > - return ret; > } > + if (ret < 0) > + return ret; ret may be used uninitialized here. > > ctrl->loaded = 1; There's very similar code in __uvc_ctrl_get(), could it be factored out, maybe into a __uvc_ctrl_get_cur() function ? > }
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 0e78233fc8a0..54c047019313 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1787,15 +1787,21 @@ int uvc_ctrl_set(struct uvc_fh *handle, if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0) { memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), 0, ctrl->info.size); + } else if (ctrl->entity->get_cur) { + ret = ctrl->entity->get_cur(chain->dev, + ctrl->entity, + ctrl->info.selector, + uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), + ctrl->info.size); } else { ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id, chain->dev->intfnum, ctrl->info.selector, uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), ctrl->info.size); - if (ret < 0) - return ret; } + if (ret < 0) + return ret; ctrl->loaded = 1; }
Entity controls should get_cur using an entity-defined function instead of via a query. Fix this in uvc_ctrl_set. Fixes: 65900c581d01 ("media: uvcvideo: Allow entity-defined get_info and get_cur") Signed-off-by: Yunke Cao <yunkec@google.com> --- drivers/media/usb/uvc/uvc_ctrl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)