* [PATCH 2/2] media: i2c: adv748x: Use devm to allocate the device struct
@ 2019-01-11 15:43 Kieran Bingham
2019-01-11 16:08 ` Kieran Bingham
0 siblings, 1 reply; 3+ messages in thread
From: Kieran Bingham @ 2019-01-11 15:43 UTC (permalink / raw)
To: linux-media, linux-renesas-soc, Kieran Bingham; +Cc: Steve Longerbeam
From: Steve Longerbeam <steve_longerbeam@mentor.com>
Switch to devm_kzalloc() when allocating the adv748x device struct.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
drivers/media/i2c/adv748x/adv748x-core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 097e5c3a8e7e..4af2ae8fcc0a 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -774,7 +774,8 @@ 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(struct adv748x_state),
+ GFP_KERNEL);
if (!state)
return -ENOMEM;
@@ -861,7 +862,6 @@ static int adv748x_probe(struct i2c_client *client,
adv748x_dt_cleanup(state);
err_free_mutex:
mutex_destroy(&state->mutex);
- kfree(state);
return ret;
}
@@ -880,8 +880,6 @@ static int adv748x_remove(struct i2c_client *client)
adv748x_dt_cleanup(state);
mutex_destroy(&state->mutex);
- kfree(state);
-
return 0;
}
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] media: i2c: adv748x: Use devm to allocate the device struct
2019-01-11 15:43 [PATCH 2/2] media: i2c: adv748x: Use devm to allocate the device struct Kieran Bingham
@ 2019-01-11 16:08 ` Kieran Bingham
2019-01-11 18:23 ` Steve Longerbeam
0 siblings, 1 reply; 3+ messages in thread
From: Kieran Bingham @ 2019-01-11 16:08 UTC (permalink / raw)
To: linux-media, linux-renesas-soc, Steve Longerbeam
Hi Steve,
On 11/01/2019 15:43, Kieran Bingham wrote:
> From: Steve Longerbeam <steve_longerbeam@mentor.com>
Thank you for the patch, (which was forwarded to me from the BSP team)
> Switch to devm_kzalloc() when allocating the adv748x device struct.
>
> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
> ---
> drivers/media/i2c/adv748x/adv748x-core.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 097e5c3a8e7e..4af2ae8fcc0a 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -774,7 +774,8 @@ 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(struct adv748x_state),
I would instead use:
state = devm_kzalloc(&client->dev, sizeof(*state));
I will submit a v2 with this change made.
--
Regards
Kieran
> + GFP_KERNEL);
> if (!state)
> return -ENOMEM;
>
> @@ -861,7 +862,6 @@ static int adv748x_probe(struct i2c_client *client,
> adv748x_dt_cleanup(state);
> err_free_mutex:
> mutex_destroy(&state->mutex);
> - kfree(state);
>
> return ret;
> }
> @@ -880,8 +880,6 @@ static int adv748x_remove(struct i2c_client *client)
> adv748x_dt_cleanup(state);
> mutex_destroy(&state->mutex);
>
> - kfree(state);
> -
> return 0;
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] media: i2c: adv748x: Use devm to allocate the device struct
2019-01-11 16:08 ` Kieran Bingham
@ 2019-01-11 18:23 ` Steve Longerbeam
0 siblings, 0 replies; 3+ messages in thread
From: Steve Longerbeam @ 2019-01-11 18:23 UTC (permalink / raw)
To: kieran.bingham+renesas, linux-media, linux-renesas-soc
On 1/11/19 8:08 AM, Kieran Bingham wrote:
> Hi Steve,
>
> On 11/01/2019 15:43, Kieran Bingham wrote:
>> From: Steve Longerbeam <steve_longerbeam@mentor.com>
> Thank you for the patch, (which was forwarded to me from the BSP team)
>
>> Switch to devm_kzalloc() when allocating the adv748x device struct.
>>
>> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
>> ---
>> drivers/media/i2c/adv748x/adv748x-core.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
>> index 097e5c3a8e7e..4af2ae8fcc0a 100644
>> --- a/drivers/media/i2c/adv748x/adv748x-core.c
>> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
>> @@ -774,7 +774,8 @@ 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(struct adv748x_state),
> I would instead use:
>
> state = devm_kzalloc(&client->dev, sizeof(*state));
Agreed!
>
> I will submit a v2 with this change made.
Thanks Kieran.
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-11 18:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 15:43 [PATCH 2/2] media: i2c: adv748x: Use devm to allocate the device struct Kieran Bingham
2019-01-11 16:08 ` Kieran Bingham
2019-01-11 18:23 ` Steve Longerbeam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).