Skip to contentSkip to conversation

iio: accel: kxcjk-1013: reject duplicate event disable

PATCH Applied Jiale Yao 4 participants 6 messages Sep 25 – Sep 27 IIO

lore
Share & tools
lore

Jiale Yao

author
#0 lore raw

PATCH 1/1 iio: accel: kxcjk-1013: reject duplicate event disable

The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), 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.

---
 drivers/iio/accel/kxcjk-1013.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kxcjk-1013.c +1 -1
index 166fb786425f..8994c9e8e048 100644
@@ -1030,7 +1030,7 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev,
 	struct kxcjk1013_data *data = iio_priv(indio_dev);
 	int ret;
 
-	if (state && data->ev_enable_state)
+	if (state == data->ev_enable_state)
 		return 0;
 
 	mutex_lock(&data->mutex);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · Jiale Yao

The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), 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.

Sounds like a bug that needs to be fixed and hence Fixes tag to be applied.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 11 lines · Andy Shevchenko
Quoted 8 lines · Jiale Yao

The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), 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.

Sounds like a bug that needs to be fixed and hence Fixes tag to be applied.

Sure, I'll add the Fixes tag in v2, 24h later, for any other comments before sending it.

Quoted 5 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 9 lines · On Fri, 25 Sep 2026 22:38:07 +0800 (CST) "jiale yao" <[email protected]>…
Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Jiale Yao

The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), 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.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Return early when the requested state already matches ev_enable_state.

Sounds like a bug that needs to be fixed and hence Fixes tag to be applied.

Sure, I'll add the Fixes tag in v2, 24h later, for any other comments before sending it.

For a simple request for a fixes tag, I'm also fine with you just replying with that tag. b4 will pick it up (though technically in the wrong place so I'll massage things whilst applying)

Fix looks good to me.

Jonathan

Quoted 5 lines
Quoted 5 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Fri, 25 Sep 2026 22:38:07 +0800 (CST) "jiale yao" <[email protected]>…
Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Jiale Yao

The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), 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.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Return early when the requested state already matches ev_enable_state.

Sounds like a bug that needs to be fixed and hence Fixes tag to be applied.

Sure, I'll add the Fixes tag in v2, 24h later, for any other comments before sending it.

For a simple request for a fixes tag, I'm also fine with you just replying with that tag. b4 will pick it up (though technically in the wrong place so I'll massage things whilst applying)

Thanks.

Fixes b4b491c0832e ("iio: accel: kxcjk-1013: Support thresholds")
Quoted 10 lines

Fix looks good to me.

Jonathan

Quoted 5 lines
Quoted 5 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
maintainer Applied
#5 lore raw
Quoted 15 lines · On Sat, 26 Sep 2026 14:48:27 +0800 (CST) "jiale yao" <[email protected]>…
Quoted 14 lines · Jonathan Cameron
Quoted 11 lines · On Fri, 25 Sep 2026 22:38:07 +0800 (CST) "jiale yao" <[email protected]>…
Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Jiale Yao

The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), 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.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Sounds like a bug that needs to be fixed and hence Fixes tag to be applied.

Sure, I'll add the Fixes tag in v2, 24h later, for any other comments before sending it.

For a simple request for a fixes tag, I'm also fine with you just replying with that tag. b4 will pick it up (though technically in the wrong place so I'll massage things whilst applying)

Thanks.

Fixes b4b491c0832e ("iio: accel: kxcjk-1013: Support thresholds")

Applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan

Quoted 10 lines
Quoted 10 lines

Fix looks good to me.

Jonathan

Quoted 5 lines
Quoted 5 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko