mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: imu: kmx61: reject duplicate event disable
@ 2026-09-25 14:10 Jiale Yao
  2026-09-25 14:18 ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Jiale Yao @ 2026-09-25 14:10 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Takashi Sakamoto, Siratul Islam, Maxwell Doose, linux-iio,
	linux-kernel
  Cc: Jiale Yao

The IIO core does not filter duplicate writes to the event enable
attribute. kmx61_write_event_config() already ignores repeated enable
requests, but a repeated disable request still calls
kmx61_set_power_state(data, false, KMX61_ACC), dropping a runtime PM
reference that was not acquired for this request. This can underflow the
runtime PM usage count and trigger a "Runtime PM usage count underflow"
warning.

Return early when the requested state already matches ev_enable_state.

Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 drivers/iio/imu/kmx61.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index c288437d53ea..a4962b88ef58 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -939,7 +939,7 @@ static int kmx61_write_event_config(struct iio_dev *indio_dev,
 	struct kmx61_data *data = kmx61_get_data(indio_dev);
 	int ret = 0;
 
-	if (state && data->ev_enable_state)
+	if (state == data->ev_enable_state)
 		return 0;
 
 	guard(mutex)(&data->lock);
-- 
2.34.1


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

* Re: [PATCH] iio: imu: kmx61: reject duplicate event disable
  2026-09-25 14:10 [PATCH] iio: imu: kmx61: reject duplicate event disable Jiale Yao
@ 2026-09-25 14:18 ` Andy Shevchenko
  2026-09-27 17:20   ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-09-25 14:18 UTC (permalink / raw)
  To: Jiale Yao
  Cc: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Takashi Sakamoto, Siratul Islam, Maxwell Doose, linux-iio,
	linux-kernel

On Fri, Sep 25, 2026 at 10:10:05PM +0800, Jiale Yao wrote:
> The IIO core does not filter duplicate writes to the event enable
> attribute. kmx61_write_event_config() already ignores repeated enable
> requests, but a repeated disable request still calls
> kmx61_set_power_state(data, false, KMX61_ACC), dropping a runtime PM
> reference that was not acquired for this request. This can underflow the
> runtime PM usage count and trigger a "Runtime PM usage count underflow"
> warning.
> 
> Return early when the requested state already matches ev_enable_state.

Same comments as per previous patches of the same topic.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] iio: imu: kmx61: reject duplicate event disable
  2026-09-25 14:18 ` Andy Shevchenko
@ 2026-09-27 17:20   ` Jonathan Cameron
  2026-09-28  8:30     ` jiale yao
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2026-09-27 17:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jiale Yao, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Takashi Sakamoto, Siratul Islam, Maxwell Doose, linux-iio,
	linux-kernel

On Fri, 25 Sep 2026 17:18:44 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, Sep 25, 2026 at 10:10:05PM +0800, Jiale Yao wrote:
> > The IIO core does not filter duplicate writes to the event enable
> > attribute. kmx61_write_event_config() already ignores repeated enable
> > requests, but a repeated disable request still calls
> > kmx61_set_power_state(data, false, KMX61_ACC), dropping a runtime PM
> > reference that was not acquired for this request. This can underflow the
> > runtime PM usage count and trigger a "Runtime PM usage count underflow"
> > warning.
> > 
> > Return early when the requested state already matches ev_enable_state.  
> 
> Same comments as per previous patches of the same topic.
> 
Fixes tag needed.


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

* Re:Re: [PATCH] iio: imu: kmx61: reject duplicate event disable
  2026-09-27 17:20   ` Jonathan Cameron
@ 2026-09-28  8:30     ` jiale yao
  2026-10-11 11:31       ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: jiale yao @ 2026-09-28  8:30 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Shevchenko, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Takashi Sakamoto, Siratul Islam, Maxwell Doose, linux-iio,
	linux-kernel

At 2026-09-28 01:20:31, "Jonathan Cameron" <jic23@kernel.org> wrote:
>On Fri, 25 Sep 2026 17:18:44 +0300
>Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
>
>> On Fri, Sep 25, 2026 at 10:10:05PM +0800, Jiale Yao wrote:
>> > The IIO core does not filter duplicate writes to the event enable
>> > attribute. kmx61_write_event_config() already ignores repeated enable
>> > requests, but a repeated disable request still calls
>> > kmx61_set_power_state(data, false, KMX61_ACC), dropping a runtime PM
>> > reference that was not acquired for this request. This can underflow the
>> > runtime PM usage count and trigger a "Runtime PM usage count underflow"
>> > warning.
>> > 
>> > Return early when the requested state already matches ev_enable_state.  
>> 
>> Same comments as per previous patches of the same topic.
>> 
>Fixes tag needed.

Fixes: fd3ae7a9f21c ("iio: imu: kmx61: Add support for any motion trigger")

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

* Re: [PATCH] iio: imu: kmx61: reject duplicate event disable
  2026-09-28  8:30     ` jiale yao
@ 2026-10-11 11:31       ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-10-11 11:31 UTC (permalink / raw)
  To: jiale yao
  Cc: Andy Shevchenko, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Takashi Sakamoto, Siratul Islam, Maxwell Doose, linux-iio,
	linux-kernel

On Mon, 28 Sep 2026 16:30:02 +0800 (CST)
"jiale yao" <19888972804@163.com> wrote:

> At 2026-09-28 01:20:31, "Jonathan Cameron" <jic23@kernel.org> wrote:
> >On Fri, 25 Sep 2026 17:18:44 +0300
> >Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> >  
> >> On Fri, Sep 25, 2026 at 10:10:05PM +0800, Jiale Yao wrote:  
> >> > The IIO core does not filter duplicate writes to the event enable
> >> > attribute. kmx61_write_event_config() already ignores repeated enable
> >> > requests, but a repeated disable request still calls
> >> > kmx61_set_power_state(data, false, KMX61_ACC), dropping a runtime PM
> >> > reference that was not acquired for this request. This can underflow the
> >> > runtime PM usage count and trigger a "Runtime PM usage count underflow"
> >> > warning.
> >> > 
> >> > Return early when the requested state already matches ev_enable_state.    
> >> 
> >> Same comments as per previous patches of the same topic.
> >>   
> >Fixes tag needed.  
> 
> Fixes: fd3ae7a9f21c ("iio: imu: kmx61: Add support for any motion trigger")

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks

Jonathan


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

end of thread, other threads:[~2026-10-11 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 14:10 [PATCH] iio: imu: kmx61: reject duplicate event disable Jiale Yao
2026-09-25 14:18 ` Andy Shevchenko
2026-09-27 17:20   ` Jonathan Cameron
2026-09-28  8:30     ` jiale yao
2026-10-11 11:31       ` Jonathan Cameron

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®