Re: [PATCH v1 1/3] iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes
From: Nikhil Gautam
Date: Tue Jul 21 2026 - 09:08:05 EST
On 21-07-2026 01:19 am, Andy Shevchenko wrote:
On Tue, Jul 21, 2026 at 01:09:09AM +0530, Nikhil Gautam wrote:ACK, Will update in v2
The IIO core does not filter duplicate writes to the event enableNo blank lines in the tag block.
attribute, so writing the same value twice invokes
write_event_config() twice. Enabling twice leaks a runtime PM
reference, preventing the device from ever suspending again;
disabling twice underflows the usage count and triggers a
"Runtime PM usage count underflow" warning.
Bail out early when the requested state matches the current state.
While at it, switch to pm_runtime_resume_and_get() so a failed
resume is propagated to userspace instead of silently marking the
event enabled.
Fixes: 97d642e23037c ("iio: light: Add a driver for Sharp GP2AP002x00F")
Signed-off-by: Nikhil Gautam <nikhilgtr@xxxxxxxxx>
...
} else {At some point consider dropping this dup call.
pm_runtime_mark_last_busy(gp2ap002->dev);
ACK, Will update in v2
pm_runtime_put_autosuspend(gp2ap002->dev);
- gp2ap002->enabled = false;
}