linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check
@ 2013-12-20 13:42 Fabio Estevam
  2013-12-20 13:42 ` [PATCH 2/2] regulator: anatop-regulator: Remove unneeded variable Fabio Estevam
  2013-12-21  7:49 ` [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Shawn Guo
  0 siblings, 2 replies; 5+ messages in thread
From: Fabio Estevam @ 2013-12-20 13:42 UTC (permalink / raw)
  To: broonie; +Cc: shawn.guo, b20788, linux-kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

At the 'anatop_probe_end' error path, the variable 'ret' is known to be
non-zero, so there is no need to check it.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/regulator/anatop-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index c734d09..0a3597b 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -211,8 +211,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, rdev);
 
 anatop_probe_end:
-	if (ret)
-		kfree(sreg->name);
+	kfree(sreg->name);
 
 	return ret;
 }
-- 
1.8.1.2


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

* [PATCH 2/2] regulator: anatop-regulator: Remove unneeded variable
  2013-12-20 13:42 [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Fabio Estevam
@ 2013-12-20 13:42 ` Fabio Estevam
  2013-12-21  7:49 ` [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Shawn Guo
  1 sibling, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2013-12-20 13:42 UTC (permalink / raw)
  To: broonie; +Cc: shawn.guo, b20788, linux-kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

There is no need to create a local variable for accessing sreg->name.

Access it directly instead.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/regulator/anatop-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 0a3597b..7d7c05e 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -220,9 +220,8 @@ static int anatop_regulator_remove(struct platform_device *pdev)
 {
 	struct regulator_dev *rdev = platform_get_drvdata(pdev);
 	struct anatop_regulator *sreg = rdev_get_drvdata(rdev);
-	const char *name = sreg->name;
 
-	kfree(name);
+	kfree(sreg->name);
 
 	return 0;
 }
-- 
1.8.1.2


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

* Re: [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check
  2013-12-20 13:42 [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Fabio Estevam
  2013-12-20 13:42 ` [PATCH 2/2] regulator: anatop-regulator: Remove unneeded variable Fabio Estevam
@ 2013-12-21  7:49 ` Shawn Guo
  2013-12-21 14:25   ` Fabio Estevam
  1 sibling, 1 reply; 5+ messages in thread
From: Shawn Guo @ 2013-12-21  7:49 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: broonie, b20788, linux-kernel, Fabio Estevam

On Fri, Dec 20, 2013 at 11:42:09AM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> At the 'anatop_probe_end' error path, the variable 'ret' is known to be
> non-zero, so there is no need to check it.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/regulator/anatop-regulator.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
> index c734d09..0a3597b 100644
> --- a/drivers/regulator/anatop-regulator.c
> +++ b/drivers/regulator/anatop-regulator.c
> @@ -211,8 +211,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, rdev);
>  
>  anatop_probe_end:
> -	if (ret)
> -		kfree(sreg->name);
> +	kfree(sreg->name);

NAK

With the change, a successful probe will end up with calling this
kfree() as well.

Shawn

>  
>  	return ret;
>  }
> -- 
> 1.8.1.2
> 

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

* Re: [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check
  2013-12-21  7:49 ` [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Shawn Guo
@ 2013-12-21 14:25   ` Fabio Estevam
  2013-12-21 15:54     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2013-12-21 14:25 UTC (permalink / raw)
  To: Shawn Guo; +Cc: Mark Brown, Anson Huang, linux-kernel, Fabio Estevam

On Sat, Dec 21, 2013 at 5:49 AM, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Fri, Dec 20, 2013 at 11:42:09AM -0200, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> At the 'anatop_probe_end' error path, the variable 'ret' is known to be
>> non-zero, so there is no need to check it.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>> ---
>>  drivers/regulator/anatop-regulator.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
>> index c734d09..0a3597b 100644
>> --- a/drivers/regulator/anatop-regulator.c
>> +++ b/drivers/regulator/anatop-regulator.c
>> @@ -211,8 +211,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
>>       platform_set_drvdata(pdev, rdev);
>>
>>  anatop_probe_end:
>> -     if (ret)
>> -             kfree(sreg->name);
>> +     kfree(sreg->name);
>
> NAK
>
> With the change, a successful probe will end up with calling this
> kfree() as well.

I see. Then we can do this instead, so that the successful probe and
the error path are clearer:

--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -210,9 +210,10 @@ static int anatop_regulator_probe(struct platform_device *p

        platform_set_drvdata(pdev, rdev);

+       return 0;
+
 anatop_probe_end:
-       if (ret)
-               kfree(sreg->name);
+       kfree(sreg->name);

        return ret;
 }


Regards,

Fabio Estevam

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

* Re: [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check
  2013-12-21 14:25   ` Fabio Estevam
@ 2013-12-21 15:54     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-12-21 15:54 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Shawn Guo, Anson Huang, linux-kernel, Fabio Estevam

On Sat, Dec 21, 2013 at 12:25:50PM -0200, Fabio Estevam wrote:

> I see. Then we can do this instead, so that the successful probe and
> the error path are clearer:

Yes, that's going to cause fewer surprises.

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

end of thread, other threads:[~2013-12-21 15:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-20 13:42 [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Fabio Estevam
2013-12-20 13:42 ` [PATCH 2/2] regulator: anatop-regulator: Remove unneeded variable Fabio Estevam
2013-12-21  7:49 ` [PATCH 1/2] regulator: anatop-regulator: Remove unneeded check Shawn Guo
2013-12-21 14:25   ` Fabio Estevam
2013-12-21 15:54     ` Mark Brown

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).