Skip to content

Commit

Permalink
iio: light: opt3001: Fixed timeout error when 0 lux
Browse files Browse the repository at this point in the history
Reading from sensor returned timeout error under
zero light conditions.

Signed-off-by: Jiri Valek - 2N <valek@2n.cz>
Fixes: ac663db ("iio: light: opt3001: enable operation w/o IRQ")
Link: https://lore.kernel.org/r/20210920125351.6569-1-valek@2n.cz
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Jiri Valek - 2N authored and Jonathan Cameron committed Oct 3, 2021
1 parent ea1945c commit 26d90b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/iio/light/opt3001.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ static int opt3001_get_lux(struct opt3001 *opt, int *val, int *val2)
ret = wait_event_timeout(opt->result_ready_queue,
opt->result_ready,
msecs_to_jiffies(OPT3001_RESULT_READY_LONG));
if (ret == 0)
return -ETIMEDOUT;
} else {
/* Sleep for result ready time */
timeout = (opt->int_time == OPT3001_INT_TIME_SHORT) ?
Expand Down Expand Up @@ -312,9 +314,7 @@ static int opt3001_get_lux(struct opt3001 *opt, int *val, int *val2)
/* Disallow IRQ to access the device while lock is active */
opt->ok_to_ignore_lock = false;

if (ret == 0)
return -ETIMEDOUT;
else if (ret < 0)
if (ret < 0)
return ret;

if (opt->use_irq) {
Expand Down

0 comments on commit 26d90b5

Please sign in to comment.