Skip to content

Commit

Permalink
regulator: lp8755: Fix lp8755_regulator_init unwind code
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Jan 8, 2013
1 parent b59320c commit a1a41ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/regulator/lp8755.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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,
};

Expand Down

0 comments on commit a1a41ab

Please sign in to comment.