All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
@ 2013-05-15  9:19 Leon Romanovsky
  2013-05-17 18:07 ` Leon Romanovsky
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Leon Romanovsky @ 2013-05-15  9:19 UTC (permalink / raw)
  To: sameo; +Cc: linux-kernel, Leon Romanovsky

There is no need to call kfree while using devm_kzalloc,
remove it from *_device_init function.

Signed-off-by: Leon Romanovsky <leon@leon.nu>
---
 drivers/mfd/tps65912-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c
index aeb8e40..f25e552 100644
--- a/drivers/mfd/tps65912-core.c
+++ b/drivers/mfd/tps65912-core.c
@@ -127,7 +127,8 @@ int tps65912_device_init(struct tps65912 *tps65912)
 	struct tps65912_platform_data *init_data;
 	int ret, dcdc_avs, value;
 
-	init_data = kzalloc(sizeof(struct tps65912_platform_data), GFP_KERNEL);
+	init_data = devm_kzalloc(&tps65912->dev,
+			sizeof(struct tps65912_platform_data), GFP_KERNEL);
 	if (init_data == NULL)
 		return -ENOMEM;
 
@@ -156,11 +157,9 @@ int tps65912_device_init(struct tps65912 *tps65912)
 	if (ret < 0)
 		goto err;
 
-	kfree(init_data);
 	return ret;
 
 err:
-	kfree(init_data);
 	mfd_remove_devices(tps65912->dev);
 	kfree(tps65912);
 	return ret;
-- 
1.8.1.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-15  9:19 [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc Leon Romanovsky
@ 2013-05-17 18:07 ` Leon Romanovsky
  2013-05-23  8:23   ` Lee Jones
  2013-05-23  7:35 ` Lee Jones
  2013-05-23  8:37 ` Lee Jones
  2 siblings, 1 reply; 9+ messages in thread
From: Leon Romanovsky @ 2013-05-17 18:07 UTC (permalink / raw)
  To: sameo; +Cc: linux-kernel, Leon Romanovsky

Hi Samuel,

On Wed, May 15, 2013 at 12:19 PM, Leon Romanovsky <leon@leon.nu> wrote:
> There is no need to call kfree while using devm_kzalloc,
> remove it from *_device_init function.
>
> Signed-off-by: Leon Romanovsky <leon@leon.nu>
> ---
>  drivers/mfd/tps65912-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

To be honest the whole tps65912 looks strange to me.
For example,  kfree(tps65912) calls all over the code.

tps65912_i2c_probe allocates tps65912 struct, but tps65912_device_exit
releases it.


--
Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | leon@leon.nu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-15  9:19 [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc Leon Romanovsky
  2013-05-17 18:07 ` Leon Romanovsky
@ 2013-05-23  7:35 ` Lee Jones
  2013-05-23  8:37 ` Lee Jones
  2 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-05-23  7:35 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: sameo, linux-kernel

On Wed, 15 May 2013, Leon Romanovsky wrote:

> There is no need to call kfree while using devm_kzalloc,
> remove it from *_device_init function.
> 
> Signed-off-by: Leon Romanovsky <leon@leon.nu>
> ---
>  drivers/mfd/tps65912-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Applied thanks.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-17 18:07 ` Leon Romanovsky
@ 2013-05-23  8:23   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-05-23  8:23 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: sameo, linux-kernel

> > There is no need to call kfree while using devm_kzalloc,
> > remove it from *_device_init function.
> >
> > Signed-off-by: Leon Romanovsky <leon@leon.nu>
> > ---
> >  drivers/mfd/tps65912-core.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> To be honest the whole tps65912 looks strange to me.
> For example,  kfree(tps65912) calls all over the code.
> 
> tps65912_i2c_probe allocates tps65912 struct, but tps65912_device_exit
> releases it.

Yes, this is expected.

tps65912_[spi|i2c]_remove() both call tps65912_device_exit() which in
turn frees tps65912. Saves duplicating code.

I'll clean thinks up a little, so this is less confusing.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-15  9:19 [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc Leon Romanovsky
  2013-05-17 18:07 ` Leon Romanovsky
  2013-05-23  7:35 ` Lee Jones
@ 2013-05-23  8:37 ` Lee Jones
       [not found]   ` <CALq1K=Las2mwV9x6ajEUDYg6nLbcK2KVLK8TH2B1f=9fQ7JfTg@mail.gmail.com>
  2 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2013-05-23  8:37 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: sameo, linux-kernel

On Wed, 15 May 2013, Leon Romanovsky wrote:

> There is no need to call kfree while using devm_kzalloc,
> remove it from *_device_init function.
> 
> Signed-off-by: Leon Romanovsky <leon@leon.nu>
> ---
>  drivers/mfd/tps65912-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c
> index aeb8e40..f25e552 100644
> --- a/drivers/mfd/tps65912-core.c
> +++ b/drivers/mfd/tps65912-core.c
> @@ -127,7 +127,8 @@ int tps65912_device_init(struct tps65912 *tps65912)
>  	struct tps65912_platform_data *init_data;
>  	int ret, dcdc_avs, value;
>  
> -	init_data = kzalloc(sizeof(struct tps65912_platform_data), GFP_KERNEL);
> +	init_data = devm_kzalloc(&tps65912->dev,
> +			sizeof(struct tps65912_platform_data), GFP_KERNEL);

On second thoughts, have you actually built this?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
       [not found]   ` <CALq1K=Las2mwV9x6ajEUDYg6nLbcK2KVLK8TH2B1f=9fQ7JfTg@mail.gmail.com>
