* [PATCH v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set
@ 2022-06-21 4:35 Yunke Cao
2022-06-21 5:51 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Yunke Cao @ 2022-06-21 4:35 UTC (permalink / raw)
To: Laurent Pinchart, Ricardo Ribalda, Mauro Carvalho Chehab
Cc: linux-media, Yunke Cao
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;
ctrl->loaded = 1;
}
--
2.37.0.rc0.104.g0611611a94-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set
2022-06-21 4:35 [PATCH v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set Yunke Cao
@ 2022-06-21 5:51 ` Laurent Pinchart
2022-06-21 6:11 ` Yunke Cao
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2022-06-21 5:51 UTC (permalink / raw)
To: Yunke Cao; +Cc: Ricardo Ribalda, Mauro Carvalho Chehab, linux-media
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 ?
> }
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set
2022-06-21 5:51 ` Laurent Pinchart
@ 2022-06-21 6:11 ` Yunke Cao
0 siblings, 0 replies; 3+ messages in thread
From: Yunke Cao @ 2022-06-21 6:11 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Ricardo Ribalda, Mauro Carvalho Chehab, linux-media
Hi Laurent,
Thanks for the review.
On Tue, Jun 21, 2022 at 2:51 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> 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 ?
>
Sounds good! I'm sending out v2.
Changelog since v1:
-Factored out common logic into __uvc_ctrl_load_cur(). (I called it
"load_cur" because I feel it's a bit more accurate)
Best,
Yunke
> > }
>
> --
> Regards,
>
> Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-21 6:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 4:35 [PATCH v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set Yunke Cao
2022-06-21 5:51 ` Laurent Pinchart
2022-06-21 6:11 ` Yunke Cao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.