Re: [PATCH v3 4/6] iio: light: vcnl4000: add support for regulators

Jonathan Cameron
2026-03-15T18:28:09Z

On Sat, 14 Mar 2026 18:06:33 +0200
Erikas Bitovtas <xerikasxx@gmail.com> wrote:

> Add supply, I2C and cathode voltage regulators to the sensor and enable
> them. This keeps the sensor powered on even after its only supply shared
> by another device shuts down.
>
> Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
> Reported-by: Raymond Hackley <raymondhackley@protonmail.com>

Mixing new features and cleanup through the series isn't ideal.
Can we move this one to the end? So do all the cleanup first
then add this new handling?

Thanks,

Jonathan

> ---
> drivers/iio/light/vcnl4000.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 0ee307fc5ab7..e501db7249d7 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -24,6 +24,7 @@
> #include <linux/interrupt.h>
> #include <linux/module.h>
> #include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/units.h>
>
> #include <linux/iio/buffer.h>
> @@ -1991,6 +1992,7 @@ static int vcnl4010_probe_trigger(struct iio_dev *indio_dev)
> static int vcnl4000_probe(struct i2c_client *client)
> {
> const struct i2c_device_id *id = i2c_client_get_device_id(client);
> + const char * const regulator_names[] = { "vdd", "vddio", "vled" };
> struct vcnl4000_data *data;
> struct iio_dev *indio_dev;
> struct device *dev = &client->dev;
> @@ -2006,6 +2008,12 @@ static int vcnl4000_probe(struct i2c_client *client)
> data->id = id->driver_data;
> data->chip_spec = &vcnl4000_chip_spec_cfg[data->id];
>
> + ret = devm_regulator_bulk_get_enable(dev,
> + ARRAY_SIZE(regulator_names),
> + regulator_names);
> + if (ret < 0)
> + return ret;
> +
> ret = devm_mutex_init(dev, &data->vcnl4000_lock);
> if (ret < 0)
> return ret;
>