iio: light: opt3001: Fixed timeout error when 0 lux
PATCH 1/1 iio: light: opt3001: Fixed timeout error when 0 lux
Reading from sensor returned timeout error under
zero light conditions.
--- drivers/iio/light/opt3001.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/opt3001.c +3 -3
@@ -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 @@ 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) {
Signature · 1 line
2.20.1
Jonathan Cameron
maintainerQuoted 4 lines · On Mon, 20 Sep 2021 14:53:48 +0200 Jiri Valek - 2N <[email protected]> wrote:
Reading from sensor returned timeout error under
zero light conditions.Signed-off-by Jiri Valek - 2N <[email protected]>
Hi Jiri,
Thanks for this. Looks good to me though I'll leave a little longer for others to take a look.
Does need a fixes tag though so we know how far to backport it. I think it should be
+Cc Alexander and Andreas
Quoted 28 lines
--- drivers/iio/light/opt3001.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/light/opt3001.c +3
-3@@ -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 @@ 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) {
Quoted 12 lines · On Sun, 26 Sep 2021 14:55:14 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 4 lines · On Mon, 20 Sep 2021 14:53:48 +0200 Jiri Valek - 2N <[email protected]> wrote:
Reading from sensor returned timeout error under
zero light conditions.Signed-off-by Jiri Valek - 2N <[email protected]>Hi Jiri,
Thanks for this. Looks good to me though I'll leave a little longer for others to take a look.
Quoted 6 lines
Does need a fixes tag though so we know how far to backport it. I think it should be
Fixes ac663db3678a ("iio: light: opt3001: enable operation w/o IRQ")+Cc Alexander and Andreas
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
Quoted 30 lines
Quoted 29 lines
--- drivers/iio/light/opt3001.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/light/opt3001.c +3
-3@@ -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 @@ 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) {