Re: [PATCH v1] media: uvcvideo: user entity get_cur in uvc_ctrl_set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Laurent,

Thanks for the review.

On Tue, Jun 21, 2022 at 2:51 PM Laurent Pinchart
<laurent.pinchart@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxx>
> > ---
> >  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



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux