]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: light: vcnl4000: add support for regulators
authorErikas Bitovtas <xerikasxx@gmail.com>
Fri, 20 Mar 2026 16:45:43 +0000 (18:45 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 21 Mar 2026 12:40:30 +0000 (12:40 +0000)
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.

Reported-by: Raymond Hackley <raymondhackley@protonmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/vcnl4000.c

index 0a4d82679cfecbc8816480ed2ae50664aecf4882..9650dbc41f2ba038b12250ee60da854737444407 100644 (file)
@@ -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>
@@ -1985,6 +1986,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", "vio", "vled" };
        struct device *dev = &client->dev;
        struct vcnl4000_data *data;
        struct iio_dev *indio_dev;
@@ -2000,6 +2002,11 @@ 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)
+               return ret;
+
        ret = devm_mutex_init(dev, &data->vcnl4000_lock);
        if (ret)
                return ret;