regulator: lp872x: use devm_regulator_register()
Use devm_regulator_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
e97bba912e
commit
ed602534df
1 changed files with 3 additions and 30 deletions
|
@ -785,7 +785,7 @@ static int lp872x_regulator_register(struct lp872x *lp)
|
||||||
struct regulator_desc *desc;
|
struct regulator_desc *desc;
|
||||||
struct regulator_config cfg = { };
|
struct regulator_config cfg = { };
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
int i, ret;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < lp->num_regulators; i++) {
|
for (i = 0; i < lp->num_regulators; i++) {
|
||||||
desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] :
|
desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] :
|
||||||
|
@ -796,34 +796,16 @@ static int lp872x_regulator_register(struct lp872x *lp)
|
||||||
cfg.driver_data = lp;
|
cfg.driver_data = lp;
|
||||||
cfg.regmap = lp->regmap;
|
cfg.regmap = lp->regmap;
|
||||||
|
|
||||||
rdev = regulator_register(desc, &cfg);
|
rdev = devm_regulator_register(lp->dev, desc, &cfg);
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
dev_err(lp->dev, "regulator register err");
|
dev_err(lp->dev, "regulator register err");
|
||||||
ret = PTR_ERR(rdev);
|
return PTR_ERR(rdev);
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*(lp->regulators + i) = rdev;
|
*(lp->regulators + i) = rdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
|
||||||
while (--i >= 0) {
|
|
||||||
rdev = *(lp->regulators + i);
|
|
||||||
regulator_unregister(rdev);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lp872x_regulator_unregister(struct lp872x *lp)
|
|
||||||
{
|
|
||||||
struct regulator_dev *rdev;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < lp->num_regulators; i++) {
|
|
||||||
rdev = *(lp->regulators + i);
|
|
||||||
regulator_unregister(rdev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct regmap_config lp872x_regmap_config = {
|
static const struct regmap_config lp872x_regmap_config = {
|
||||||
|
@ -979,14 +961,6 @@ err_dev:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lp872x_remove(struct i2c_client *cl)
|
|
||||||
{
|
|
||||||
struct lp872x *lp = i2c_get_clientdata(cl);
|
|
||||||
|
|
||||||
lp872x_regulator_unregister(lp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct of_device_id lp872x_dt_ids[] = {
|
static const struct of_device_id lp872x_dt_ids[] = {
|
||||||
{ .compatible = "ti,lp8720", },
|
{ .compatible = "ti,lp8720", },
|
||||||
{ .compatible = "ti,lp8725", },
|
{ .compatible = "ti,lp8725", },
|
||||||
|
@ -1008,7 +982,6 @@ static struct i2c_driver lp872x_driver = {
|
||||||
.of_match_table = of_match_ptr(lp872x_dt_ids),
|
.of_match_table = of_match_ptr(lp872x_dt_ids),
|
||||||
},
|
},
|
||||||
.probe = lp872x_probe,
|
.probe = lp872x_probe,
|
||||||
.remove = lp872x_remove,
|
|
||||||
.id_table = lp872x_ids,
|
.id_table = lp872x_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue