mbox series

[-next,v3,0/2] media: cx231xx: Switch to use kmemdup() helper and add two macros

Message ID 20230903081440.1564633-1-ruanjinjie@huawei.com
Headers show
Series media: cx231xx: Switch to use kmemdup() helper and add two macros | expand

Message

Jinjie Ruan Sept. 3, 2023, 8:14 a.m. UTC
Use kmemdup() helper instead of open-coding to simplify the code.

On the other hand, as Andrzej suggested, add EP5_BUF_SIZE and
EP5_TIMEOUT_MS macros to replace the magic constant 4096 and 2000.

Changes in v3:
- Adjust the second patch to be the first.
- Update the names of the macros.

Jinjie Ruan (2):
  media: cx231xx: Switch to use kmemdup() helper
  media: cx231xx: Add EP5_BUF_SIZE and EP5_TIMEOUT_MS macros

 drivers/media/usb/cx231xx/cx231xx-core.c | 5 ++---
 drivers/media/usb/cx231xx/cx231xx.h      | 3 +++
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Andrzej Pietrasiewicz Sept. 8, 2023, 12:19 p.m. UTC | #1
Hi,

W dniu 3.09.2023 o 10:14, Jinjie Ruan pisze:
> Use kmemdup() helper instead of open-coding to
> simplify the code.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

I have already reviewed this before, you can add my

Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>

> ---
> v2:
> - Adjust use kmemdup() helper to be the first patch as suggested.
> ---
>   drivers/media/usb/cx231xx/cx231xx-core.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
> index 727e6268567f..746727ea1a4c 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-core.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-core.c
> @@ -751,10 +751,9 @@ int cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size)
>   	int ret = -ENOMEM;
>   	u32 *buffer;
>   
> -	buffer = kzalloc(4096, GFP_KERNEL);
> +	buffer = kmemdup(firmware, 4096, GFP_KERNEL);
>   	if (buffer == NULL)
>   		return -ENOMEM;
> -	memcpy(&buffer[0], firmware, 4096);
>   
>   	ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5),
>   			buffer, 4096, &actlen, 2000);
Jinjie Ruan Sept. 9, 2023, 7:29 a.m. UTC | #2
On 2023/9/8 20:19, Andrzej Pietrasiewicz wrote:
> Hi,
> 
> W dniu 3.09.2023 o 10:14, Jinjie Ruan pisze:
>> Use kmemdup() helper instead of open-coding to
>> simplify the code.
>>
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> 
> I have already reviewed this before, you can add my
> 
> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>

Thank you very much!

> 
>> ---
>> v2:
>> - Adjust use kmemdup() helper to be the first patch as suggested.
>> ---
>>   drivers/media/usb/cx231xx/cx231xx-core.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c
>> b/drivers/media/usb/cx231xx/cx231xx-core.c
>> index 727e6268567f..746727ea1a4c 100644
>> --- a/drivers/media/usb/cx231xx/cx231xx-core.c
>> +++ b/drivers/media/usb/cx231xx/cx231xx-core.c
>> @@ -751,10 +751,9 @@ int cx231xx_ep5_bulkout(struct cx231xx *dev, u8
>> *firmware, u16 size)
>>       int ret = -ENOMEM;
>>       u32 *buffer;
>>   -    buffer = kzalloc(4096, GFP_KERNEL);
>> +    buffer = kmemdup(firmware, 4096, GFP_KERNEL);
>>       if (buffer == NULL)
>>           return -ENOMEM;
>> -    memcpy(&buffer[0], firmware, 4096);
>>         ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5),
>>               buffer, 4096, &actlen, 2000);
>