Skip to contentSkip to conversation

regulator: lp8755: Fix lp8755_regulator_init unwind code

PATCH In review Axel Lin 2 participants 2 messages Dec 25, 2012 – Dec 26, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: lp8755: Fix lp8755_regulator_init unwind code

It's safe to pass NULL argument to regulator_unregister(), so we can remove the NULL checking before calling regulator_unregister(). However pass a ERR_PTR to regulator_unregister() is wrong, so we need to explicitly set "pchip->rdev[buck_num] = NULL" before goto err_buck.

This patch also includes below cleanups:
Show correct regulator id in dev_err.
Remove __devexit_p.

---
 drivers/regulator/lp8755.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/regulator/lp8755.c +5 -4
index dbc4d12..06a82e2 100644
@@ -358,7 +358,9 @@ static int lp8755_regulator_init(struct lp8755_chip *pchip)
 		    regulator_register(&lp8755_regulators[buck_num], &rconfig);
 		if (IS_ERR(pchip->rdev[buck_num])) {
 			ret = PTR_ERR(pchip->rdev[buck_num]);
-			dev_err(pchip->dev, "regulator init failed: buck 0\n");
+			pchip->rdev[buck_num] = NULL;
+			dev_err(pchip->dev, "regulator init failed: buck %d\n",
+				buck_num);
 			goto err_buck;
 		}
 	}
@@ -367,8 +369,7 @@ static int lp8755_regulator_init(struct lp8755_chip *pchip)
 
 err_buck:
 	for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
-		if (pchip->rdev[icnt] != NULL)
-			regulator_unregister(pchip->rdev[icnt]);
+		regulator_unregister(pchip->rdev[icnt]);
 	return ret;
 }
 
@@ -557,7 +558,7 @@ static struct i2c_driver lp8755_i2c_driver = {
 		   .name = LP8755_NAME,
 		   },
 	.probe = lp8755_probe,
-	.remove = __devexit_p(lp8755_remove),
+	.remove = lp8755_remove,
 	.id_table = lp8755_id,
 };
 
Signature · 1 line
1.7.9.5
#1 lore raw

2012년 12월 25일 11:06, Axel Lin 쓴 글:

Quoted 35 lines

This patch also includes below cleanups:
Show correct regulator id in dev_err.
Remove __devexit_p.

---
  drivers/regulator/lp8755.c |    9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/regulator/lp8755.c +4 -3
index dbc4d12..06a82e2 100644
@@ -358,7 +358,9 @@ static int lp8755_regulator_init(struct lp8755_chip *pchip)
  		    regulator_register(&lp8755_regulators[buck_num], &rconfig);
  		if (IS_ERR(pchip->rdev[buck_num])) {
  			ret = PTR_ERR(pchip->rdev[buck_num]);
-			dev_err(pchip->dev, "regulator init failed: buck 0\n");
+			pchip->rdev[buck_num] = NULL;
+			dev_err(pchip->dev, "regulator init failed: buck %d\n",
+				buck_num);
  			goto err_buck;
  		}
  	}
@@ -367,8 +369,7 @@ static int lp8755_regulator_init(struct lp8755_chip *pchip)
 
  err_buck:
  	for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
-		if (pchip->rdev[icnt] != NULL)
-			regulator_unregister(pchip->rdev[icnt]);
+		regulator_unregister(pchip->rdev[icnt]);
  	return ret;
  }
 

drivers/regulator/lp8755.c static struct i2c_driver lp8755_i2c_driver = {

Quoted 9 lines
drivers/regulator/lp8755.c +1 -2
@@ -557,7 +558,7 @@ static struct i2c_driver lp8755_i2c_driver = {
  		   .name = LP8755_NAME,
  		   },
  	.probe = lp8755_probe,
-	.remove = __devexit_p(lp8755_remove),
+	.remove = lp8755_remove,
  	.id_table = lp8755_id,
  };
 
-- 1.7.9.5

Thank you Alex.
I will check your patch and test it using my board.