The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3 0/2] iio: proximity: cleanup fixes for vl53l1x-i2c
@ 2026-06-11 13:42 Siratul Islam
  2026-06-11 13:42 ` [PATCH v3 1/2] iio: proximity: sort the register values " Siratul Islam
  2026-06-11 13:42 ` [PATCH v3 2/2] iio: proximity: cleanup fixes " Siratul Islam
  0 siblings, 2 replies; 7+ messages in thread
From: Siratul Islam @ 2026-06-11 13:42 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Siratul Islam

This patch series adds some cleanup fixes for the vl53l1x-i2c
proximity sensor driver.

- Sort register defines list
- Extract data-ready polling into a helper
- Fix regmap_read_poll_timeout() arguments alignment
- Add field definitions for BIT(0).

No functional changes.

Siratul Islam (2):
  iio: proximity: sort the register values for vl53l1x-i2c
  iio: proximity: cleanup fixes for vl53l1x-i2c

 drivers/iio/proximity/vl53l1x-i2c.c | 40 +++++++++++++++--------------
 1 file changed, 21 insertions(+), 19 deletions(-)

--
2.54.0


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

* [PATCH v3 1/2] iio: proximity: sort the register values for vl53l1x-i2c
  2026-06-11 13:42 [PATCH v3 0/2] iio: proximity: cleanup fixes for vl53l1x-i2c Siratul Islam
@ 2026-06-11 13:42 ` Siratul Islam
  2026-06-11 19:21   ` Andy Shevchenko
  2026-06-11 13:42 ` [PATCH v3 2/2] iio: proximity: cleanup fixes " Siratul Islam
  1 sibling, 1 reply; 7+ messages in thread
From: Siratul Islam @ 2026-06-11 13:42 UTC (permalink / raw)
  To: jic23
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Siratul Islam,
	Andy Shevchenko

- Sort register defines list

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Siratul Islam <email@sirat.me>
---
 drivers/iio/proximity/vl53l1x-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/vl53l1x-i2c.c b/drivers/iio/proximity/vl53l1x-i2c.c
index 4d9cb3983dba..8302e0049e7c 100644
--- a/drivers/iio/proximity/vl53l1x-i2c.c
+++ b/drivers/iio/proximity/vl53l1x-i2c.c
@@ -43,6 +43,7 @@
 #define VL53L1X_REG_SOFT_RESET						0x0000
 #define VL53L1X_REG_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND		0x0008
 #define VL53L1X_REG_VHV_CONFIG__INIT					0x000B
+#define VL53L1X_REG_DEFAULT_CONFIG					0x002D
 #define VL53L1X_REG_GPIO_HV_MUX__CTRL					0x0030
 #define VL53L1X_REG_GPIO__TIO_HV_STATUS					0x0031
 #define VL53L1X_REG_SYSTEM__INTERRUPT_CONFIG_GPIO			0x0046
@@ -64,7 +65,6 @@
 #define VL53L1X_REG_RESULT__OSC_CALIBRATE_VAL				0x00DE
 #define VL53L1X_REG_FIRMWARE__SYSTEM_STATUS				0x00E5
 #define VL53L1X_REG_IDENTIFICATION__MODEL_ID				0x010F
-#define VL53L1X_REG_DEFAULT_CONFIG					0x002D
 
 #define VL53L1X_MODEL_ID_VAL		0xEACC
 
-- 
2.54.0


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

* [PATCH v3 2/2] iio: proximity: cleanup fixes for vl53l1x-i2c
  2026-06-11 13:42 [PATCH v3 0/2] iio: proximity: cleanup fixes for vl53l1x-i2c Siratul Islam
  2026-06-11 13:42 ` [PATCH v3 1/2] iio: proximity: sort the register values " Siratul Islam
@ 2026-06-11 13:42 ` Siratul Islam
  2026-06-11 19:23   ` Andy Shevchenko
  2026-06-12 17:40   ` Jonathan Cameron
  1 sibling, 2 replies; 7+ messages in thread
From: Siratul Islam @ 2026-06-11 13:42 UTC (permalink / raw)
  To: jic23
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Siratul Islam,
	Andy Shevchenko

Extract data-ready polling into a helper, fix regmap_read_poll_timeout()
argument alignment, and add field definitions for BIT(0).
No functional changes.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>

Signed-off-by: Siratul Islam <email@sirat.me>
---
 drivers/iio/proximity/vl53l1x-i2c.c | 38 +++++++++++++++--------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/proximity/vl53l1x-i2c.c b/drivers/iio/proximity/vl53l1x-i2c.c
index 8302e0049e7c..1782c89d5277 100644
--- a/drivers/iio/proximity/vl53l1x-i2c.c
+++ b/drivers/iio/proximity/vl53l1x-i2c.c
@@ -82,6 +82,9 @@
 
 #define VL53L1X_OSC_CALIBRATE_MASK	GENMASK(9, 0)
 
+#define VL53L1X_FIRMWARE__SYSTEM_STATUS_BOOTED	BIT(0)
+#define VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY	BIT(0)
+
 /* Inter-measurement period uses PLL divider with 1.075 oscillator correction */
 static const struct u32_fract vl53l1x_osc_correction = {
 	.numerator = 1075,
@@ -191,6 +194,18 @@ static int vl53l1x_stop_ranging(struct vl53l1x_data *data)
 			    VL53L1X_MODE_START_STOP);
 }
 
+static int vl53l1x_wait_data_ready(struct vl53l1x_data *data)
+{
+	unsigned int val;
+
+	/* 1ms poll, 1s timeout covers max timing budgets (per ST Ultra Lite Driver) */
+	return regmap_read_poll_timeout(data->regmap,
+					VL53L1X_REG_GPIO__TIO_HV_STATUS,
+					val, (val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) !=
+					data->gpio_polarity,
+					1 * USEC_PER_MSEC, 1 * USEC_PER_SEC);
+}
+
 /*
  * Default configuration blob from ST's VL53L1X Ultra Lite Driver
  * (STSW-IMG009).
@@ -230,10 +245,9 @@ static int vl53l1x_chip_init(struct vl53l1x_data *data)
 	}
 
 	ret = regmap_read_poll_timeout(data->regmap,
-				       VL53L1X_REG_FIRMWARE__SYSTEM_STATUS, val,
-				       val & BIT(0),
-				       1 * USEC_PER_MSEC,
-				       100 * USEC_PER_MSEC);
+				       VL53L1X_REG_FIRMWARE__SYSTEM_STATUS,
+				       val, val & VL53L1X_FIRMWARE__SYSTEM_STATUS_BOOTED,
+				       1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC);
 	if (ret)
 		return dev_err_probe(dev, ret, "firmware boot timeout\n");
 
@@ -261,12 +275,7 @@ static int vl53l1x_chip_init(struct vl53l1x_data *data)
 	if (ret)
 		return ret;
 
-	/* 1ms poll, 1s timeout covers max timing budgets (per ST Ultra Lite Driver) */
-	ret = regmap_read_poll_timeout(data->regmap,
-				       VL53L1X_REG_GPIO__TIO_HV_STATUS, val,
-				       (val & 1) != data->gpio_polarity,
-				       1 * USEC_PER_MSEC,
-				       1000 * USEC_PER_MSEC);
+	ret = vl53l1x_wait_data_ready(data);
 	if (ret)
 		return ret;
 
@@ -461,14 +470,7 @@ static int vl53l1x_read_proximity(struct vl53l1x_data *data, int *val)
 		if (!wait_for_completion_timeout(&data->completion, HZ))
 			return -ETIMEDOUT;
 	} else {
-		unsigned int rdy;
-
-		/* 1ms poll, 1s timeout covers max timing budgets (per ST Ultra Lite Driver) */
-		ret = regmap_read_poll_timeout(data->regmap,
-					       VL53L1X_REG_GPIO__TIO_HV_STATUS, rdy,
-					       (rdy & 1) != data->gpio_polarity,
-					       1 * USEC_PER_MSEC,
-					       1000 * USEC_PER_MSEC);
+		ret = vl53l1x_wait_data_ready(data);
 		if (ret)
 			return ret;
 	}
-- 
2.54.0


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

* Re: [PATCH v3 1/2] iio: proximity: sort the register values for vl53l1x-i2c
  2026-06-11 13:42 ` [PATCH v3 1/2] iio: proximity: sort the register values " Siratul Islam
@ 2026-06-11 19:21   ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-06-11 19:21 UTC (permalink / raw)
  To: Siratul Islam; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Thu, Jun 11, 2026 at 07:42:29PM +0600, Siratul Islam wrote:
> - Sort register defines list

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 2/2] iio: proximity: cleanup fixes for vl53l1x-i2c
  2026-06-11 13:42 ` [PATCH v3 2/2] iio: proximity: cleanup fixes " Siratul Islam
@ 2026-06-11 19:23   ` Andy Shevchenko
  2026-06-12 17:44     ` Jonathan Cameron
  2026-06-12 17:40   ` Jonathan Cameron
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-06-11 19:23 UTC (permalink / raw)
  To: Siratul Islam; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Thu, Jun 11, 2026 at 07:42:30PM +0600, Siratul Islam wrote:
> Extract data-ready polling into a helper, fix regmap_read_poll_timeout()
> argument alignment, and add field definitions for BIT(0).
> No functional changes.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

...

> +static int vl53l1x_wait_data_ready(struct vl53l1x_data *data)
> +{
> +	unsigned int val;
> +
> +	/* 1ms poll, 1s timeout covers max timing budgets (per ST Ultra Lite Driver) */
> +	return regmap_read_poll_timeout(data->regmap,
> +					VL53L1X_REG_GPIO__TIO_HV_STATUS,
> +					val, (val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) !=
> +					data->gpio_polarity,

I would put it this way
					val,
					(val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) != data->gpio_polarity,

but it goes over even 100! So up to Jonathan.

> +					1 * USEC_PER_MSEC, 1 * USEC_PER_SEC);
> +}

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 2/2] iio: proximity: cleanup fixes for vl53l1x-i2c
  2026-06-11 13:42 ` [PATCH v3 2/2] iio: proximity: cleanup fixes " Siratul Islam
  2026-06-11 19:23   ` Andy Shevchenko
@ 2026-06-12 17:40   ` Jonathan Cameron
  1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2026-06-12 17:40 UTC (permalink / raw)
  To: Siratul Islam
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Andy Shevchenko

On Thu, 11 Jun 2026 19:42:30 +0600
Siratul Islam <email@sirat.me> wrote:

> Extract data-ready polling into a helper, fix regmap_read_poll_timeout()
> argument alignment, and add field definitions for BIT(0).
> No functional changes.
> 
> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> 

No blank lines in tag blocks. It breaks many of the scripts that
run on the kernel tree.

> Signed-off-by: Siratul Islam <email@sirat.me>

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

* Re: [PATCH v3 2/2] iio: proximity: cleanup fixes for vl53l1x-i2c
  2026-06-11 19:23   ` Andy Shevchenko
@ 2026-06-12 17:44     ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2026-06-12 17:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Siratul Islam, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Thu, 11 Jun 2026 22:23:30 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Jun 11, 2026 at 07:42:30PM +0600, Siratul Islam wrote:
> > Extract data-ready polling into a helper, fix regmap_read_poll_timeout()
> > argument alignment, and add field definitions for BIT(0).
> > No functional changes.  
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> ...
> 
> > +static int vl53l1x_wait_data_ready(struct vl53l1x_data *data)
> > +{
> > +	unsigned int val;
> > +
> > +	/* 1ms poll, 1s timeout covers max timing budgets (per ST Ultra Lite Driver) */
> > +	return regmap_read_poll_timeout(data->regmap,
> > +					VL53L1X_REG_GPIO__TIO_HV_STATUS,
> > +					val, (val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) !=
> > +					data->gpio_polarity,  
> 
> I would put it this way
> 					val,
> 					(val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) != data->gpio_polarity,
> 
> but it goes over even 100! So up to Jonathan.
It's ugly whatever we do but 100 is too fa.  This may be a case for just not aligning with the bracket.

	return regmap_read_poll_timeout(data->regmap,
		VL53L1X_REG_GPIO__TIO_HV_STATUS, val,
		(val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) != data->gpio_polarity,  
		1 * USEC_PER_MSEC, 1 * USEC_PER_SEC);


or at least avoiding the mix of a full parameter and half of next one lin line.
	return regmap_read_poll_timeout(data->regmap,
					VL53L1X_REG_GPIO__TIO_HV_STATUS,
					val,
					(val & VL53L1X_GPIO__TIO_HV_STATUS_DATA_READY) !=
					data->gpio_polarity,
					1 * USEC_PER_MSEC, 1 * USEC_PER_SEC);

I think I'd go with the first option of just not aligning after the bracket.
}  
> 


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

end of thread, other threads:[~2026-06-12 17:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 13:42 [PATCH v3 0/2] iio: proximity: cleanup fixes for vl53l1x-i2c Siratul Islam
2026-06-11 13:42 ` [PATCH v3 1/2] iio: proximity: sort the register values " Siratul Islam
2026-06-11 19:21   ` Andy Shevchenko
2026-06-11 13:42 ` [PATCH v3 2/2] iio: proximity: cleanup fixes " Siratul Islam
2026-06-11 19:23   ` Andy Shevchenko
2026-06-12 17:44     ` Jonathan Cameron
2026-06-12 17:40   ` Jonathan Cameron

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