forked from Minki/linux
regulator: isl6271a-regulator: Use devm_regulator_register
devm_* simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Marek Vasut <marex@denx.de> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
be1221e893
commit
0ab6e8ca54
@ -112,7 +112,7 @@ static int isl6271a_probe(struct i2c_client *i2c,
|
||||
struct regulator_config config = { };
|
||||
struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev);
|
||||
struct isl_pmic *pmic;
|
||||
int err, i;
|
||||
int i;
|
||||
|
||||
if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return -EIO;
|
||||
@ -133,32 +133,17 @@ static int isl6271a_probe(struct i2c_client *i2c,
|
||||
config.init_data = NULL;
|
||||
config.driver_data = pmic;
|
||||
|
||||
pmic->rdev[i] = regulator_register(&isl_rd[i], &config);
|
||||
pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i],
|
||||
&config);
|
||||
if (IS_ERR(pmic->rdev[i])) {
|
||||
dev_err(&i2c->dev, "failed to register %s\n", id->name);
|
||||
err = PTR_ERR(pmic->rdev[i]);
|
||||
goto error;
|
||||
return PTR_ERR(pmic->rdev[i]);
|
||||
}
|
||||
}
|
||||
|
||||
i2c_set_clientdata(i2c, pmic);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
while (--i >= 0)
|
||||
regulator_unregister(pmic->rdev[i]);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int isl6271a_remove(struct i2c_client *i2c)
|
||||
{
|
||||
struct isl_pmic *pmic = i2c_get_clientdata(i2c);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
regulator_unregister(pmic->rdev[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id isl6271a_id[] = {
|
||||
@ -174,7 +159,6 @@ static struct i2c_driver isl6271a_i2c_driver = {
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = isl6271a_probe,
|
||||
.remove = isl6271a_remove,
|
||||
.id_table = isl6271a_id,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user