diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-19 12:43:37 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-03-07 11:55:05 +0100 |
commit | 39ad07b7de82bff26118a69e680cda3d081392dc (patch) | |
tree | 4bbefdbe7e13e6008cc0f8092afedc652c5c6c16 /drivers/media/i2c | |
parent | media: cxd2880: remove unused vars (diff) | |
download | linux-39ad07b7de82bff26118a69e680cda3d081392dc.tar.xz linux-39ad07b7de82bff26118a69e680cda3d081392dc.zip |
media: s5c73m3-core: fix logic on a timeout condition
As warned by smatch:
drivers/media/i2c/s5c73m3/s5c73m3-core.c:268 s5c73m3_check_status() error: uninitialized symbol 'status'.
if s5c73m3_check_status() is called too late, time_is_after_jiffies(end)
will return 0, causing the while to abort before reading status.
The current code will do the wrong thing here, as it will still
check if status != value. The right fix here is to change
the logic to ensure that it will always read the status.
Suggested-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/s5c73m3/s5c73m3-core.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index cdc4f2392ef9..ce196b60f917 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -248,17 +248,17 @@ static int s5c73m3_check_status(struct s5c73m3 *state, unsigned int value) { unsigned long start = jiffies; unsigned long end = start + msecs_to_jiffies(2000); - int ret = 0; + int ret; u16 status; int count = 0; - while (time_is_after_jiffies(end)) { + do { ret = s5c73m3_read(state, REG_STATUS, &status); if (ret < 0 || status == value) break; usleep_range(500, 1000); ++count; - } + } while (time_is_after_jiffies(end)); if (count > 0) v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd, |