regulator: fixed: Use devm_regulator_register
PATCH 1/1 regulator: fixed: Use devm_regulator_register
Use "devm_regulator_register" instead of "regulator_register" which simplifies the code.
---
:100644 100644 5ea64b9... 6d32341... M drivers/regulator/fixed.c
drivers/regulator/fixed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/fixed.c +2 -2
@@ -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);
Signature · 1 line
1.7.10.4
Hi Manish,
Quoted 2 lines · Manish Badarkhe
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.
Quoted 22 lines
Signed-off-by Manish Badarkhe <[email protected]>---
:100644 100644 5ea64b9... 6d32341... Mdrivers/regulator/fixed.cdrivers/regulator/fixed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/regulator/fixed.c +2
-1@@ -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);
drivers/regulator/fixed.c static int reg_fixed_voltage_remove(struct platform_device *pdev) · line 218
Quoted 7 lines
drivers/regulator/fixed.c +0
-1@@ -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.
Signature · 1 line
Dmitry
Mark Brown
maintainerQuoted 8 lines · Dmitry Torokhov
Quoted 2 lines · Manish Badarkhe
Use "
devm_regulator_register" instead of "regulator_register" which simplifies the code.... and also breaks the driver: now you are freeing
desc->nameanddesc->supply_namewhile 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.
Hi
Quoted 6 lines · Mark Brown
Quoted 4 lines · Dmitry Torokhov
Quoted 2 lines · Manish Badarkhe
Use "
devm_regulator_register" instead of "regulator_register" which simplifies the code.
Quoted 7 lines
Quoted 3 lines
... and also breaks the driver: now you are freeing
desc->nameanddesc->supply_namewhile 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