Message ID | 20250509-uvc-followup-v1-3-73bcde30d2b5@chromium.org |
---|---|
State | New |
Headers | show |
Series | media: uvcvideo: Follow-up patches for next-media-uvc-20250509 | expand |
Hi Ricardo, Thank you for the patch. On Fri, May 09, 2025 at 06:24:15PM +0000, Ricardo Ribalda wrote: > Declaring a variable for doing automatic cleanup is not a very common > pattern. Replace the cleanup macro with manual cleanup to make the code > simpler. > > Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_v4l2.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c > index 862b4e34e5b629cf324479a9bb59ebe8784ccd5d..fe3db03d7458eeb4b9a846ae4ed141bb60ea46eb 100644 > --- a/drivers/media/usb/uvc/uvc_v4l2.c > +++ b/drivers/media/usb/uvc/uvc_v4l2.c > @@ -1382,11 +1382,9 @@ static int uvc_v4l2_put_xu_query(const struct uvc_xu_control_query *kp, > #define UVCIOC_CTRL_MAP32 _IOWR('u', 0x20, struct uvc_xu_control_mapping32) > #define UVCIOC_CTRL_QUERY32 _IOWR('u', 0x21, struct uvc_xu_control_query32) > > -DEFINE_FREE(uvc_pm_put, struct uvc_device *, if (_T) uvc_pm_put(_T)) > static long uvc_v4l2_compat_ioctl32(struct file *file, > unsigned int cmd, unsigned long arg) > { > - struct uvc_device *uvc_device __free(uvc_pm_put) = NULL; > struct uvc_fh *handle = file->private_data; > union { > struct uvc_xu_control_mapping xmap; > @@ -1399,38 +1397,37 @@ static long uvc_v4l2_compat_ioctl32(struct file *file, > if (ret) > return ret; > > - uvc_device = handle->stream->dev; > - > switch (cmd) { > case UVCIOC_CTRL_MAP32: > ret = uvc_v4l2_get_xu_mapping(&karg.xmap, up); > if (ret) > - return ret; > + break; > ret = uvc_ioctl_xu_ctrl_map(handle->chain, &karg.xmap); > if (ret) > - return ret; > + break; > ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up); > if (ret) > - return ret; > - > + break; > break; > > case UVCIOC_CTRL_QUERY32: > ret = uvc_v4l2_get_xu_query(&karg.xqry, up); > if (ret) > - return ret; > + break; > ret = uvc_xu_ctrl_query(handle->chain, &karg.xqry); > if (ret) > - return ret; > + break; > ret = uvc_v4l2_put_xu_query(&karg.xqry, up); > if (ret) > - return ret; > + break; > break; > > default: > - return -ENOIOCTLCMD; > + ret = -ENOIOCTLCMD; I'll add a break; here. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > } > > + uvc_pm_put(handle->stream->dev); > + > return ret; > } > #endif
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 862b4e34e5b629cf324479a9bb59ebe8784ccd5d..fe3db03d7458eeb4b9a846ae4ed141bb60ea46eb 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -1382,11 +1382,9 @@ static int uvc_v4l2_put_xu_query(const struct uvc_xu_control_query *kp, #define UVCIOC_CTRL_MAP32 _IOWR('u', 0x20, struct uvc_xu_control_mapping32) #define UVCIOC_CTRL_QUERY32 _IOWR('u', 0x21, struct uvc_xu_control_query32) -DEFINE_FREE(uvc_pm_put, struct uvc_device *, if (_T) uvc_pm_put(_T)) static long uvc_v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) { - struct uvc_device *uvc_device __free(uvc_pm_put) = NULL; struct uvc_fh *handle = file->private_data; union { struct uvc_xu_control_mapping xmap; @@ -1399,38 +1397,37 @@ static long uvc_v4l2_compat_ioctl32(struct file *file, if (ret) return ret; - uvc_device = handle->stream->dev; - switch (cmd) { case UVCIOC_CTRL_MAP32: ret = uvc_v4l2_get_xu_mapping(&karg.xmap, up); if (ret) - return ret; + break; ret = uvc_ioctl_xu_ctrl_map(handle->chain, &karg.xmap); if (ret) - return ret; + break; ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up); if (ret) - return ret; - + break; break; case UVCIOC_CTRL_QUERY32: ret = uvc_v4l2_get_xu_query(&karg.xqry, up); if (ret) - return ret; + break; ret = uvc_xu_ctrl_query(handle->chain, &karg.xqry); if (ret) - return ret; + break; ret = uvc_v4l2_put_xu_query(&karg.xqry, up); if (ret) - return ret; + break; break; default: - return -ENOIOCTLCMD; + ret = -ENOIOCTLCMD; } + uvc_pm_put(handle->stream->dev); + return ret; } #endif
Declaring a variable for doing automatic cleanup is not a very common pattern. Replace the cleanup macro with manual cleanup to make the code simpler. Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/usb/uvc/uvc_v4l2.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)