public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] iio: light: vcnl4000: add regulator support
@ 2026-03-16 17:19 Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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 of LKML.

Signed-off-by: Erikas Bitovtas <xerikasxx@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 (7):
      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: add support for regulators

 .../bindings/iio/light/vishay,vcnl4000.yaml        |  7 ++
 drivers/iio/light/vcnl4000.c                       | 90 ++++++++++++----------
 2 files changed, 56 insertions(+), 41 deletions(-)
---
base-commit: 6e03baeeb160e6cfd72f2c39f26c50bcd925c7a0
change-id: 20260310-vcnl4000-regulators-bcf1b8a01ce6

Best regards,
-- 
Erikas Bitovtas <xerikasxx@gmail.com>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-17  7:20   ` Krzysztof Kozlowski
  2026-03-16 17:19 ` [PATCH v4 2/7] iio: light: vcnl4000: sort includes by their name Erikas Bitovtas
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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 I2C bus, 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>
---
 Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
index 2ba4d5de4ec4..a1b4c02db246 100644
--- a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
+++ b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
@@ -33,6 +33,10 @@ properties:
   interrupts:
     maxItems: 1
 
+  vdd-supply: true
+  vddio-supply: true
+  vled-supply: true
+
   reg:
     maxItems: 1
 
@@ -54,6 +58,9 @@ examples:
             compatible = "vishay,vcnl4200";
             reg = <0x51>;
             proximity-near-level = <220>;
+            vdd-supply = <&reg_vdd>;
+            vddio-supply = <&reg_vddio>;
+            vled-supply = <&reg_vled>;
         };
     };
 ...

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 2/7] iio: light: vcnl4000: sort includes by their name
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 3/7] iio: light: vcnl4000: move power enablement from init to probe Erikas Bitovtas
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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] 17+ messages in thread

* [PATCH v4 3/7] iio: light: vcnl4000: move power enablement from init to probe
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 2/7] iio: light: vcnl4000: sort includes by their name Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 4/7] iio: light: vcnl4000: replace mutex_init with devm_mutex_init Erikas Bitovtas
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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] 17+ messages in thread

* [PATCH v4 4/7] iio: light: vcnl4000: replace mutex_init with devm_mutex_init
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
                   ` (2 preceding siblings ...)
  2026-03-16 17:19 ` [PATCH v4 3/7] iio: light: vcnl4000: move power enablement from init to probe Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 5/7] iio: light: vcnl4000: remove error messages for trigger and irq Erikas Bitovtas
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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 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] 17+ messages in thread

* [PATCH v4 5/7] iio: light: vcnl4000: remove error messages for trigger and irq
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
                   ` (3 preceding siblings ...)
  2026-03-16 17:19 ` [PATCH v4 4/7] iio: light: vcnl4000: replace mutex_init with devm_mutex_init Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-16 17:19 ` [PATCH v4 6/7] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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] 17+ messages in thread

* [PATCH v4 6/7] iio: light: vcnl4000: use variables for I2C client and device instances
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
                   ` (4 preceding siblings ...)
  2026-03-16 17:19 ` [PATCH v4 5/7] iio: light: vcnl4000: remove error messages for trigger and irq Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-16 20:03   ` Andy Shevchenko
  2026-03-16 17:19 ` [PATCH v4 7/7] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
  2026-03-16 19:59 ` [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Andy Shevchenko
  7 siblings, 1 reply; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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 | 39 +++++++++++++++++----------------------
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 76aee16d479b..0a4d82679cfe 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,12 +2012,10 @@ 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",
-				     &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;
@@ -2029,8 +2025,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 +2033,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 +2047,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 +2055,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] 17+ messages in thread

* [PATCH v4 7/7] iio: light: vcnl4000: add support for regulators
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
                   ` (5 preceding siblings ...)
  2026-03-16 17:19 ` [PATCH v4 6/7] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
@ 2026-03-16 17:19 ` Erikas Bitovtas
  2026-03-16 20:05   ` Andy Shevchenko
  2026-03-16 19:59 ` [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Andy Shevchenko
  7 siblings, 1 reply; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 17:19 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..5d1408aca562 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", "vddio", "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] 17+ messages in thread

* Re: [PATCH v4 0/7] iio: light: vcnl4000: add regulator support
  2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
                   ` (6 preceding siblings ...)
  2026-03-16 17:19 ` [PATCH v4 7/7] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
@ 2026-03-16 19:59 ` Andy Shevchenko
  2026-03-16 20:20   ` Erikas Bitovtas
  7 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2026-03-16 19:59 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 Mon, Mar 16, 2026 at 07:19:44PM +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 of LKML.

You mean outside of public web access?


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 6/7] iio: light: vcnl4000: use variables for I2C client and device instances
  2026-03-16 17:19 ` [PATCH v4 6/7] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
@ 2026-03-16 20:03   ` Andy Shevchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-03-16 20:03 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 Mon, Mar 16, 2026 at 07:19:50PM +0200, Erikas Bitovtas wrote:
> 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

vcnl4200_init()
vcnl4000_probe()

> clutter.

...

> -	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);

I meant to see this change in a separate patch after the current one.
This will be associated with a commit message explaining why it's okay
because it looks like a potential behaviour change (but actually not).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 7/7] iio: light: vcnl4000: add support for regulators
  2026-03-16 17:19 ` [PATCH v4 7/7] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
@ 2026-03-16 20:05   ` Andy Shevchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-03-16 20:05 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 Mon, Mar 16, 2026 at 07:19:51PM +0200, Erikas Bitovtas 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.

...

> +	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
> +					     regulator_names);

I was suggesting just to fix an indentation in your original approach,
but okay, this is not a big deal to have less logical split between lines.

> +	if (ret)
> +		return ret;

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 0/7] iio: light: vcnl4000: add regulator support
  2026-03-16 19:59 ` [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Andy Shevchenko
@ 2026-03-16 20:20   ` Erikas Bitovtas
  2026-03-16 21:14     ` Andy Shevchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-16 20:20 UTC (permalink / raw)
  To: Andy Shevchenko
  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 3/16/26 9:59 PM, Andy Shevchenko wrote:
> On Mon, Mar 16, 2026 at 07:19:44PM +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 of LKML.
> 
> You mean outside of public web access?
> 

The report was done in a Matrix channel. I could provide the link to the
report for the Closes: tag, but it requires to sign-in to view it.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 0/7] iio: light: vcnl4000: add regulator support
  2026-03-16 20:20   ` Erikas Bitovtas
@ 2026-03-16 21:14     ` Andy Shevchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-03-16 21: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, Raymond Hackley

On Mon, Mar 16, 2026 at 10:20:54PM +0200, Erikas Bitovtas wrote:
> On 3/16/26 9:59 PM, Andy Shevchenko wrote:
> > On Mon, Mar 16, 2026 at 07:19:44PM +0200, Erikas Bitovtas wrote:

...

> >> One of the commits includes a Reported-by: tag without a Closes: tag -
> >> the report was done outside of LKML.
> > 
> > You mean outside of public web access?
> 
> The report was done in a Matrix channel. I could provide the link to the
> report for the Closes: tag, but it requires to sign-in to view it.

Okay, thanks for elaboration. In case of a new version, please mention this
in the cover letter.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators
  2026-03-16 17:19 ` [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
@ 2026-03-17  7:20   ` Krzysztof Kozlowski
  2026-03-17  8:07     ` Erikas Bitovtas
  0 siblings, 1 reply; 17+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-17  7:20 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 Mon, Mar 16, 2026 at 07:19:45PM +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 I2C bus, 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>
> ---
>  Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
> index 2ba4d5de4ec4..a1b4c02db246 100644
> --- a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
> +++ b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
> @@ -33,6 +33,10 @@ properties:
>    interrupts:
>      maxItems: 1
>  
> +  vdd-supply: true
> +  vddio-supply: true
> +  vled-supply: true

Same comments as before, I do not see improvements.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators
  2026-03-17  7:20   ` Krzysztof Kozlowski
@ 2026-03-17  8:07     ` Erikas Bitovtas
  2026-03-17 15:42       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-17  8:07 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  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 3/17/26 9:20 AM, Krzysztof Kozlowski wrote:
> On Mon, Mar 16, 2026 at 07:19:45PM +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 I2C bus, 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>
>> ---
>>  Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
>> index 2ba4d5de4ec4..a1b4c02db246 100644
>> --- a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
>> +++ b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml
>> @@ -33,6 +33,10 @@ properties:
>>    interrupts:
>>      maxItems: 1
>>  
>> +  vdd-supply: true
>> +  vddio-supply: true
>> +  vled-supply: true
> 
> Same comments as before, I do not see improvements.
> 
> Best regards,
> Krzysztof
> 

I explained why in v3. The message can be found here:
https://lore.kernel.org/linux-iio/cb92bb47-9078-475d-b242-71e3f9181a72@baylibre.com/T/#m6da277894cf5c2b473fbeebd4b7bafc7519ebc26

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators
  2026-03-17  8:07     ` Erikas Bitovtas
@ 2026-03-17 15:42       ` Krzysztof Kozlowski
  2026-03-18 12:47         ` Erikas Bitovtas
  0 siblings, 1 reply; 17+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-17 15:42 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 17/03/2026 09:07, Erikas Bitovtas wrote:
>>> +  vdd-supply: true
>>> +  vddio-supply: true
>>> +  vled-supply: true
>>
>> Same comments as before, I do not see improvements.
>>
>> Best regards,
>> Krzysztof
>>
> 
> I explained why in v3. The message can be found here:
> https://lore.kernel.org/linux-iio/cb92bb47-9078-475d-b242-71e3f9181a72@baylibre.com/T/#m6da277894cf5c2b473fbeebd4b7bafc7519ebc26

Apologies, I missed that. VDD and VLED are fine, but I2C bus supply is a
property of the I2C controller, not the device, therefore please drop VDDIO.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators
  2026-03-17 15:42       ` Krzysztof Kozlowski
@ 2026-03-18 12:47         ` Erikas Bitovtas
  0 siblings, 0 replies; 17+ messages in thread
From: Erikas Bitovtas @ 2026-03-18 12:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  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 3/17/26 5:42 PM, Krzysztof Kozlowski wrote:
> On 17/03/2026 09:07, Erikas Bitovtas wrote:
>>>> +  vdd-supply: true
>>>> +  vddio-supply: true
>>>> +  vled-supply: true
>>>
>>> Same comments as before, I do not see improvements.
>>>
>>> Best regards,
>>> Krzysztof
>>>
>>
>> I explained why in v3. The message can be found here:
>> https://lore.kernel.org/linux-iio/cb92bb47-9078-475d-b242-71e3f9181a72@baylibre.com/T/#m6da277894cf5c2b473fbeebd4b7bafc7519ebc26
> 
> Apologies, I missed that. VDD and VLED are fine, but I2C bus supply is a
> property of the I2C controller, not the device, therefore please drop VDDIO.
> 
> Best regards,
> Krzysztof

VDDIO supply is needed for the pull-up resistors for the open drain I2C
and interrupt lines. Without them, the device will send spurious
interrupts. Such cases are already present in mainline, for example
Awinic AW2013 led driver [1]:
> there is usually more than just the I2C I/O lines. For AW2013 there is
> at least also the open-drain interrupt line. On other ICs there could
> also be arbitrary GPIO lines that are used in open-drain mode. Those
> are completely unrelated to the I2C controller.
>
> Do you have any suggestions how to handle the power supply for those?

From the looks of it, it was agreed upon to rename the supply from VDDIO
to VIO. Has anything changed since then and now there is a better way to
represent this relationship?

[1]: https://lore.kernel.org/all/ZBoR0DPQ+AufzKHk@gerhold.net/#t

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-03-18 12:47 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 17:19 [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Erikas Bitovtas
2026-03-16 17:19 ` [PATCH v4 1/7] dt-bindings: iio: light: vcnl4000: add regulators Erikas Bitovtas
2026-03-17  7:20   ` Krzysztof Kozlowski
2026-03-17  8:07     ` Erikas Bitovtas
2026-03-17 15:42       ` Krzysztof Kozlowski
2026-03-18 12:47         ` Erikas Bitovtas
2026-03-16 17:19 ` [PATCH v4 2/7] iio: light: vcnl4000: sort includes by their name Erikas Bitovtas
2026-03-16 17:19 ` [PATCH v4 3/7] iio: light: vcnl4000: move power enablement from init to probe Erikas Bitovtas
2026-03-16 17:19 ` [PATCH v4 4/7] iio: light: vcnl4000: replace mutex_init with devm_mutex_init Erikas Bitovtas
2026-03-16 17:19 ` [PATCH v4 5/7] iio: light: vcnl4000: remove error messages for trigger and irq Erikas Bitovtas
2026-03-16 17:19 ` [PATCH v4 6/7] iio: light: vcnl4000: use variables for I2C client and device instances Erikas Bitovtas
2026-03-16 20:03   ` Andy Shevchenko
2026-03-16 17:19 ` [PATCH v4 7/7] iio: light: vcnl4000: add support for regulators Erikas Bitovtas
2026-03-16 20:05   ` Andy Shevchenko
2026-03-16 19:59 ` [PATCH v4 0/7] iio: light: vcnl4000: add regulator support Andy Shevchenko
2026-03-16 20:20   ` Erikas Bitovtas
2026-03-16 21:14     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox