[PATCH] iio: imu: kmx61: reject duplicate event disable

From: Jiale Yao

Date: Fri Sep 25 2026 - 10:18:56 EST


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@xxxxxxx>
---
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