[PATCH 2/2] iio: light: vcnl4000: add regulator support

From: Erikas Bitovtas

Date: Wed Mar 11 2026 - 07:38:47 EST


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@xxxxxxxxx>
Reported-by: Raymond Hackley <raymondhackley@xxxxxxxxxxxxxx>
---
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 5e03c3d8874b..967589d5f246 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -17,6 +17,8 @@
* interrupts (VCNL4040, VCNL4200)
*/

+#include "linux/array_size.h"
+#include "linux/regulator/consumer.h"
#include <linux/bitfield.h>
#include <linux/module.h>
#include <linux/i2c.h>
@@ -1983,6 +1985,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;
int ret;
@@ -1998,6 +2001,11 @@ static int vcnl4000_probe(struct i2c_client *client)
data->chip_spec = &vcnl4000_chip_spec_cfg[data->id];

mutex_init(&data->vcnl4000_lock);
+ ret = devm_regulator_bulk_get_enable(&client->dev,
+ ARRAY_SIZE(regulator_names),
+ regulator_names);
+ if (ret < 0)
+ return ret;

ret = data->chip_spec->init(data);
if (ret < 0)

--
2.53.0