regulator: mc13892: 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:
Sachin Kamat 2013-09-04 12:01:00 +05:30 committed by Mark Brown
parent 8e568635af
commit 8c0b4ab502

View file

@ -611,43 +611,27 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
config.driver_data = priv; config.driver_data = priv;
config.of_node = node; config.of_node = node;
priv->regulators[i] = regulator_register(desc, &config); priv->regulators[i] = devm_regulator_register(&pdev->dev, desc,
&config);
if (IS_ERR(priv->regulators[i])) { if (IS_ERR(priv->regulators[i])) {
dev_err(&pdev->dev, "failed to register regulator %s\n", dev_err(&pdev->dev, "failed to register regulator %s\n",
mc13892_regulators[i].desc.name); mc13892_regulators[i].desc.name);
ret = PTR_ERR(priv->regulators[i]); return PTR_ERR(priv->regulators[i]);
goto err;
} }
} }
return 0; return 0;
err:
while (--i >= 0)
regulator_unregister(priv->regulators[i]);
return ret;
err_unlock: err_unlock:
mc13xxx_unlock(mc13892); mc13xxx_unlock(mc13892);
return ret; return ret;
} }
static int mc13892_regulator_remove(struct platform_device *pdev)
{
struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
int i;
for (i = 0; i < priv->num_regulators; i++)
regulator_unregister(priv->regulators[i]);
return 0;
}
static struct platform_driver mc13892_regulator_driver = { static struct platform_driver mc13892_regulator_driver = {
.driver = { .driver = {
.name = "mc13892-regulator", .name = "mc13892-regulator",
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.remove = mc13892_regulator_remove,
.probe = mc13892_regulator_probe, .probe = mc13892_regulator_probe,
}; };