diff options
| author | Sakari Ailus <[email protected]> | 2024-10-15 07:07:02 +0000 |
|---|---|---|
| committer | Hans Verkuil <[email protected]> | 2025-04-25 08:15:33 +0000 |
| commit | bb468fc5a4d902c9202f32ed4ee1f0980c17fe52 (patch) | |
| tree | e1be3df7bbabe42abd46ce0ecb38ef1fa0919998 /drivers/media/i2c/ccs/ccs-core.c | |
| parent | media: ccs: Try a little longer to access the sensor before giving up (diff) | |
| download | kernel-bb468fc5a4d902c9202f32ed4ee1f0980c17fe52.tar.gz kernel-bb468fc5a4d902c9202f32ed4ee1f0980c17fe52.zip | |
media: ccs: Use read_poll_timeout() in reset polling
Use read_poll_timeout() in polling the device after a reset, either hard
or soft. While at it, improve the related error message.
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Diffstat (limited to 'drivers/media/i2c/ccs/ccs-core.c')
| -rw-r--r-- | drivers/media/i2c/ccs/ccs-core.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index a47c56d9779f..01744ebd3e06 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1588,7 +1588,6 @@ static int ccs_power_on(struct device *dev) * an error. */ if (!sensor->reset && !sensor->xshutdown) { - u8 retry = 100; u32 reset; rval = read_poll_timeout(ccs_write, rval, !rval, @@ -1601,18 +1600,15 @@ static int ccs_power_on(struct device *dev) goto out_cci_addr_fail; } - do { - rval = ccs_read(sensor, SOFTWARE_RESET, &reset); - reset = !rval && reset == CCS_SOFTWARE_RESET_OFF; - if (reset) - break; - - usleep_range(1000, 2000); - } while (--retry); - - if (!reset) { - dev_err(dev, "software reset failed\n"); - rval = -EIO; + rval = read_poll_timeout(ccs_read, rval, + !rval && + reset == CCS_SOFTWARE_RESET_OFF, + CCS_RESET_DELAY_US, + CCS_RESET_TIMEOUT_US, false, sensor, + SOFTWARE_RESET, &reset); + if (rval < 0) { + dev_err_probe(dev, rval, + "failed to respond after reset\n"); goto out_cci_addr_fail; } } |
