mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-19 20:12:32 +00:00
iio: amplifier: hmc425a: simplify using devm_regulator_get_enable()
Drop open-coded pattern: 'devm_regulator_get(), regulator_enable(), add_action_or_reset(regulator_disable)' and use the devm_regulator_get_enable() and drop the pointer to the regulator. This simplifies code and makes it less tempting to add manual control for the regulator which is also controlled by devm. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/8b1193fdefb231a6d721e2bded52c48e56039c20.1660934107.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
3dfa1d4f63
commit
563746c26d
@ -34,7 +34,6 @@ struct hmc425a_chip_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct hmc425a_state {
|
struct hmc425a_state {
|
||||||
struct regulator *reg;
|
|
||||||
struct mutex lock; /* protect sensor state */
|
struct mutex lock; /* protect sensor state */
|
||||||
struct hmc425a_chip_info *chip_info;
|
struct hmc425a_chip_info *chip_info;
|
||||||
struct gpio_descs *gpios;
|
struct gpio_descs *gpios;
|
||||||
@ -162,13 +161,6 @@ static const struct of_device_id hmc425a_of_match[] = {
|
|||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, hmc425a_of_match);
|
MODULE_DEVICE_TABLE(of, hmc425a_of_match);
|
||||||
|
|
||||||
static void hmc425a_reg_disable(void *data)
|
|
||||||
{
|
|
||||||
struct hmc425a_state *st = data;
|
|
||||||
|
|
||||||
regulator_disable(st->reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct hmc425a_chip_info hmc425a_chip_info_tbl[] = {
|
static struct hmc425a_chip_info hmc425a_chip_info_tbl[] = {
|
||||||
[ID_HMC425A] = {
|
[ID_HMC425A] = {
|
||||||
.name = "hmc425a",
|
.name = "hmc425a",
|
||||||
@ -211,14 +203,7 @@ static int hmc425a_probe(struct platform_device *pdev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
st->reg = devm_regulator_get(&pdev->dev, "vcc-supply");
|
ret = devm_regulator_get_enable(&pdev->dev, "vcc-supply");
|
||||||
if (IS_ERR(st->reg))
|
|
||||||
return PTR_ERR(st->reg);
|
|
||||||
|
|
||||||
ret = regulator_enable(st->reg);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
ret = devm_add_action_or_reset(&pdev->dev, hmc425a_reg_disable, st);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user