Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: light: opt3001: Fixed timeout error when 0 lux

Reading from sensor returned timeout error under
zero light conditions.

Signed-off-by: Jiri Valek - 2N <valek@2n.cz>
Fixes: ac663db3678a ("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>

authored by

Jiri Valek - 2N and committed by
Jonathan Cameron
26d90b55 ea1945c2

+3 -3
+3 -3
drivers/iio/light/opt3001.c
··· 276 276 ret = wait_event_timeout(opt->result_ready_queue, 277 277 opt->result_ready, 278 278 msecs_to_jiffies(OPT3001_RESULT_READY_LONG)); 279 + if (ret == 0) 280 + return -ETIMEDOUT; 279 281 } else { 280 282 /* Sleep for result ready time */ 281 283 timeout = (opt->int_time == OPT3001_INT_TIME_SHORT) ? ··· 314 312 /* Disallow IRQ to access the device while lock is active */ 315 313 opt->ok_to_ignore_lock = false; 316 314 317 - if (ret == 0) 318 - return -ETIMEDOUT; 319 - else if (ret < 0) 315 + if (ret < 0) 320 316 return ret; 321 317 322 318 if (opt->use_irq) {