Skip to contentSkip to conversation

regulator: anatop-regulator: Only jump to 'anatop_probe_end' on error

PATCH In review Fabio Estevam 2 participants 3 messages Dec 21, 2013 – Dec 23, 2013 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

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
index c734d09..53e6048 100644
@@ -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
#1 lore raw

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
index 53e6048..8fee74d 100644
@@ -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
#2 lore raw
In reply to Fabio Estevam
Quoted 18 lines · Fabio Estevam

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 +0 -0
index c734d09..53e6048 100644

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 -0
 	return ret;
 }
Signature · 1 line
1.8.1.2