@ 2013-05-28  9:02     ` Lee Jones
  2013-05-28 16:24       ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2013-05-28  9:02 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Samuel Ortiz, linux-kernel

On Mon, 27 May 2013, Leon Romanovsky wrote:

> On May 23, 2013 11:37 AM, "Lee Jones" <lee.jones@linaro.org> wrote:
> >
> > On Wed, 15 May 2013, Leon Romanovsky wrote:
> >
> > > There is no need to call kfree while using devm_kzalloc,
> > > remove it from *_device_init function.
> > >
> > > Signed-off-by: Leon Romanovsky <leon@leon.nu>
> > > ---
> > >  drivers/mfd/tps65912-core.c | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c
> > > index aeb8e40..f25e552 100644
> > > --- a/drivers/mfd/tps65912-core.c
> > > +++ b/drivers/mfd/tps65912-core.c
> > > @@ -127,7 +127,8 @@ int tps65912_device_init(struct tps65912 *tps65912)
> > >       struct tps65912_platform_data *init_data;
> > >       int ret, dcdc_avs, value;
> > >
> > > -     init_data = kzalloc(sizeof(struct tps65912_platform_data),
> GFP_KERNEL);
> > > +     init_data = devm_kzalloc(&tps65912->dev,
> > > +                     sizeof(struct tps65912_platform_data),
> GFP_KERNEL);
> >
> > On second thoughts, have you actually built this?
>
> Sure,  I hope,  that I didn't miss anything.
 
Can you make absolutely sure that you did please?

I mention it because I would expect lots of warnings if you did.

Something like:

drivers/mfd/tps65912-core.c: In function ‘tps65912_reg_write’:
drivers/mfd/tps65912-core.c:117:3: warning: passing argument 1 of ‘dev_err’ from incompatible pointer type [enabled by default]
In file included from include/linux/platform_device.h:14:0,
                 from include/linux/mfd/core.h:17,
                 from drivers/mfd/tps65912-core.c:21:
include/linux/device.h:954:5: note: expected ‘const struct device *’ but argument is of type ‘struct device **’
drivers/mfd/tps65912-core.c: In function ‘tps65912_device_init’:
drivers/mfd/tps65912-core.c:131:18: warning: passing argument 1 of ‘devm_kzalloc’ from incompatible pointer type [enabled by default]
In file included from include/linux/platform_device.h:14:0,
                 from include/linux/mfd/core.h:17,
                 from drivers/mfd/tps65912-core.c:21:
include/linux/device.h:574:14: note: expected ‘struct device *’ but argument is of type ‘struct device **’

Can you check and make sure, because there's some disparity
somewhere.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-28  9:02     ` Lee Jones
@ 2013-05-28 16:24       ` Andy Shevchenko
  2013-05-28 18:36         ` Leon Romanovsky
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2013-05-28 16:24 UTC (permalink / raw)
  To: Lee Jones; +Cc: Leon Romanovsky, Samuel Ortiz, linux-kernel

On Tue, May 28, 2013 at 12:02 PM, Lee Jones <lee.jones@linaro.org> wrote:
> On Mon, 27 May 2013, Leon Romanovsky wrote:

