Re: [PATCH v2] media: i2c: adv748x: Use devm to allocate the device struct

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

 



Hi Kieran,

Thanks for your work.

On 2019-01-11 16:17:03 +0000, Kieran Bingham wrote:
> From: Steve Longerbeam <steve_longerbeam@xxxxxxxxxx>
> 
> Switch to devm_kzalloc() when allocating the adv748x device struct.
> 
> The sizeof() is updated to determine the correct allocation size from
> the dereferenced pointer type rather than hardcoding the struct type.

I would put this under a changes since v1 section and not for inclusion 
on the commit message upstream. Apart from that

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>

> 
> Signed-off-by: Steve Longerbeam <steve_longerbeam@xxxxxxxxxx>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@xxxxxxxxxxxxxxxx>
> [Kieran: Change sizeof() to dereference the pointer type]
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@xxxxxxxxxxxxxxxx>
> ---
>  drivers/media/i2c/adv748x/adv748x-core.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 060d0c5b4989..1e5c7bbcf6b2 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -674,7 +674,7 @@ static int adv748x_probe(struct i2c_client *client,
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
>  		return -EIO;
>  
> -	state = kzalloc(sizeof(struct adv748x_state), GFP_KERNEL);
> +	state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
>  	if (!state)
>  		return -ENOMEM;
>  
> @@ -772,7 +772,6 @@ static int adv748x_probe(struct i2c_client *client,
>  	adv748x_dt_cleanup(state);
>  err_free_mutex:
>  	mutex_destroy(&state->mutex);
> -	kfree(state);
>  
>  	return ret;
>  }
> @@ -791,8 +790,6 @@ static int adv748x_remove(struct i2c_client *client)
>  	adv748x_dt_cleanup(state);
>  	mutex_destroy(&state->mutex);
>  
> -	kfree(state);
> -
>  	return 0;
>  }
>  
> -- 
> 2.17.1
> 

-- 
Regards,
Niklas Söderlund



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux