Skip to content

Commit 1b92691

Browse files
Demon000jic23
authored andcommitted
iio: accel: adxl367: fix DEVID read after reset
regmap_read_poll_timeout() will not sleep before reading, causing the first read to return -ENXIO on I2C, since the chip does not respond to it while it is being reset. The datasheet specifies that a soft reset operation has a latency of 7.5ms. Add a 15ms sleep between reset and reading the DEVID register, and switch to a simple regmap_read() call. Fixes: cbab791 ("iio: accel: add ADXL367 driver") Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240207033657.206171-1-demonsingur@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent a1c9f50 commit 1b92691

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iio/accel/adxl367.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,9 +1429,11 @@ static int adxl367_verify_devid(struct adxl367_state *st)
14291429
unsigned int val;
14301430
int ret;
14311431

1432-
ret = regmap_read_poll_timeout(st->regmap, ADXL367_REG_DEVID, val,
1433-
val == ADXL367_DEVID_AD, 1000, 10000);
1432+
ret = regmap_read(st->regmap, ADXL367_REG_DEVID, &val);
14341433
if (ret)
1434+
return dev_err_probe(st->dev, ret, "Failed to read dev id\n");
1435+
1436+
if (val != ADXL367_DEVID_AD)
14351437
return dev_err_probe(st->dev, -ENODEV,
14361438
"Invalid dev id 0x%02X, expected 0x%02X\n",
14371439
val, ADXL367_DEVID_AD);
@@ -1510,6 +1512,8 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
15101512
if (ret)
15111513
return ret;
15121514

1515+
fsleep(15000);
1516+
15131517
ret = adxl367_verify_devid(st);
15141518
if (ret)
15151519
return ret;

0 commit comments

Comments
 (0)