mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: light: st_uvis25: notify the current trigger when done
@ 2026-11-09  2:54 Jonathan Cameron
  2026-11-09  8:55 ` Lorenzo Bianconi
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Cameron @ 2026-11-09  2:54 UTC (permalink / raw)
  To: iio
  Cc: David Lechner, Nuno Sá,
	Andy Shevchenko, linux-kernel, Lorenzo Bianconi,
	Jonathan Cameron, stable

From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>

The trigger handler calls iio_trigger_notify_done() on the driver's own
trigger rather than on the trigger that is currently in use by the
device. The driver does not restrict which trigger may be used, so if
another trigger, for example an hrtimer trigger, is selected then that
trigger's use_count is never decremented and it stops firing after the
first sample. The driver's own trigger use_count also underflows,
preventing it from firing later.

Use iio_dev->trig instead.

Fixes: 3025c8688c1e ("iio: light: add support for UVIS25 sensor")
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
Another LLM found one as part of refactoring how all the code around
triggers works.  Definitely the wrong trigger. There are lots
that access the right trigger via the wrong path (shortly to be
cleaned up), this one manages to get the wrong one in many cases!
---
 drivers/iio/light/st_uvis25_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/st_uvis25_core.c b/drivers/iio/light/st_uvis25_core.c
index 94d5261b2663..5c63a68948d6 100644
--- a/drivers/iio/light/st_uvis25_core.c
+++ b/drivers/iio/light/st_uvis25_core.c
@@ -248,7 +248,7 @@ static irqreturn_t st_uvis25_buffer_handler_thread(int irq, void *p)
 				    iio_get_time_ns(iio_dev));
 
 out:
-	iio_trigger_notify_done(hw->trig);
+	iio_trigger_notify_done(iio_dev->trig);
 
 	return IRQ_HANDLED;
 }
-- 
2.56.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: light: st_uvis25: notify the current trigger when done
  2026-11-09  2:54 [PATCH] iio: light: st_uvis25: notify the current trigger when done Jonathan Cameron
@ 2026-11-09  8:55 ` Lorenzo Bianconi
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2026-11-09  8:55 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: iio, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-kernel, Lorenzo Bianconi,
	Jonathan Cameron, stable

[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]

> From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> 
> The trigger handler calls iio_trigger_notify_done() on the driver's own
> trigger rather than on the trigger that is currently in use by the
> device. The driver does not restrict which trigger may be used, so if
> another trigger, for example an hrtimer trigger, is selected then that
> trigger's use_count is never decremented and it stops firing after the
> first sample. The driver's own trigger use_count also underflows,
> preventing it from firing later.
> 
> Use iio_dev->trig instead.
> 
> Fixes: 3025c8688c1e ("iio: light: add support for UVIS25 sensor")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
> Another LLM found one as part of refactoring how all the code around
> triggers works.  Definitely the wrong trigger. There are lots
> that access the right trigger via the wrong path (shortly to be
> cleaned up), this one manages to get the wrong one in many cases!
> ---
>  drivers/iio/light/st_uvis25_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/st_uvis25_core.c b/drivers/iio/light/st_uvis25_core.c
> index 94d5261b2663..5c63a68948d6 100644
> --- a/drivers/iio/light/st_uvis25_core.c
> +++ b/drivers/iio/light/st_uvis25_core.c
> @@ -248,7 +248,7 @@ static irqreturn_t st_uvis25_buffer_handler_thread(int irq, void *p)
>  				    iio_get_time_ns(iio_dev));
>  
>  out:
> -	iio_trigger_notify_done(hw->trig);
> +	iio_trigger_notify_done(iio_dev->trig);
>  
>  	return IRQ_HANDLED;
>  }
> -- 
> 2.56.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-09  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09  2:54 [PATCH] iio: light: st_uvis25: notify the current trigger when done Jonathan Cameron
2026-11-09  8:55 ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®