>> > > +     init_data = devm_kzalloc(&tps65912->dev,

There is an obvious typo: no need of & here if I got it correctly.

> drivers/mfd/tps65912-core.c: In function ‘tps65912_device_init’:
> drivers/mfd/tps65912-core.c:131:18: warning: passing argument 1 of ‘devm_kzalloc’ from incompatible pointer type [enabled by default]
> In file included from include/linux/platform_device.h:14:0,
>                  from include/linux/mfd/core.h:17,
>                  from drivers/mfd/tps65912-core.c:21:
> include/linux/device.h:574:14: note: expected ‘struct device *’ but argument is of type ‘struct device **’

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-28 16:24       ` Andy Shevchenko
@ 2013-05-28 18:36         ` Leon Romanovsky
  2013-05-28 19:16           ` Lee Jones
  0 siblings, 1 reply; 9+ messages in thread
From: Leon Romanovsky @ 2013-05-28 18:36 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Lee Jones, Samuel Ortiz, linux-kernel

On Tue, May 28, 2013 at 7:24 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Tue, May 28, 2013 at 12:02 PM, Lee Jones <lee.jones@linaro.org> wrote:
>> On Mon, 27 May 2013, Leon Romanovsky wrote:
>
>>> > > +     init_data = devm_kzalloc(&tps65912->dev,
>
> There is an obvious typo: no need of & here if I got it correctly.
>
>> drivers/mfd/tps65912-core.c: In function ‘tps65912_device_init’:
>> drivers/mfd/tps65912-core.c:131:18: warning: passing argument 1 of ‘devm_kzalloc’ from incompatible pointer type [enabled by default]
>> In file included from include/linux/platform_device.h:14:0,
>>                  from include/linux/mfd/core.h:17,
>>                  from drivers/mfd/tps65912-core.c:21:
>> include/linux/device.h:574:14: note: expected ‘struct device *’ but argument is of type ‘struct device **’
You are absolutely right, I sent the wrong patch with typo :(

Lee,
Do I need to resend it ? Or you can fix it by yourself ?


>
> --
> With Best Regards,
> Andy Shevchenko



--
Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | leon@leon.nu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc
  2013-05-28 18:36         ` Leon Romanovsky
@ 2013-05-28 19:16           ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2013-05-28 19:16 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Andy Shevchenko, Samuel Ortiz, linux-kernel

On Tue, 28 May 2013, Leon Romanovsky wrote:

> On Tue, May 28, 2013 at 7:24 PM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, May 28, 2013 at 12:02 PM, Lee Jones <lee.jones@linaro.org> wrote:
> >> On Mon, 27 May 2013, Leon Romanovsky wrote:
> >
> >>> > > +     init_data = devm_kzalloc(&tps65912->dev,
> >
> > There is an obvious typo: no need of & here if I got it correctly.
> >
> >> drivers/mfd/tps65912-core.c: In function ‘tps65912_device_init’:
> >> drivers/mfd/tps65912-core.c:131:18: warning: passing argument 1 of ‘devm_kzalloc’ from incompatible pointer type [enabled by default]
> >> In file included from include/linux/platform_device.h:14:0,
> >>                  from include/linux/mfd/core.h:17,
> >>                  from drivers/mfd/tps65912-core.c:21:
> >> include/linux/device.h:574:14: note: expected ‘struct device *’ but argument is of type ‘struct device **’
> You are absolutely right, I sent the wrong patch with typo :(
> 
> Lee,
> Do I need to resend it ? Or you can fix it by yourself ?

I've already fixed it up and tested.

I just wanted to clarify exactly what happened, as it couldn't have
been tested.

No worries, patch applied.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-05-28 19:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-15  9:19 [PATCH] drivers: mfd: tps65912: Convert to use devm_kzalloc Leon Romanovsky
2013-05-17 18:07 ` Leon Romanovsky
2013-05-23  8:23   ` Lee Jones
2013-05-23  7:35 ` Lee Jones
2013-05-23  8:37 ` Lee Jones
     [not found]   ` <CALq1K=Las2mwV9x6ajEUDYg6nLbcK2KVLK8TH2B1f=9fQ7JfTg@mail.gmail.com>
2013-05-28  9:02     ` Lee Jones
2013-05-28 16:24       ` Andy Shevchenko
2013-05-28 18:36         ` Leon Romanovsky
2013-05-28 19:16           ` Lee Jones

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.