All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rix <trix@redhat.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	mchehab@kernel.org, cai.huoqing@linux.dev, paskripkin@gmail.com,
	xose.vazquez@gmail.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: stkwebcam: move stk_camera_read_reg() scratch buffer to struct stk_camera
Date: Wed, 27 Apr 2022 12:03:21 -0700	[thread overview]
Message-ID: <f4b83fc9-f4b8-f9d5-43d6-61decc497e07@redhat.com> (raw)
In-Reply-To: <8cab70e2-cd3f-da75-9e6a-1d63e33e6e24@xs4all.nl>


On 4/26/22 10:38 PM, Hans Verkuil wrote:
> 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.

Merged as-is is fine.

Thanks

Tom


>
> 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)


      reply	other threads:[~2022-04-27 19:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12 17:30 [PATCH] media: stkwebcam: move stk_camera_read_reg() scratch buffer to struct stk_camera trix
2022-03-12 19:50 ` Pavel Skripkin
2022-03-12 19:58 ` Pavel Skripkin
2022-03-12 23:48   ` Tom Rix
2022-03-13 15:11     ` Pavel Skripkin
2022-03-13 15:35       ` Tom Rix
2022-04-27  5:38 ` Hans Verkuil
2022-04-27 19:03   ` Tom Rix [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4b83fc9-f4b8-f9d5-43d6-61decc497e07@redhat.com \
    --to=trix@redhat.com \
    --cc=cai.huoqing@linux.dev \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paskripkin@gmail.com \
    --cc=xose.vazquez@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.