iio: gyro: bmg160_core: Simplify using devm_regulator_*get_enable()

Use devm_regulator_bulk_get_enable() instead of open coded bulk-get,
bulk-enable, add-action-to-disable-at-detach - pattern.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/3fd11489356b1c73a3d7b4bd9dec7e12c9fe8788.1660934107.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Matti Vaittinen 2022-08-19 22:19:31 +03:00 committed by Jonathan Cameron
parent 08f75f180d
commit 2c620883a4
1 changed files with 3 additions and 21 deletions

View File

@ -93,7 +93,6 @@
struct bmg160_data { struct bmg160_data {
struct regmap *regmap; struct regmap *regmap;
struct regulator_bulk_data regulators[2];
struct iio_trigger *dready_trig; struct iio_trigger *dready_trig;
struct iio_trigger *motion_trig; struct iio_trigger *motion_trig;
struct iio_mount_matrix orientation; struct iio_mount_matrix orientation;
@ -1067,16 +1066,10 @@ static const char *bmg160_match_acpi_device(struct device *dev)
return dev_name(dev); return dev_name(dev);
} }
static void bmg160_disable_regulators(void *d)
{
struct bmg160_data *data = d;
regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
}
int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
const char *name) const char *name)
{ {
static const char * const regulators[] = { "vdd", "vddio" };
struct bmg160_data *data; struct bmg160_data *data;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
int ret; int ret;
@ -1090,22 +1083,11 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
data->irq = irq; data->irq = irq;
data->regmap = regmap; data->regmap = regmap;
data->regulators[0].supply = "vdd"; ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators),
data->regulators[1].supply = "vddio"; regulators);
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
data->regulators);
if (ret) if (ret)
return dev_err_probe(dev, ret, "Failed to get regulators\n"); return dev_err_probe(dev, ret, "Failed to get regulators\n");
ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
data->regulators);
if (ret)
return ret;
ret = devm_add_action_or_reset(dev, bmg160_disable_regulators, data);
if (ret)
return ret;
ret = iio_read_mount_matrix(dev, &data->orientation); ret = iio_read_mount_matrix(dev, &data->orientation);
if (ret) if (ret)
return ret; return ret;