Skip to content

Commit

Permalink
regulator: pfuze100: use devm_regulator_register()
Browse files Browse the repository at this point in the history
Use devm_regulator_register() to make cleanup paths simpler,
and remove unnecessary remove().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Robin Gong <b38343@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Jingoo Han authored and Mark Brown committed Dec 9, 2013
1 parent 6ce4eac commit f5247b4
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions drivers/regulator/pfuze100-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,31 +402,18 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
config.driver_data = pfuze_chip;
config.of_node = match_of_node(i);

pfuze_chip->regulators[i] = regulator_register(desc, &config);
pfuze_chip->regulators[i] =
devm_regulator_register(&client->dev, desc, &config);
if (IS_ERR(pfuze_chip->regulators[i])) {
dev_err(&client->dev, "register regulator%s failed\n",
pfuze100_regulators[i].desc.name);
ret = PTR_ERR(pfuze_chip->regulators[i]);
while (--i >= 0)
regulator_unregister(pfuze_chip->regulators[i]);
return ret;
return PTR_ERR(pfuze_chip->regulators[i]);
}
}

return 0;
}

static int pfuze100_regulator_remove(struct i2c_client *client)
{
int i;
struct pfuze_chip *pfuze_chip = i2c_get_clientdata(client);

for (i = 0; i < PFUZE100_MAX_REGULATOR; i++)
regulator_unregister(pfuze_chip->regulators[i]);

return 0;
}

static struct i2c_driver pfuze_driver = {
.id_table = pfuze_device_id,
.driver = {
Expand All @@ -435,7 +422,6 @@ static struct i2c_driver pfuze_driver = {
.of_match_table = pfuze_dt_ids,
},
.probe = pfuze100_regulator_probe,
.remove = pfuze100_regulator_remove,
};
module_i2c_driver(pfuze_driver);

Expand Down

0 comments on commit f5247b4

Please sign in to comment.