]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
iio: light: opt3001: Fixed timeout error when 0 lux
authorJiri Valek - 2N <valek@2n.cz>
Mon, 20 Sep 2021 12:53:48 +0000 (14:53 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 3 Oct 2021 15:43:25 +0000 (16:43 +0100)
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>
drivers/iio/light/opt3001.c

index 52963da401a78e9bdbba5bc186455312a1c9c882..1880bd5bb2586c5b9f05b61fa1dda532bc7156d0 100644 (file)
@@ -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) ?
@@ -312,9 +314,7 @@ err:
                /* 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) {