Skip to content

Commit a551c26

Browse files
nxpfranklijic23
authored andcommitted
iio: light: vcnl4035: fixed chip ID check
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: 5570729 ("iio: light: Add support for vishay vcnl4035") Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 72c1d11 commit a551c26

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/iio/light/vcnl4035.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* TODO: Proximity
99
*/
1010
#include <linux/bitops.h>
11+
#include <linux/bitfield.h>
1112
#include <linux/i2c.h>
1213
#include <linux/module.h>
1314
#include <linux/pm_runtime.h>
@@ -42,6 +43,7 @@
4243
#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2)
4344
#define VCNL4035_INT_ALS_IF_H_MASK BIT(12)
4445
#define VCNL4035_INT_ALS_IF_L_MASK BIT(13)
46+
#define VCNL4035_DEV_ID_MASK GENMASK(7, 0)
4547

4648
/* Default values */
4749
#define VCNL4035_MODE_ALS_ENABLE BIT(0)
@@ -413,6 +415,7 @@ static int vcnl4035_init(struct vcnl4035_data *data)
413415
return ret;
414416
}
415417

418+
id = FIELD_GET(VCNL4035_DEV_ID_MASK, id);
416419
if (id != VCNL4035_DEV_ID_VAL) {
417420
dev_err(&data->client->dev, "Wrong id, got %x, expected %x\n",
418421
id, VCNL4035_DEV_ID_VAL);

0 commit comments

Comments
 (0)