lkml.org 
[lkml]   [2022]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] media: stkwebcam: move stk_camera_read_reg() scratch buffer to struct stk_camera
From
Hi Tom,

On 12/03/2022 18:30, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> In stk_camera_read_reg() a single byte buffer is alloc-ed and
> freed on every function call. Since the size is known,
> move the buffer to the struct stk_camera where it will be alloc-ed
> and freed once.

I read the replies to this patch, but I am not certain if you still want
this patch to be merged, or will make a v2. I have no problem applying this
patch as-is, but I just want to have confirmation that there won't be a v2.

Regards,

Hans

>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/media/usb/stkwebcam/stk-webcam.c | 11 ++---------
> drivers/media/usb/stkwebcam/stk-webcam.h | 2 ++
> 2 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
> index 5b822214ccc5c..787edb3d47c23 100644
> --- a/drivers/media/usb/stkwebcam/stk-webcam.c
> +++ b/drivers/media/usb/stkwebcam/stk-webcam.c
> @@ -150,25 +150,18 @@ int stk_camera_write_reg(struct stk_camera *dev, u16 index, u8 value)
> int stk_camera_read_reg(struct stk_camera *dev, u16 index, u8 *value)
> {
> struct usb_device *udev = dev->udev;
> - unsigned char *buf;
> int ret;
>
> - buf = kmalloc(sizeof(u8), GFP_KERNEL);
> - if (!buf)
> - return -ENOMEM;
> -
> ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> 0x00,
> USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> 0x00,
> index,
> - buf,
> + &dev->read_reg_scratch,
> sizeof(u8),
> 500);
> if (ret >= 0)
> - *value = *buf;
> -
> - kfree(buf);
> + *value = dev->read_reg_scratch;
>
> if (ret < 0)
> return ret;
> diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h
> index 14519e5308b18..136decffe9ced 100644
> --- a/drivers/media/usb/stkwebcam/stk-webcam.h
> +++ b/drivers/media/usb/stkwebcam/stk-webcam.h
> @@ -105,6 +105,8 @@ struct stk_camera {
> struct list_head sio_avail;
> struct list_head sio_full;
> unsigned sequence;
> +
> + u8 read_reg_scratch;
> };
>
> #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)

\
 
 \ /
  Last update: 2022-04-27 07:40    [W:0.108 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site