regulator: max8660: Use devm_regulator_register

devm_* simplifies the code.

[Fixups from rebase onto v3.12 code -- broonie]
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Sachin Kamat 2013-09-04 11:07:58 +05:30 committed by Mark Brown
parent e453f92eec
commit dcfb6b56f1
1 changed files with 7 additions and 23 deletions

View File

@ -439,7 +439,7 @@ static int max8660_probe(struct i2c_client *client,
for (i = 0; i < pdata->num_subdevs; i++) {
if (!pdata->subdevs[i].platform_data)
goto err_out;
return ret;
boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
@ -465,7 +465,7 @@ static int max8660_probe(struct i2c_client *client,
case MAX8660_V7:
if (type == MAX8661) {
dev_err(dev, "Regulator not on this chip!\n");
goto err_out;
return -EINVAL;
}
if (boot_on)
@ -475,7 +475,7 @@ static int max8660_probe(struct i2c_client *client,
default:
dev_err(dev, "invalid regulator %s\n",
pdata->subdevs[i].name);
goto err_out;
return ret;
}
}
@ -489,33 +489,18 @@ static int max8660_probe(struct i2c_client *client,
config.of_node = of_node[i];
config.driver_data = max8660;
rdev[i] = regulator_register(&max8660_reg[id], &config);
rdev[i] = devm_regulator_register(&client->dev,
&max8660_reg[id], &config);
if (IS_ERR(rdev[i])) {
ret = PTR_ERR(rdev[i]);
dev_err(dev, "failed to register %s\n",
dev_err(&client->dev, "failed to register %s\n",
max8660_reg[id].name);
goto err_unregister;
return PTR_ERR(rdev[i]);
}
}
i2c_set_clientdata(client, max8660);
return 0;
err_unregister:
while (--i >= 0)
regulator_unregister(rdev[i]);
err_out:
return ret;
}
static int max8660_remove(struct i2c_client *client)
{
struct max8660 *max8660 = i2c_get_clientdata(client);
int i;
for (i = 0; i < MAX8660_V_END; i++)
regulator_unregister(max8660->rdev[i]);
return 0;
}
static const struct i2c_device_id max8660_id[] = {
@ -527,7 +512,6 @@ MODULE_DEVICE_TABLE(i2c, max8660_id);
static struct i2c_driver max8660_driver = {
.probe = max8660_probe,
.remove = max8660_remove,
.driver = {
.name = "max8660",
.owner = THIS_MODULE,