mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-16 07:35:14 +00:00
iio: accel: adxl367: Use devm_regulator_bulk_get_enable()
This driver only turns the power on at probe and off via a custom devm_add_action_or_reset() callback. The new devm_regulator_bulk_get_enable() replaces this boilerplate code. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Cosmin Tanislav <cosmin.tanislav@analog.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20221016163409.320197-2-jic23@kernel.org
This commit is contained in:
parent
e54ec96c72
commit
e9b96e18cf
1 changed files with 4 additions and 24 deletions
|
@ -160,8 +160,6 @@ struct adxl367_state {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
|
||||||
struct regulator_bulk_data regulators[2];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Synchronize access to members of driver state, and ensure atomicity
|
* Synchronize access to members of driver state, and ensure atomicity
|
||||||
* of consecutive regmap operations.
|
* of consecutive regmap operations.
|
||||||
|
@ -1487,16 +1485,10 @@ static int adxl367_setup(struct adxl367_state *st)
|
||||||
return adxl367_set_measure_en(st, true);
|
return adxl367_set_measure_en(st, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void adxl367_disable_regulators(void *data)
|
|
||||||
{
|
|
||||||
struct adxl367_state *st = data;
|
|
||||||
|
|
||||||
regulator_bulk_disable(ARRAY_SIZE(st->regulators), st->regulators);
|
|
||||||
}
|
|
||||||
|
|
||||||
int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
|
int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
|
||||||
void *context, struct regmap *regmap, int irq)
|
void *context, struct regmap *regmap, int irq)
|
||||||
{
|
{
|
||||||
|
static const char * const regulator_names[] = { "vdd", "vddio" };
|
||||||
struct iio_dev *indio_dev;
|
struct iio_dev *indio_dev;
|
||||||
struct adxl367_state *st;
|
struct adxl367_state *st;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1520,25 +1512,13 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
|
||||||
indio_dev->info = &adxl367_info;
|
indio_dev->info = &adxl367_info;
|
||||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||||
|
|
||||||
st->regulators[0].supply = "vdd";
|
ret = devm_regulator_bulk_get_enable(st->dev,
|
||||||
st->regulators[1].supply = "vddio";
|
ARRAY_SIZE(regulator_names),
|
||||||
|
regulator_names);
|
||||||
ret = devm_regulator_bulk_get(st->dev, ARRAY_SIZE(st->regulators),
|
|
||||||
st->regulators);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return dev_err_probe(st->dev, ret,
|
return dev_err_probe(st->dev, ret,
|
||||||
"Failed to get regulators\n");
|
"Failed to get regulators\n");
|
||||||
|
|
||||||
ret = regulator_bulk_enable(ARRAY_SIZE(st->regulators), st->regulators);
|
|
||||||
if (ret)
|
|
||||||
return dev_err_probe(st->dev, ret,
|
|
||||||
"Failed to enable regulators\n");
|
|
||||||
|
|
||||||
ret = devm_add_action_or_reset(st->dev, adxl367_disable_regulators, st);
|
|
||||||
if (ret)
|
|
||||||
return dev_err_probe(st->dev, ret,
|
|
||||||
"Failed to add regulators disable action\n");
|
|
||||||
|
|
||||||
ret = regmap_write(st->regmap, ADXL367_REG_RESET, ADXL367_RESET_CODE);
|
ret = regmap_write(st->regmap, ADXL367_REG_RESET, ADXL367_RESET_CODE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue