Commit 563746c2 authored by Matti Vaittinen's avatar Matti Vaittinen Committed by Jonathan Cameron
Browse files

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: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Acked-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/8b1193fdefb231a6d721e2bded52c48e56039c20.1660934107.git.mazziesaccount@gmail.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 3dfa1d4f
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ struct hmc425a_chip_info {
};

struct hmc425a_state {
	struct	regulator *reg;
	struct	mutex lock; /* protect sensor state */
	struct	hmc425a_chip_info *chip_info;
	struct	gpio_descs *gpios;
@@ -162,13 +161,6 @@ static const struct of_device_id 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[] = {
	[ID_HMC425A] = {
		.name = "hmc425a",
@@ -211,14 +203,7 @@ static int hmc425a_probe(struct platform_device *pdev)
		return -ENODEV;
	}

	st->reg = devm_regulator_get(&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);
	ret = devm_regulator_get_enable(&pdev->dev, "vcc-supply");
	if (ret)
		return ret;