public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: fixed: Use devm_regulator_register
@ 2014-01-25 18:05 Manish Badarkhe
  2014-01-26 21:36 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Manish Badarkhe @ 2014-01-25 18:05 UTC (permalink / raw)
  To: linux-omap, linux-samsung-soc, linux-tegra, linux-kernel
  Cc: broonie, lgirdwood, badarkhe.manish

Use "devm_regulator_register" instead of "regulator_register"
which simplifies the code.

Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
---
:100644 100644 5ea64b9... 6d32341... M	drivers/regulator/fixed.c
 drivers/regulator/fixed.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 5ea64b9..6d32341 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -186,7 +186,8 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
 	cfg.driver_data = drvdata;
 	cfg.of_node = pdev->dev.of_node;
 
-	drvdata->dev = regulator_register(&drvdata->desc, &cfg);
+	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
+					       &cfg);
 	if (IS_ERR(drvdata->dev)) {
 		ret = PTR_ERR(drvdata->dev);
 		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
@@ -212,7 +213,6 @@ static int reg_fixed_voltage_remove(struct platform_device *pdev)
 {
 	struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
 
-	regulator_unregister(drvdata->dev);
 	kfree(drvdata->desc.supply_name);
 	kfree(drvdata->desc.name);
 
-- 
1.7.10.4

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

* Re: [PATCH] regulator: fixed: Use devm_regulator_register
  2014-01-25 18:05 [PATCH] regulator: fixed: Use devm_regulator_register Manish Badarkhe
@ 2014-01-26 21:36 ` Dmitry Torokhov
  2014-01-27  0:03   ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2014-01-26 21:36 UTC (permalink / raw)
  To: Manish Badarkhe
  Cc: linux-omap, linux-samsung-soc, linux-tegra, linux-kernel, broonie,
	lgirdwood

Hi Manish,

On Sat, Jan 25, 2014 at 11:35:54PM +0530, Manish Badarkhe wrote:
> Use "devm_regulator_register" instead of "regulator_register"
> which simplifies the code.

... and also breaks the driver: now you are freeing desc->name and
desc->supply_name while regulator structures are still alive and can be
referenced from its sysfs attributes, etc.

> 
> Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
> ---
> :100644 100644 5ea64b9... 6d32341... M	drivers/regulator/fixed.c
>  drivers/regulator/fixed.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> index 5ea64b9..6d32341 100644
> --- a/drivers/regulator/fixed.c
> +++ b/drivers/regulator/fixed.c
> @@ -186,7 +186,8 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
>  	cfg.driver_data = drvdata;
>  	cfg.of_node = pdev->dev.of_node;
>  
> -	drvdata->dev = regulator_register(&drvdata->desc, &cfg);
> +	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
> +					       &cfg);
>  	if (IS_ERR(drvdata->dev)) {
>  		ret = PTR_ERR(drvdata->dev);
>  		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
> @@ -212,7 +213,6 @@ static int reg_fixed_voltage_remove(struct platform_device *pdev)
>  {
>  	struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
>  
> -	regulator_unregister(drvdata->dev);
>  	kfree(drvdata->desc.supply_name);
>  	kfree(drvdata->desc.name);
>  

Thanks.

-- 
Dmitry

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

* Re: [PATCH] regulator: fixed: Use devm_regulator_register
  2014-01-26 21:36 ` Dmitry Torokhov
@ 2014-01-27  0:03   ` Mark Brown
  2014-01-27  4:29     ` Manish Badarkhe
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2014-01-27  0:03 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Manish Badarkhe, linux-omap, linux-samsung-soc, linux-tegra,
	linux-kernel, lgirdwood

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

On Sun, Jan 26, 2014 at 01:36:53PM -0800, Dmitry Torokhov wrote:
> On Sat, Jan 25, 2014 at 11:35:54PM +0530, Manish Badarkhe wrote:

> > Use "devm_regulator_register" instead of "regulator_register"
> > which simplifies the code.

> ... and also breaks the driver: now you are freeing desc->name and
> desc->supply_name while regulator structures are still alive and can be
> referenced from its sysfs attributes, etc.

Yup, they need to be converted to managed allocations too if the
regulator_register() is going to be converted (see previous discussions
on similar patches).  It would be good to do so.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] regulator: fixed: Use devm_regulator_register
  2014-01-27  0:03   ` Mark Brown
@ 2014-01-27  4:29     ` Manish Badarkhe
  0 siblings, 0 replies; 4+ messages in thread
From: Manish Badarkhe @ 2014-01-27  4:29 UTC (permalink / raw)
  To: Mark Brown
  Cc: Dmitry Torokhov, linux-omap, linux-samsung-soc@vger.kernel.org,
	linux-tegra, linux-kernel@vger.kernel.org, Liam Girdwood

Hi

On Mon, Jan 27, 2014 at 5:33 AM, Mark Brown <broonie@kernel.org> wrote:
> On Sun, Jan 26, 2014 at 01:36:53PM -0800, Dmitry Torokhov wrote:
>> On Sat, Jan 25, 2014 at 11:35:54PM +0530, Manish Badarkhe wrote:
>
>> > Use "devm_regulator_register" instead of "regulator_register"
>> > which simplifies the code.
>
>> ... and also breaks the driver: now you are freeing desc->name and
>> desc->supply_name while regulator structures are still alive and can be
>> referenced from its sysfs attributes, etc.
>
> Yup, they need to be converted to managed allocations too if the
> regulator_register() is going to be converted (see previous discussions
> on similar patches).  It would be good to do so.

Thank you for pointing this out.
I missed to convert these two " desc->name" and "desc->supply_name"
to manage allocation. I will modify code and repost patch.

Regards
Manish Badarkhe

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

end of thread, other threads:[~2014-01-27  4:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25 18:05 [PATCH] regulator: fixed: Use devm_regulator_register Manish Badarkhe
2014-01-26 21:36 ` Dmitry Torokhov
2014-01-27  0:03   ` Mark Brown
2014-01-27  4:29     ` Manish Badarkhe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox