* [PATCH v6 0/8] iio: light: vcnl4000: add regulator support
@ 2026-03-20 16:45 Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
` (8 more replies)
0 siblings, 9 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas, Raymond Hackley
This patch series introduces support for voltage supply, I2C and cathode
regulators. This fixes an issue where if a regulator is shared between
the proximity sensor and some other device, and the other device is
powered off, the proximity sensor would be powered off as well.
One of the commits includes a Reported-by: tag without a Closes: tag -
the report was done outside in a Matrix channel. A link to access the
report requires sign-in, therefore it was left out.
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
Changes in v6:
- Added descriptions to the regulators in the binding.
- Fixed the dt_binding_check bug in the example.
- Link to v5: https://lore.kernel.org/r/20260319-vcnl4000-regulators-v5-0-a025d3332805@gmail.com
Changes in v5:
- Renamed vddio-supply to vio-supply.
- Added parentheses to function calls in a variable usage commit message.
- Moved the redundant "proximity-near-level" check removal into its own
patch.
- Link to v4: https://lore.kernel.org/r/20260316-vcnl4000-regulators-v4-0-854fc2eaf54b@gmail.com
Changes in v4:
- Reworded device tree bindings commit into imperative mood and
clarified where do supplies come from.
- Moved data->chip_spec->set_power_state() calls from init functions to
probe.
- Removed explicit less than 0 checks for ret where unnecessary.
- Moved the patch that adds regulators to the end of the series.
- Added an explanation for removing duplicate prints in probe.
- Fixed indentation for devm_regulator_bulk_get_enable() and i2c_smbus
writes in vcnl4200_init().
- Removed a redundant check for "proximity-near-level" device property.
- Link to v3: https://lore.kernel.org/r/20260314-vcnl4000-regulators-v3-0-3c4a48d30676@gmail.com
Changes in v3:
- Added a more detailed description for supplies in the dt-bindings commit.
- Separated sorting includes into a commit of its own.
- Replaced all occurrences of mutex_init with its device-managed
counterpart.
- Moved client->dev variable declaration into a commit for adding
regulators.
- Removed redundant dev_err messages in probe function.
- Replaced all direct usages of client->dev and data->client into usages
by variable.
- Link to v2: https://lore.kernel.org/r/20260312-vcnl4000-regulators-v2-0-2bdebbcbb58a@gmail.com
Changes in v2:
- Removed double quotes in includes.
- Reordered includes alphabetically.
- Enabled regulators before the mutex is initialized.
- Replaced direct usage of &client->dev with a variable.
- Link to v1: https://lore.kernel.org/r/20260311-vcnl4000-regulators-v1-0-66b6038ce563@gmail.com
---
Erikas Bitovtas (8):
dt-bindings: iio: light: vcnl4000: add regulators
iio: light: vcnl4000: sort includes by their name
iio: light: vcnl4000: move power enablement from init to probe
iio: light: vcnl4000: replace mutex_init() with devm_mutex_init()
iio: light: vcnl4000: remove error messages for trigger and irq
iio: light: vcnl4000: use variables for I2C client and device instances
iio: light: vcnl4000: remove redundant check for proximity-near-level
iio: light: vcnl4000: add support for regulators
.../bindings/iio/light/vishay,vcnl4000.yaml | 14 ++++
drivers/iio/light/vcnl4000.c | 90 ++++++++++++----------
2 files changed, 63 insertions(+), 41 deletions(-)
---
base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e
change-id: 20260310-vcnl4000-regulators-bcf1b8a01ce6
Best regards,
--
Erikas Bitovtas <xerikasxx@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-21 10:14 ` Krzysztof Kozlowski
2026-03-21 12:42 ` Jonathan Cameron
2026-03-20 16:45 ` [PATCH v6 2/8] iio: light: vcnl4000: sort includes by their name Erikas Bitovtas
` (7 subsequent siblings)
8 siblings, 2 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
These sensors can accept 2 supplies - one for the sensor and one for IR
LED [1]. Add supply properties for the sensor - 2 for the sensors and
one external, for their open drain interrupt line, to ensure the sensor
is powered on before proceeding with setup.
[1] https://www.vishay.com/docs/84274/vcnl4040.pdf
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
.../devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
index 2ba4d5de4ec4..516afef7a545 100644
--- a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
+++ b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
@@ -33,6 +33,17 @@ properties:
interrupts:
maxItems: 1
+ vdd-supply:
+ description: Regulator providing power to the "VDD" pin.
+
+ vio-supply:
+ description: Regulator providing power for pull-up of the I/O lines.
+ Does not connect to the sensor directly, but is needed for the
+ correct operation of the I2C and interrupt lines.
+
+ vled-supply:
+ description: Regulator providing power to the IR anode pin.
+
reg:
maxItems: 1
@@ -54,6 +65,9 @@ examples:
compatible = "vishay,vcnl4200";
reg = <0x51>;
proximity-near-level = <220>;
+ vdd-supply = <®_vdd>;
+ vio-supply = <®_vio>;
+ vled-supply = <®_vled>;
};
};
...
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 2/8] iio: light: vcnl4000: sort includes by their name
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 3/8] iio: light: vcnl4000: move power enablement from init to probe Erikas Bitovtas
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
Sort include headers by file name for better readability.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 5e03c3d8874b..939ff2d65105 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -18,12 +18,12 @@
*/
#include <linux/bitfield.h>
-#include <linux/module.h>
-#include <linux/i2c.h>
-#include <linux/err.h>
#include <linux/delay.h>
-#include <linux/pm_runtime.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
#include <linux/units.h>
#include <linux/iio/buffer.h>
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 3/8] iio: light: vcnl4000: move power enablement from init to probe
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 2/8] iio: light: vcnl4000: sort includes by their name Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 4/8] iio: light: vcnl4000: replace mutex_init() with devm_mutex_init() Erikas Bitovtas
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
Given both vcnl4000_init() and vcnl4200_init() end with
dev->chip_spec->set_power_state(), they can be called once from the
probe to enable the sensors. Move the set_power_state function from init
and call it after init function in probe.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 939ff2d65105..287ccd89cfb2 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -280,7 +280,7 @@ static int vcnl4000_init(struct vcnl4000_data *data)
data->rev = ret & 0xf;
data->al_scale = 250000;
- return data->chip_spec->set_power_state(data, true);
+ return 0;
};
static ssize_t vcnl4000_write_als_enable(struct vcnl4000_data *data, bool en)
@@ -425,10 +425,6 @@ static int vcnl4200_init(struct vcnl4000_data *data)
if (ret < 0)
return ret;
- ret = data->chip_spec->set_power_state(data, true);
- if (ret < 0)
- return ret;
-
return 0;
};
@@ -2003,6 +1999,10 @@ static int vcnl4000_probe(struct i2c_client *client)
if (ret < 0)
return ret;
+ ret = data->chip_spec->set_power_state(data, true);
+ if (ret)
+ return ret;
+
dev_dbg(&client->dev, "%s Ambient light/proximity sensor, Rev: %02x\n",
data->chip_spec->prod, data->rev);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 4/8] iio: light: vcnl4000: replace mutex_init() with devm_mutex_init()
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
` (2 preceding siblings ...)
2026-03-20 16:45 ` [PATCH v6 3/8] iio: light: vcnl4000: move power enablement from init to probe Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 5/8] iio: light: vcnl4000: remove error messages for trigger and irq Erikas Bitovtas
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
Replace mutex_init() used across the driver with its device-managed
counterpart, so all assigned mutexes get destroyed.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 287ccd89cfb2..cd7e6ee42cc5 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -356,6 +356,8 @@ static int vcnl4200_set_power_state(struct vcnl4000_data *data, bool on)
static int vcnl4200_init(struct vcnl4000_data *data)
{
+ struct i2c_client *client = data->client;
+ struct device *dev = &client->dev;
int ret, id;
u16 regval;
@@ -400,8 +402,14 @@ static int vcnl4200_init(struct vcnl4000_data *data)
}
data->al_scale = data->chip_spec->ulux_step;
data->ps_scale = 16;
- mutex_init(&data->vcnl4200_al.lock);
- mutex_init(&data->vcnl4200_ps.lock);
+
+ ret = devm_mutex_init(dev, &data->vcnl4200_al.lock);
+ if (ret)
+ return ret;
+
+ ret = devm_mutex_init(dev, &data->vcnl4200_ps.lock);
+ if (ret)
+ return ret;
/* Use 16 bits proximity sensor readings */
ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1);
@@ -1979,6 +1987,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);
+ struct device *dev = &client->dev;
struct vcnl4000_data *data;
struct iio_dev *indio_dev;
int ret;
@@ -1993,7 +2002,9 @@ static int vcnl4000_probe(struct i2c_client *client)
data->id = id->driver_data;
data->chip_spec = &vcnl4000_chip_spec_cfg[data->id];
- mutex_init(&data->vcnl4000_lock);
+ ret = devm_mutex_init(dev, &data->vcnl4000_lock);
+ if (ret)
+ return ret;
ret = data->chip_spec->init(data);
if (ret < 0)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 5/8] iio: light: vcnl4000: remove error messages for trigger and irq
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
` (3 preceding siblings ...)
2026-03-20 16:45 ` [PATCH v6 4/8] iio: light: vcnl4000: replace mutex_init() with devm_mutex_init() Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 6/8] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
` (3 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
The error code is available in the log after return. In our case,
attaching a triggered buffer can only fail if we are out of memory, as
no other buffer is being attached. Remove duplicate error messages to
reduce noise in dmesg.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index cd7e6ee42cc5..76aee16d479b 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -2033,11 +2033,8 @@ static int vcnl4000_probe(struct i2c_client *client)
NULL,
data->chip_spec->trig_buffer_func,
data->chip_spec->buffer_setup_ops);
- if (ret < 0) {
- dev_err(&client->dev,
- "unable to setup iio triggered buffer\n");
+ if (ret < 0)
return ret;
- }
}
if (client->irq && data->chip_spec->irq_thread) {
@@ -2047,10 +2044,8 @@ static int vcnl4000_probe(struct i2c_client *client)
IRQF_ONESHOT,
"vcnl4000_irq",
indio_dev);
- if (ret < 0) {
- dev_err(&client->dev, "irq request failed\n");
+ if (ret < 0)
return ret;
- }
ret = vcnl4010_probe_trigger(indio_dev);
if (ret < 0)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 6/8] iio: light: vcnl4000: use variables for I2C client and device instances
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
` (4 preceding siblings ...)
2026-03-20 16:45 ` [PATCH v6 5/8] iio: light: vcnl4000: remove error messages for trigger and irq Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 7/8] iio: light: vcnl4000: remove redundant check for proximity-near-level Erikas Bitovtas
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
After moving data->client and client->dev into variables of their own,
replace all instances of data->client and client->dev being used in
vcnl4200_init() and vcnl4000_probe() by the said variables to reduce
clutter.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 76aee16d479b..34b52725aff6 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -361,14 +361,14 @@ static int vcnl4200_init(struct vcnl4000_data *data)
int ret, id;
u16 regval;
- ret = i2c_smbus_read_word_data(data->client, VCNL4200_DEV_ID);
+ ret = i2c_smbus_read_word_data(client, VCNL4200_DEV_ID);
if (ret < 0)
return ret;
id = ret & 0xff;
if (id != VCNL4200_PROD_ID) {
- ret = i2c_smbus_read_word_data(data->client, VCNL4040_DEV_ID);
+ ret = i2c_smbus_read_word_data(client, VCNL4040_DEV_ID);
if (ret < 0)
return ret;
@@ -378,7 +378,7 @@ static int vcnl4200_init(struct vcnl4000_data *data)
return -ENODEV;
}
- dev_dbg(&data->client->dev, "device id 0x%x", id);
+ dev_dbg(dev, "device id 0x%x", id);
data->rev = (ret >> 8) & 0xf;
data->ps_int = 0;
@@ -412,24 +412,22 @@ static int vcnl4200_init(struct vcnl4000_data *data)
return ret;
/* Use 16 bits proximity sensor readings */
- ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1);
+ ret = i2c_smbus_read_word_data(client, VCNL4200_PS_CONF1);
if (ret < 0)
return ret;
regval = ret | VCNL4040_PS_CONF2_PS_HD;
- ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1,
- regval);
+ ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF1, regval);
if (ret < 0)
return ret;
/* Align proximity sensor sample rate to 16 bits data width */
- ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF3);
+ ret = i2c_smbus_read_word_data(client, VCNL4200_PS_CONF3);
if (ret < 0)
return ret;
regval = ret | VCNL4040_CONF3_PS_SAMPLE_16BITS;
- ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF3,
- regval);
+ ret = i2c_smbus_write_word_data(client, VCNL4200_PS_CONF3, regval);
if (ret < 0)
return ret;
@@ -1992,7 +1990,7 @@ static int vcnl4000_probe(struct i2c_client *client)
struct iio_dev *indio_dev;
int ret;
- indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
@@ -2014,7 +2012,7 @@ static int vcnl4000_probe(struct i2c_client *client)
if (ret)
return ret;
- dev_dbg(&client->dev, "%s Ambient light/proximity sensor, Rev: %02x\n",
+ dev_dbg(dev, "%s Ambient light/proximity sensor, Rev: %02x\n",
data->chip_spec->prod, data->rev);
if (device_property_read_u32(&client->dev, "proximity-near-level",
@@ -2029,8 +2027,7 @@ static int vcnl4000_probe(struct i2c_client *client)
if (data->chip_spec->trig_buffer_func &&
data->chip_spec->buffer_setup_ops) {
- ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev,
- NULL,
+ ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
data->chip_spec->trig_buffer_func,
data->chip_spec->buffer_setup_ops);
if (ret < 0)
@@ -2038,8 +2035,8 @@ static int vcnl4000_probe(struct i2c_client *client)
}
if (client->irq && data->chip_spec->irq_thread) {
- ret = devm_request_threaded_irq(&client->dev, client->irq,
- NULL, data->chip_spec->irq_thread,
+ ret = devm_request_threaded_irq(dev, client->irq, NULL,
+ data->chip_spec->irq_thread,
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT,
"vcnl4000_irq",
@@ -2052,7 +2049,7 @@ static int vcnl4000_probe(struct i2c_client *client)
return ret;
}
- ret = pm_runtime_set_active(&client->dev);
+ ret = pm_runtime_set_active(dev);
if (ret < 0)
goto fail_poweroff;
@@ -2060,9 +2057,9 @@ static int vcnl4000_probe(struct i2c_client *client)
if (ret < 0)
goto fail_poweroff;
- pm_runtime_enable(&client->dev);
- pm_runtime_set_autosuspend_delay(&client->dev, VCNL4000_SLEEP_DELAY_MS);
- pm_runtime_use_autosuspend(&client->dev);
+ pm_runtime_enable(dev);
+ pm_runtime_set_autosuspend_delay(dev, VCNL4000_SLEEP_DELAY_MS);
+ pm_runtime_use_autosuspend(dev);
return 0;
fail_poweroff:
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 7/8] iio: light: vcnl4000: remove redundant check for proximity-near-level
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
` (5 preceding siblings ...)
2026-03-20 16:45 ` [PATCH v6 6/8] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 8/8] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
2026-03-20 19:35 ` [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Andy Shevchenko
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas
The data->near_level variable is already assigned 0 during
devm_kzalloc(), therefore checking if the property is present and then
assigning it 0 is redundant. Remove the check for device tree property
and let it fail silently if it is missing or invalid.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
---
drivers/iio/light/vcnl4000.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 34b52725aff6..0a4d82679cfe 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -2015,9 +2015,7 @@ static int vcnl4000_probe(struct i2c_client *client)
dev_dbg(dev, "%s Ambient light/proximity sensor, Rev: %02x\n",
data->chip_spec->prod, data->rev);
- if (device_property_read_u32(&client->dev, "proximity-near-level",
- &data->near_level))
- data->near_level = 0;
+ device_property_read_u32(dev, "proximity-near-level", &data->near_level);
indio_dev->info = data->chip_spec->info;
indio_dev->channels = data->chip_spec->channels;
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 8/8] iio: light: vcnl4000: add support for regulators
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
` (6 preceding siblings ...)
2026-03-20 16:45 ` [PATCH v6 7/8] iio: light: vcnl4000: remove redundant check for proximity-near-level Erikas Bitovtas
@ 2026-03-20 16:45 ` Erikas Bitovtas
2026-03-20 19:35 ` [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Andy Shevchenko
8 siblings, 0 replies; 13+ messages in thread
From: Erikas Bitovtas @ 2026-03-20 16:45 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald
Cc: linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Erikas Bitovtas, Raymond Hackley
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>
---
drivers/iio/light/vcnl4000.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 0a4d82679cfe..9650dbc41f2b 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>
@@ -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;
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/8] iio: light: vcnl4000: add regulator support
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
` (7 preceding siblings ...)
2026-03-20 16:45 ` [PATCH v6 8/8] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
@ 2026-03-20 19:35 ` Andy Shevchenko
2026-03-21 12:42 ` Jonathan Cameron
8 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2026-03-20 19:35 UTC (permalink / raw)
To: Erikas Bitovtas
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald,
linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Raymond Hackley
On Fri, Mar 20, 2026 at 06:45:35PM +0200, Erikas Bitovtas wrote:
> This patch series introduces support for voltage supply, I2C and cathode
> regulators. This fixes an issue where if a regulator is shared between
> the proximity sensor and some other device, and the other device is
> powered off, the proximity sensor would be powered off as well.
>
> One of the commits includes a Reported-by: tag without a Closes: tag -
> the report was done outside in a Matrix channel. A link to access the
> report requires sign-in, therefore it was left out.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
For the series, except the DT binding, I haven't even opened that mail.
Also you can add Suggested-by to the selected patches.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators
2026-03-20 16:45 ` [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
@ 2026-03-21 10:14 ` Krzysztof Kozlowski
2026-03-21 12:42 ` Jonathan Cameron
1 sibling, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-21 10:14 UTC (permalink / raw)
To: Erikas Bitovtas
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald,
linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel
On Fri, Mar 20, 2026 at 06:45:36PM +0200, Erikas Bitovtas wrote:
> These sensors can accept 2 supplies - one for the sensor and one for IR
> LED [1]. Add supply properties for the sensor - 2 for the sensors and
> one external, for their open drain interrupt line, to ensure the sensor
> is powered on before proceeding with setup.
>
> [1] https://www.vishay.com/docs/84274/vcnl4040.pdf
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
> ---
> .../devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/8] iio: light: vcnl4000: add regulator support
2026-03-20 19:35 ` [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Andy Shevchenko
@ 2026-03-21 12:42 ` Jonathan Cameron
0 siblings, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2026-03-21 12:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Erikas Bitovtas, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Meerwald,
linux-iio, devicetree, linux-kernel, ~postmarketos/upstreaming,
phone-devel, Raymond Hackley
On Fri, 20 Mar 2026 21:35:01 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Mar 20, 2026 at 06:45:35PM +0200, Erikas Bitovtas wrote:
> > This patch series introduces support for voltage supply, I2C and cathode
> > regulators. This fixes an issue where if a regulator is shared between
> > the proximity sensor and some other device, and the other device is
> > powered off, the proximity sensor would be powered off as well.
> >
> > One of the commits includes a Reported-by: tag without a Closes: tag -
> > the report was done outside in a Matrix channel. A link to access the
> > report requires sign-in, therefore it was left out.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
>
> For the series, except the DT binding, I haven't even opened that mail.
> Also you can add Suggested-by to the selected patches.
>
You do like to challenge b4! :) Hand removed the tag it added for
the DT patch.
Series applied to the testing branch of iio.git that I'll push
out as togreg once initial build tests are in etc.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators
2026-03-20 16:45 ` [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
2026-03-21 10:14 ` Krzysztof Kozlowski
@ 2026-03-21 12:42 ` Jonathan Cameron
1 sibling, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2026-03-21 12:42 UTC (permalink / raw)
To: Erikas Bitovtas
Cc: David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Peter Meerwald, linux-iio,
devicetree, linux-kernel, ~postmarketos/upstreaming, phone-devel
On Fri, 20 Mar 2026 18:45:36 +0200
Erikas Bitovtas <xerikasxx@gmail.com> wrote:
> These sensors can accept 2 supplies - one for the sensor and one for IR
> LED [1]. Add supply properties for the sensor - 2 for the sensors and
> one external, for their open drain interrupt line, to ensure the sensor
> is powered on before proceeding with setup.
>
> [1] https://www.vishay.com/docs/84274/vcnl4040.pdf
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
> ---
> .../devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
> index 2ba4d5de4ec4..516afef7a545 100644
> --- a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
> +++ b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
> @@ -33,6 +33,17 @@ properties:
> interrupts:
> maxItems: 1
>
> + vdd-supply:
> + description: Regulator providing power to the "VDD" pin.
> +
> + vio-supply:
> + description: Regulator providing power for pull-up of the I/O lines.
> + Does not connect to the sensor directly, but is needed for the
> + correct operation of the I2C and interrupt lines.
It's optional so I guess it doesn't matter, but whether this supply is
needed of not is down to whether the SoC allows for pull up on the
interrupt and I2C lines. Some SoCs provide this (though it's been
a while since I used one that did.).
In other cases an external pull up is needed. It would feel
odd to provide a supply for the pull up it was all hidden in the SoC.
Anyhow, optional so we aren't forcing this anyway.
Jonathan
> +
> + vled-supply:
> + description: Regulator providing power to the IR anode pin.
> +
> reg:
> maxItems: 1
>
> @@ -54,6 +65,9 @@ examples:
> compatible = "vishay,vcnl4200";
> reg = <0x51>;
> proximity-near-level = <220>;
> + vdd-supply = <®_vdd>;
> + vio-supply = <®_vio>;
> + vled-supply = <®_vled>;
> };
> };
> ...
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-03-21 12:42 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 16:45 [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 1/8] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
2026-03-21 10:14 ` Krzysztof Kozlowski
2026-03-21 12:42 ` Jonathan Cameron
2026-03-20 16:45 ` [PATCH v6 2/8] iio: light: vcnl4000: sort includes by their name Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 3/8] iio: light: vcnl4000: move power enablement from init to probe Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 4/8] iio: light: vcnl4000: replace mutex_init() with devm_mutex_init() Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 5/8] iio: light: vcnl4000: remove error messages for trigger and irq Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 6/8] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 7/8] iio: light: vcnl4000: remove redundant check for proximity-near-level Erikas Bitovtas
2026-03-20 16:45 ` [PATCH v6 8/8] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
2026-03-20 19:35 ` [PATCH v6 0/8] iio: light: vcnl4000: add regulator support Andy Shevchenko
2026-03-21 12:42 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox