Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2 1/1] iio: light: vcnl4035: fixed chip ID check
@ 2023-05-01 14:36 Frank Li
  2023-05-07 14:26 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Li @ 2023-05-01 14:36 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Uwe Kleine-König,
	Jeremy Kerr, Hans Verkuil, Ajay Gupta, Andy Shevchenko,
	Parthiban Nallathambi, open list:IIO SUBSYSTEM AND DRIVERS,
	open list
  Cc: imx

VCNL4035 register(0xE) ID_L and ID_M define as:

 ID_L: 0x80
 ID_H: 7:6 (0:0)
       5:4 (0:0) slave address = 0x60 (7-bit)
           (0:1) slave address = 0x51 (7-bit)
           (1:0) slave address = 0x40 (7-bit)
           (1:0) slave address = 0x41 (7-bit)
       3:0 Version code default	(0:0:0:0)

So just check ID_L.

Fixes: 55707294c4eb ("iio: light: Add support for vishay vcnl4035")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change from v1 to V2: 
-define VCNL4035_DEV_ID_MASK instead hardcode 0xff
-using FIELD_GET
-update commit message, remove a space line between fixes and signed-off

 drivers/iio/light/vcnl4035.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c
index 3ed37f6057fb..a23c415fcb7a 100644
--- a/drivers/iio/light/vcnl4035.c
+++ b/drivers/iio/light/vcnl4035.c
@@ -8,6 +8,7 @@
  * TODO: Proximity
  */
 #include <linux/bitops.h>
+#include <linux/bitfield.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -42,6 +43,7 @@
 #define VCNL4035_ALS_PERS_MASK		GENMASK(3, 2)
 #define VCNL4035_INT_ALS_IF_H_MASK	BIT(12)
 #define VCNL4035_INT_ALS_IF_L_MASK	BIT(13)
+#define VCNL4035_DEV_ID_MASK		GENMASK(7, 0)
 
 /* Default values */
 #define VCNL4035_MODE_ALS_ENABLE	BIT(0)
@@ -413,6 +415,7 @@ static int vcnl4035_init(struct vcnl4035_data *data)
 		return ret;
 	}
 
+	id = FIELD_GET(VCNL4035_DEV_ID_MASK, id);
 	if (id != VCNL4035_DEV_ID_VAL) {
 		dev_err(&data->client->dev, "Wrong id, got %x, expected %x\n",
 			id, VCNL4035_DEV_ID_VAL);
-- 
2.34.1


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

* Re: [PATCH v2 1/1] iio: light: vcnl4035: fixed chip ID check
  2023-05-01 14:36 [PATCH v2 1/1] iio: light: vcnl4035: fixed chip ID check Frank Li
@ 2023-05-07 14:26 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2023-05-07 14:26 UTC (permalink / raw)
  To: Frank Li
  Cc: Lars-Peter Clausen, Uwe Kleine-König, Jeremy Kerr,
	Hans Verkuil, Ajay Gupta, Andy Shevchenko, Parthiban Nallathambi,
	open list:IIO SUBSYSTEM AND DRIVERS, open list, imx

On Mon,  1 May 2023 10:36:04 -0400
Frank Li <Frank.Li@nxp.com> wrote:

> VCNL4035 register(0xE) ID_L and ID_M define as:
> 
>  ID_L: 0x80
>  ID_H: 7:6 (0:0)
>        5:4 (0:0) slave address = 0x60 (7-bit)
>            (0:1) slave address = 0x51 (7-bit)
>            (1:0) slave address = 0x40 (7-bit)
>            (1:0) slave address = 0x41 (7-bit)
>        3:0 Version code default	(0:0:0:0)
> 
> So just check ID_L.
> 
> Fixes: 55707294c4eb ("iio: light: Add support for vishay vcnl4035")
> Signed-off-by: Frank Li <Frank.Li@nxp.com>

Applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan

> ---
> Change from v1 to V2: 
> -define VCNL4035_DEV_ID_MASK instead hardcode 0xff
> -using FIELD_GET
> -update commit message, remove a space line between fixes and signed-off
> 
>  drivers/iio/light/vcnl4035.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c
> index 3ed37f6057fb..a23c415fcb7a 100644
> --- a/drivers/iio/light/vcnl4035.c
> +++ b/drivers/iio/light/vcnl4035.c
> @@ -8,6 +8,7 @@
>   * TODO: Proximity
>   */
>  #include <linux/bitops.h>
> +#include <linux/bitfield.h>
>  #include <linux/i2c.h>
>  #include <linux/module.h>
>  #include <linux/pm_runtime.h>
> @@ -42,6 +43,7 @@
>  #define VCNL4035_ALS_PERS_MASK		GENMASK(3, 2)
>  #define VCNL4035_INT_ALS_IF_H_MASK	BIT(12)
>  #define VCNL4035_INT_ALS_IF_L_MASK	BIT(13)
> +#define VCNL4035_DEV_ID_MASK		GENMASK(7, 0)
>  
>  /* Default values */
>  #define VCNL4035_MODE_ALS_ENABLE	BIT(0)
> @@ -413,6 +415,7 @@ static int vcnl4035_init(struct vcnl4035_data *data)
>  		return ret;
>  	}
>  
> +	id = FIELD_GET(VCNL4035_DEV_ID_MASK, id);
>  	if (id != VCNL4035_DEV_ID_VAL) {
>  		dev_err(&data->client->dev, "Wrong id, got %x, expected %x\n",
>  			id, VCNL4035_DEV_ID_VAL);


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

end of thread, other threads:[~2023-05-07 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-01 14:36 [PATCH v2 1/1] iio: light: vcnl4035: fixed chip ID check Frank Li
2023-05-07 14:26 ` Jonathan Cameron

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