regulator: anatop-regulator: Only jump to 'anatop_probe_end' on error
PATCH v2 1/2 regulator: anatop-regulator: Only jump to 'anatop_probe_end' on error
From: Fabio Estevam <[email protected]>
Currently 'anatop_probe_end' path is executed on both succesfull and error paths of anatop_regulator_probe().
To let the code a bit clearer, make 'anatop_probe_end' to be executed only when an error happens.
--- drivers/regulator/anatop-regulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/regulator/anatop-regulator.c +3 -2
@@ -210,9 +210,10 @@ static int anatop_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); +return 0 ; + anatop_probe_end: -if (ret) -kfree (sreg->name); +kfree (sreg->name);return ret; }
Signature · 1 line
1.8.1.2
PATCH v2 2/2 regulator: anatop-regulator: Remove unneeded variable
From: Fabio Estevam <[email protected]>
There is no need to create a local variable for accessing sreg->name.
Access it directly instead.
---
Changes since v1:
- None
drivers/regulator/anatop-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/anatop-regulator.c +1 -2
@@ -222,9 +222,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 ; }
Signature · 1 line
1.8.1.2
Quoted 18 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Currently '
anatop_probe_end' path is executed on both succesfull and error paths ofanatop_regulator_probe().To let the code a bit clearer, make '
anatop_probe_end' to be executed only when an error happens.Signed-off-by Fabio Estevam <[email protected]>--- drivers/regulator/anatop-regulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/regulator/anatop-regulator.c +0
-0
drivers/regulator/anatop-regulator.c static int anatop_regulator_probe(struct platform_device *pdev) · line 216
Quoted 9 lines
drivers/regulator/anatop-regulator.c +3
-2@@ -210,9 +210,10 @@ static int anatop_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); +return 0 ; + anatop_probe_end: -if (ret) -kfree (sreg->name); +kfree (sreg->name);
While you're there, you may wan to fix the return check of of_get_parent() in anatop_regulator_probe() as well.
Shawn
Quoted 6 lines
drivers/regulator/anatop-regulator.c +0
-0return ret; }Signature · 1 line
1.8.1.2