* [PATCH V2] regulator: fixed: update to devm_* API
@ 2014-01-28 3:12 Manish Badarkhe
[not found] ` <1390878720-8676-1-git-send-email-badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Manish Badarkhe @ 2014-01-28 3:12 UTC (permalink / raw)
To: linux-omap, linux-samsung-soc, linux-tegra, linux-kernel
Cc: broonie, lgirdwood, badarkhe.manish
Update the code to use devm_* API so that driver core will manage
resources.
Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
---
Changes since V1:
1. Updated driver to use "devm_kzalloc" to "kstrdup".
2. Updated commit message.
Not tested on any board.
:100644 100644 5ea64b9... e9763a4... M drivers/regulator/fixed.c
drivers/regulator/fixed.c | 42 ++++++++++++------------------------------
1 file changed, 12 insertions(+), 30 deletions(-)
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 5ea64b9..e9763a4 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
GFP_KERNEL);
if (drvdata == NULL) {
dev_err(&pdev->dev, "Failed to allocate device data\n");
- ret = -ENOMEM;
- goto err;
+ return -ENOMEM;
}
- drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
+ drvdata->desc.name = devm_kzalloc(&pdev->dev,
+ strlen(config->supply_name) + 1,
+ GFP_KERNEL);
if (drvdata->desc.name == NULL) {
dev_err(&pdev->dev, "Failed to allocate supply name\n");
- ret = -ENOMEM;
- goto err;
+ return -ENOMEM;
}
drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE;
@@ -149,13 +149,13 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
drvdata->desc.enable_time = config->startup_delay;
if (config->input_supply) {
- drvdata->desc.supply_name = kstrdup(config->input_supply,
- GFP_KERNEL);
+ drvdata->desc.supply_name = devm_kzalloc(&pdev->dev,
+ strlen(config->input_supply) + 1,
+ GFP_KERNEL);
if (!drvdata->desc.supply_name) {
dev_err(&pdev->dev,
"Failed to allocate input supply\n");
- ret = -ENOMEM;
- goto err_name;
+ return -ENOMEM;
}
}
@@ -186,11 +186,12 @@ 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);
- goto err_input;
+ return ret;
}
platform_set_drvdata(pdev, drvdata);
@@ -199,24 +200,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
drvdata->desc.fixed_uV);
return 0;
-
-err_input:
- kfree(drvdata->desc.supply_name);
-err_name:
- kfree(drvdata->desc.name);
-err:
- return ret;
-}
-
-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);
-
- return 0;
}
#if defined(CONFIG_OF)
@@ -229,7 +212,6 @@ MODULE_DEVICE_TABLE(of, fixed_of_match);
static struct platform_driver regulator_fixed_voltage_driver = {
.probe = reg_fixed_voltage_probe,
- .remove = reg_fixed_voltage_remove,
.driver = {
.name = "reg-fixed-voltage",
.owner = THIS_MODULE,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
[not found] ` <1390878720-8676-1-git-send-email-badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-01-28 6:33 ` Dmitry Torokhov
2014-01-28 7:16 ` Manish Badarkhe
2014-01-28 16:41 ` Stephen Warren
1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2014-01-28 6:33 UTC (permalink / raw)
To: Manish Badarkhe
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w
Hi Manish,
On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
> Update the code to use devm_* API so that driver core will manage
> resources.
>
> Signed-off-by: Manish Badarkhe <badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> Changes since V1:
> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
> 2. Updated commit message.
>
> Not tested on any board.
>
> :100644 100644 5ea64b9... e9763a4... M drivers/regulator/fixed.c
> drivers/regulator/fixed.c | 42 ++++++++++++------------------------------
> 1 file changed, 12 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> index 5ea64b9..e9763a4 100644
> --- a/drivers/regulator/fixed.c
> +++ b/drivers/regulator/fixed.c
> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
> GFP_KERNEL);
> if (drvdata == NULL) {
> dev_err(&pdev->dev, "Failed to allocate device data\n");
> - ret = -ENOMEM;
> - goto err;
> + return -ENOMEM;
> }
>
> - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
> + strlen(config->supply_name) + 1,
> + GFP_KERNEL);
> if (drvdata->desc.name == NULL) {
> dev_err(&pdev->dev, "Failed to allocate supply name\n");
> - ret = -ENOMEM;
> - goto err;
> + return -ENOMEM;
> }
Umm, I am fairly certain that devm_kzalloc() can't be used as a
substitute for kstrdup, at least not without accompanying memcpy.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
2014-01-28 6:33 ` Dmitry Torokhov
@ 2014-01-28 7:16 ` Manish Badarkhe
2014-01-28 7:38 ` Heiko Stübner
0 siblings, 1 reply; 10+ messages in thread
From: Manish Badarkhe @ 2014-01-28 7:16 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-omap, linux-samsung-soc@vger.kernel.org, linux-tegra,
linux-kernel@vger.kernel.org, Mark Brown, Liam Girdwood
Hi Dmitry,
Thank you for your review.
On Tue, Jan 28, 2014 at 12:03 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Manish,
>
> On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
>> Update the code to use devm_* API so that driver core will manage
>> resources.
>>
>> Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
>> ---
>> Changes since V1:
>> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
>> 2. Updated commit message.
>>
>> Not tested on any board.
>>
>> :100644 100644 5ea64b9... e9763a4... M drivers/regulator/fixed.c
>> drivers/regulator/fixed.c | 42 ++++++++++++------------------------------
>> 1 file changed, 12 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
>> index 5ea64b9..e9763a4 100644
>> --- a/drivers/regulator/fixed.c
>> +++ b/drivers/regulator/fixed.c
>> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
>> GFP_KERNEL);
>> if (drvdata == NULL) {
>> dev_err(&pdev->dev, "Failed to allocate device data\n");
>> - ret = -ENOMEM;
>> - goto err;
>> + return -ENOMEM;
>> }
>>
>> - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
>> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
>> + strlen(config->supply_name) + 1,
>> + GFP_KERNEL);
>> if (drvdata->desc.name == NULL) {
>> dev_err(&pdev->dev, "Failed to allocate supply name\n");
>> - ret = -ENOMEM;
>> - goto err;
>> + return -ENOMEM;
>> }
>
> Umm, I am fairly certain that devm_kzalloc() can't be used as a
> substitute for kstrdup, at least not without accompanying memcpy.
Yes, I have provided allocation but it should be followed with assignment.
Can I modify like this,
+ drvdata->desc.name = devm_kzalloc(&pdev->dev,
+ strlen(config->supply_name) + 1,
+ GFP_KERNEL);
+ if (drvdata->desc.name)
+ sprintf(drvdata->desc.name, "%s", config->supply_name);
Thanks
Manish Badakhe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
2014-01-28 7:16 ` Manish Badarkhe
@ 2014-01-28 7:38 ` Heiko Stübner
2014-01-28 8:46 ` Manish Badarkhe
0 siblings, 1 reply; 10+ messages in thread
From: Heiko Stübner @ 2014-01-28 7:38 UTC (permalink / raw)
To: Manish Badarkhe
Cc: Dmitry Torokhov, linux-omap, linux-samsung-soc@vger.kernel.org,
linux-tegra, linux-kernel@vger.kernel.org, Mark Brown,
Liam Girdwood
On Tuesday, 28. January 2014 12:46:01 Manish Badarkhe wrote:
> Hi Dmitry,
>
> Thank you for your review.
>
> On Tue, Jan 28, 2014 at 12:03 PM, Dmitry Torokhov
>
> <dmitry.torokhov@gmail.com> wrote:
> > Hi Manish,
> >
> > On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
> >> Update the code to use devm_* API so that driver core will manage
> >> resources.
> >>
> >> Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
> >> ---
> >> Changes since V1:
> >> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
> >> 2. Updated commit message.
> >>
> >> Not tested on any board.
> >>
> >> :100644 100644 5ea64b9... e9763a4... M drivers/regulator/fixed.c
> >> :
> >> drivers/regulator/fixed.c | 42
> >> ++++++++++++------------------------------
> >> 1 file changed, 12 insertions(+), 30 deletions(-)
> >>
> >> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> >> index 5ea64b9..e9763a4 100644
> >> --- a/drivers/regulator/fixed.c
> >> +++ b/drivers/regulator/fixed.c
> >> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct
> >> platform_device *pdev)>>
> >> GFP_KERNEL);
> >>
> >> if (drvdata == NULL) {
> >>
> >> dev_err(&pdev->dev, "Failed to allocate device data\n");
> >>
> >> - ret = -ENOMEM;
> >> - goto err;
> >> + return -ENOMEM;
> >>
> >> }
> >>
> >> - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
> >> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
> >> + strlen(config->supply_name) + 1,
> >> + GFP_KERNEL);
> >>
> >> if (drvdata->desc.name == NULL) {
> >>
> >> dev_err(&pdev->dev, "Failed to allocate supply name\n");
> >>
> >> - ret = -ENOMEM;
> >> - goto err;
> >> + return -ENOMEM;
> >>
> >> }
> >
> > Umm, I am fairly certain that devm_kzalloc() can't be used as a
> > substitute for kstrdup, at least not without accompanying memcpy.
>
> Yes, I have provided allocation but it should be followed with assignment.
> Can I modify like this,
>
> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
> + strlen(config->supply_name) + 1,
> + GFP_KERNEL);
> + if (drvdata->desc.name)
> + sprintf(drvdata->desc.name, "%s", config->supply_name);
hmm, so you replaced a general helper function by open coding the string-
duplication. Doesn't this defeat the target of simplifying the code?
Heiko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
2014-01-28 7:38 ` Heiko Stübner
@ 2014-01-28 8:46 ` Manish Badarkhe
[not found] ` <CAKDJKT4jPLmtrm6Ngp+nT5vf0H4zXwwAM=oURDF-DSAJodVN6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Manish Badarkhe @ 2014-01-28 8:46 UTC (permalink / raw)
To: Heiko Stübner
Cc: Dmitry Torokhov, linux-omap, linux-samsung-soc@vger.kernel.org,
linux-tegra, linux-kernel@vger.kernel.org, Mark Brown,
Liam Girdwood
Hi Heiko
Thank you for your reply.
On Tue, Jan 28, 2014 at 1:08 PM, Heiko Stübner <heiko@sntech.de> wrote:
> On Tuesday, 28. January 2014 12:46:01 Manish Badarkhe wrote:
>> Hi Dmitry,
>>
>> Thank you for your review.
>>
>> On Tue, Jan 28, 2014 at 12:03 PM, Dmitry Torokhov
>>
>> <dmitry.torokhov@gmail.com> wrote:
>> > Hi Manish,
>> >
>> > On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
>> >> Update the code to use devm_* API so that driver core will manage
>> >> resources.
>> >>
>> >> Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
>> >> ---
>> >> Changes since V1:
>> >> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
>> >> 2. Updated commit message.
>> >>
>> >> Not tested on any board.
>> >>
>> >> :100644 100644 5ea64b9... e9763a4... M drivers/regulator/fixed.c
>> >> :
>> >> drivers/regulator/fixed.c | 42
>> >> ++++++++++++------------------------------
>> >> 1 file changed, 12 insertions(+), 30 deletions(-)
>> >>
>> >> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
>> >> index 5ea64b9..e9763a4 100644
>> >> --- a/drivers/regulator/fixed.c
>> >> +++ b/drivers/regulator/fixed.c
>> >> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct
>> >> platform_device *pdev)>>
>> >> GFP_KERNEL);
>> >>
>> >> if (drvdata == NULL) {
>> >>
>> >> dev_err(&pdev->dev, "Failed to allocate device data\n");
>> >>
>> >> - ret = -ENOMEM;
>> >> - goto err;
>> >> + return -ENOMEM;
>> >>
>> >> }
>> >>
>> >> - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
>> >> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
>> >> + strlen(config->supply_name) + 1,
>> >> + GFP_KERNEL);
>> >>
>> >> if (drvdata->desc.name == NULL) {
>> >>
>> >> dev_err(&pdev->dev, "Failed to allocate supply name\n");
>> >>
>> >> - ret = -ENOMEM;
>> >> - goto err;
>> >> + return -ENOMEM;
>> >>
>> >> }
>> >
>> > Umm, I am fairly certain that devm_kzalloc() can't be used as a
>> > substitute for kstrdup, at least not without accompanying memcpy.
>>
>> Yes, I have provided allocation but it should be followed with assignment.
>> Can I modify like this,
>>
>> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
>> + strlen(config->supply_name) + 1,
>> + GFP_KERNEL);
>> + if (drvdata->desc.name)
>> + sprintf(drvdata->desc.name, "%s", config->supply_name);
>
> hmm, so you replaced a general helper function by open coding the string-
> duplication. Doesn't this defeat the target of simplifying the code?
Intention here, is to use devm_ API and to adopt this I have to do these
modifications for "kstrdup" functions. I have seen in regulator folder almost
all drivers adopted to "devm_" API. Hence same thing I am following to
update this driver. Please let me know whether to go ahead with this patch
or retain driver as it is.
Regards
Manish Badarkhe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
[not found] ` <CAKDJKT4jPLmtrm6Ngp+nT5vf0H4zXwwAM=oURDF-DSAJodVN6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-01-28 8:55 ` Heiko Stübner
2014-01-28 9:01 ` Manish Badarkhe
0 siblings, 1 reply; 10+ messages in thread
From: Heiko Stübner @ 2014-01-28 8:55 UTC (permalink / raw)
To: Manish Badarkhe
Cc: Dmitry Torokhov, linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Mark Brown,
Liam Girdwood
On Tuesday, 28. January 2014 14:16:39 Manish Badarkhe wrote:
> Hi Heiko
>
> Thank you for your reply.
>
> On Tue, Jan 28, 2014 at 1:08 PM, Heiko Stübner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> wrote:
> > On Tuesday, 28. January 2014 12:46:01 Manish Badarkhe wrote:
> >> Hi Dmitry,
> >>
> >> Thank you for your review.
> >>
> >> On Tue, Jan 28, 2014 at 12:03 PM, Dmitry Torokhov
> >>
> >> <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >> > Hi Manish,
> >> >
> >> > On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
> >> >> Update the code to use devm_* API so that driver core will manage
> >> >> resources.
> >> >>
> >> >> Signed-off-by: Manish Badarkhe <badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >> >> ---
> >> >> Changes since V1:
> >> >> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
> >> >> 2. Updated commit message.
> >> >>
> >> >> Not tested on any board.
> >> >>
> >> >> :100644 100644 5ea64b9... e9763a4... M
> >> >> :drivers/regulator/fixed.c
> >> >> :
> >> >> drivers/regulator/fixed.c | 42
> >> >> ++++++++++++------------------------------
> >> >> 1 file changed, 12 insertions(+), 30 deletions(-)
> >> >>
> >> >> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> >> >> index 5ea64b9..e9763a4 100644
> >> >> --- a/drivers/regulator/fixed.c
> >> >> +++ b/drivers/regulator/fixed.c
> >> >> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct
> >> >> platform_device *pdev)>>
> >> >>
> >> >> GFP_KERNEL);
> >> >>
> >> >> if (drvdata == NULL) {
> >> >>
> >> >> dev_err(&pdev->dev, "Failed to allocate device data\n");
> >> >>
> >> >> - ret = -ENOMEM;
> >> >> - goto err;
> >> >> + return -ENOMEM;
> >> >>
> >> >> }
> >> >>
> >> >> - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
> >> >> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
> >> >> + strlen(config->supply_name) +
> >> >> 1,
> >> >> + GFP_KERNEL);
> >> >>
> >> >> if (drvdata->desc.name == NULL) {
> >> >>
> >> >> dev_err(&pdev->dev, "Failed to allocate supply name\n");
> >> >>
> >> >> - ret = -ENOMEM;
> >> >> - goto err;
> >> >> + return -ENOMEM;
> >> >>
> >> >> }
> >> >
> >> > Umm, I am fairly certain that devm_kzalloc() can't be used as a
> >> > substitute for kstrdup, at least not without accompanying memcpy.
> >>
> >> Yes, I have provided allocation but it should be followed with
> >> assignment.
> >> Can I modify like this,
> >>
> >> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
> >> + strlen(config->supply_name) + 1,
> >> + GFP_KERNEL);
> >> + if (drvdata->desc.name)
> >> + sprintf(drvdata->desc.name, "%s", config->supply_name);
> >
> > hmm, so you replaced a general helper function by open coding the string-
> > duplication. Doesn't this defeat the target of simplifying the code?
>
> Intention here, is to use devm_ API and to adopt this I have to do these
> modifications for "kstrdup" functions. I have seen in regulator folder
> almost all drivers adopted to "devm_" API. Hence same thing I am following
> to update this driver. Please let me know whether to go ahead with this
> patch or retain driver as it is.
I don't have a strong opinion on this and others are most likely more qualified
to have a definitive answer, I just found it strange to exchange one open-coded
pattern against another open-coded one.
So don't let me keep you from it ;-)
Heiko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
2014-01-28 8:55 ` Heiko Stübner
@ 2014-01-28 9:01 ` Manish Badarkhe
2014-01-28 10:45 ` Mark Brown
0 siblings, 1 reply; 10+ messages in thread
From: Manish Badarkhe @ 2014-01-28 9:01 UTC (permalink / raw)
To: Heiko Stübner
Cc: Dmitry Torokhov, linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Mark Brown,
Liam Girdwood
On Tue, Jan 28, 2014 at 2:25 PM, Heiko Stübner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> wrote:
> On Tuesday, 28. January 2014 14:16:39 Manish Badarkhe wrote:
>> Hi Heiko
>>
>> Thank you for your reply.
>>
>> On Tue, Jan 28, 2014 at 1:08 PM, Heiko Stübner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> wrote:
>> > On Tuesday, 28. January 2014 12:46:01 Manish Badarkhe wrote:
>> >> Hi Dmitry,
>> >>
>> >> Thank you for your review.
>> >>
>> >> On Tue, Jan 28, 2014 at 12:03 PM, Dmitry Torokhov
>> >>
>> >> <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> >> > Hi Manish,
>> >> >
>> >> > On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
>> >> >> Update the code to use devm_* API so that driver core will manage
>> >> >> resources.
>> >> >>
>> >> >> Signed-off-by: Manish Badarkhe <badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> >> >> ---
>> >> >> Changes since V1:
>> >> >> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
>> >> >> 2. Updated commit message.
>> >> >>
>> >> >> Not tested on any board.
>> >> >>
>> >> >> :100644 100644 5ea64b9... e9763a4... M
>> >> >> :drivers/regulator/fixed.c
>> >> >> :
>> >> >> drivers/regulator/fixed.c | 42
>> >> >> ++++++++++++------------------------------
>> >> >> 1 file changed, 12 insertions(+), 30 deletions(-)
>> >> >>
>> >> >> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
>> >> >> index 5ea64b9..e9763a4 100644
>> >> >> --- a/drivers/regulator/fixed.c
>> >> >> +++ b/drivers/regulator/fixed.c
>> >> >> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct
>> >> >> platform_device *pdev)>>
>> >> >>
>> >> >> GFP_KERNEL);
>> >> >>
>> >> >> if (drvdata == NULL) {
>> >> >>
>> >> >> dev_err(&pdev->dev, "Failed to allocate device data\n");
>> >> >>
>> >> >> - ret = -ENOMEM;
>> >> >> - goto err;
>> >> >> + return -ENOMEM;
>> >> >>
>> >> >> }
>> >> >>
>> >> >> - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
>> >> >> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
>> >> >> + strlen(config->supply_name) +
>> >> >> 1,
>> >> >> + GFP_KERNEL);
>> >> >>
>> >> >> if (drvdata->desc.name == NULL) {
>> >> >>
>> >> >> dev_err(&pdev->dev, "Failed to allocate supply name\n");
>> >> >>
>> >> >> - ret = -ENOMEM;
>> >> >> - goto err;
>> >> >> + return -ENOMEM;
>> >> >>
>> >> >> }
>> >> >
>> >> > Umm, I am fairly certain that devm_kzalloc() can't be used as a
>> >> > substitute for kstrdup, at least not without accompanying memcpy.
>> >>
>> >> Yes, I have provided allocation but it should be followed with
>> >> assignment.
>> >> Can I modify like this,
>> >>
>> >> + drvdata->desc.name = devm_kzalloc(&pdev->dev,
>> >> + strlen(config->supply_name) + 1,
>> >> + GFP_KERNEL);
>> >> + if (drvdata->desc.name)
>> >> + sprintf(drvdata->desc.name, "%s", config->supply_name);
>> >
>> > hmm, so you replaced a general helper function by open coding the string-
>> > duplication. Doesn't this defeat the target of simplifying the code?
>>
>> Intention here, is to use devm_ API and to adopt this I have to do these
>> modifications for "kstrdup" functions. I have seen in regulator folder
>> almost all drivers adopted to "devm_" API. Hence same thing I am following
>> to update this driver. Please let me know whether to go ahead with this
>> patch or retain driver as it is.
>
> I don't have a strong opinion on this and others are most likely more qualified
> to have a definitive answer, I just found it strange to exchange one open-coded
> pattern against another open-coded one.
>
> So don't let me keep you from it ;-)
Okay.
@Mark, Dmitry: Please let me know your opinion on this.
Thanks
Manish Badarkhe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
2014-01-28 9:01 ` Manish Badarkhe
@ 2014-01-28 10:45 ` Mark Brown
0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2014-01-28 10:45 UTC (permalink / raw)
To: Manish Badarkhe
Cc: Heiko Stübner, Dmitry Torokhov, linux-omap,
linux-samsung-soc@vger.kernel.org, linux-tegra,
linux-kernel@vger.kernel.org, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 537 bytes --]
On Tue, Jan 28, 2014 at 02:31:32PM +0530, Manish Badarkhe wrote:
> On Tue, Jan 28, 2014 at 2:25 PM, Heiko Stübner <heiko@sntech.de> wrote:
> > I don't have a strong opinion on this and others are most likely more qualified
> > to have a definitive answer, I just found it strange to exchange one open-coded
> > pattern against another open-coded one.
> >
> > So don't let me keep you from it ;-)
> Okay.
> @Mark, Dmitry: Please let me know your opinion on this.
How about implementing devm_kstrdup() and then using that?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
[not found] ` <1390878720-8676-1-git-send-email-badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-28 6:33 ` Dmitry Torokhov
@ 2014-01-28 16:41 ` Stephen Warren
2014-01-28 17:06 ` Manish Badarkhe
1 sibling, 1 reply; 10+ messages in thread
From: Stephen Warren @ 2014-01-28 16:41 UTC (permalink / raw)
To: Manish Badarkhe, linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w
On 01/27/2014 08:12 PM, Manish Badarkhe wrote:
> Update the code to use devm_* API so that driver core will manage
> resources.
I'm not sure why this patch is sent to linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; it
seems nothing to do with Tegra (or Samsung or OMAP for that matter).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] regulator: fixed: update to devm_* API
2014-01-28 16:41 ` Stephen Warren
@ 2014-01-28 17:06 ` Manish Badarkhe
0 siblings, 0 replies; 10+ messages in thread
From: Manish Badarkhe @ 2014-01-28 17:06 UTC (permalink / raw)
To: Stephen Warren
Cc: linux-omap, linux-samsung-soc@vger.kernel.org, linux-tegra,
linux-kernel@vger.kernel.org, Mark Brown, Liam Girdwood
Hi Stephan,
On Tue, Jan 28, 2014 at 10:11 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 01/27/2014 08:12 PM, Manish Badarkhe wrote:
>> Update the code to use devm_* API so that driver core will manage
>> resources.
>
> I'm not sure why this patch is sent to linux-tegra@vger.kernel.org; it
> seems nothing to do with Tegra (or Samsung or OMAP for that matter).
Sorry, for the noise. I sent it to have review comments from community.
Regards
Manish Badarkhe
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-01-28 17:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-28 3:12 [PATCH V2] regulator: fixed: update to devm_* API Manish Badarkhe
[not found] ` <1390878720-8676-1-git-send-email-badarkhe.manish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-28 6:33 ` Dmitry Torokhov
2014-01-28 7:16 ` Manish Badarkhe
2014-01-28 7:38 ` Heiko Stübner
2014-01-28 8:46 ` Manish Badarkhe
[not found] ` <CAKDJKT4jPLmtrm6Ngp+nT5vf0H4zXwwAM=oURDF-DSAJodVN6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-28 8:55 ` Heiko Stübner
2014-01-28 9:01 ` Manish Badarkhe
2014-01-28 10:45 ` Mark Brown
2014-01-28 16:41 ` Stephen Warren
2014-01-28 17:06 ` Manish Badarkhe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox