Skip to content

Commit 58bf9ac

Browse files
stoupa-czjic23
authored andcommitted
iio: vcnl4000: warn on incorrectly specified device id
We can detect incorrectly specified device id for some chips, so warn user in that case. Signed-off-by: Tomas Novotny <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 50c50b9 commit 58bf9ac

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/iio/light/vcnl4000.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,20 @@ static int vcnl4000_init(struct vcnl4000_data *data)
8484
return ret;
8585

8686
prod_id = ret >> 4;
87-
if (prod_id != VCNL4010_PROD_ID && prod_id != VCNL4000_PROD_ID)
87+
switch (prod_id) {
88+
case VCNL4000_PROD_ID:
89+
if (data->id != VCNL4000)
90+
dev_warn(&data->client->dev,
91+
"wrong device id, use vcnl4000");
92+
break;
93+
case VCNL4010_PROD_ID:
94+
if (data->id != VCNL4010)
95+
dev_warn(&data->client->dev,
96+
"wrong device id, use vcnl4010/4020");
97+
break;
98+
default:
8899
return -ENODEV;
100+
}
89101

90102
data->rev = ret & 0xf;
91103
data->al_scale = 250000;

0 commit comments

Comments
 (0)