diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-03-14 18:15:06 +0000 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-04-07 08:36:36 +0100 |
commit | a9f8afe16412bc388a81269387d28c7319cb2c9e (patch) | |
tree | a95acdf6a2c59abc732dd5ac989c666f0d75623d /drivers/staging/iio | |
parent | 18595e71c57a60dcc041fe6a280b05417bc38d54 (diff) |
staging:iio:cdc:ad7150: Really basic regulator support.
Given DT docs will include regulators, lets just turn them on and
off with driver probe() and remove().
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210314181511.531414-20-jic23@kernel.org
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r-- | drivers/staging/iio/cdc/ad7150.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index c7d242f8da52..e27ed845879a 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -12,6 +12,7 @@ #include <linux/i2c.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/iio/iio.h> @@ -533,11 +534,19 @@ static const struct iio_info ad7150_info_no_irq = { .read_raw = &ad7150_read_raw, }; +static void ad7150_reg_disable(void *data) +{ + struct regulator *reg = data; + + regulator_disable(reg); +} + static int ad7150_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ad7150_chip_info *chip; struct iio_dev *indio_dev; + struct regulator *reg; int ret; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); @@ -552,6 +561,18 @@ static int ad7150_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; + reg = devm_regulator_get(&client->dev, "vdd"); + if (IS_ERR(reg)) + return PTR_ERR(reg); + + ret = regulator_enable(reg); + if (ret) + return ret; + + ret = devm_add_action_or_reset(&client->dev, ad7150_reg_disable, reg); + if (ret) + return ret; + chip->interrupts[0] = fwnode_irq_get(dev_fwnode(&client->dev), 0); if (chip->interrupts[0] < 0) return chip->interrupts[0]; |