Skip to content

Commit e01107e

Browse files
jilaypandyakartben
authored andcommitted
drivers: haptics: drv2605 fix unchecked return value
return -EIO if i2c_read does not work as expected. Signed-off-by: Jilay Pandya <[email protected]>
1 parent a0eb112 commit e01107e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/haptics/drv2605.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,16 +498,18 @@ static int drv2605_reset(const struct device *dev)
498498
k_msleep(100);
499499

500500
while (retries > 0) {
501-
i2c_reg_read_byte_dt(&config->i2c, DRV2605_REG_MODE, &value);
501+
retries--;
502+
503+
ret = i2c_reg_read_byte_dt(&config->i2c, DRV2605_REG_MODE, &value);
504+
if (ret < 0) {
505+
k_usleep(10000);
506+
continue;
507+
}
502508

503509
if ((value & DRV2605_DEV_RESET) == 0U) {
504510
i2c_reg_update_byte_dt(&config->i2c, DRV2605_REG_MODE, DRV2605_STANDBY, 0);
505511
return 0;
506512
}
507-
508-
retries--;
509-
510-
k_usleep(10000);
511513
}
512514

513515
return -ETIMEDOUT;

0 commit comments

Comments
 (0)