summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnav Kapoor <kapoorarnav43@gmail.com>2026-10-24 23:26:53 +0530
committerJonathan Cameron <jonathan.cameron@oss.qualcomm.com>2026-11-02 00:39:47 +0000
commitb8ed9165906597b69a46fabf39ab41690721ebe8 (patch)
tree9b8ccdbbaede1a7100e20022d6c893ea1778fd53
parent098a4c37dc8815ea941866179220394e4d182c67 (diff)
iio: proximity: sx9500: ignore event config writes that don't change state
sx9500_write_event_config() adjusts the channel and close/far user counts on every write, even when the event is already in the requested state. Writing 0 to a disabled event and then 1 leaves the counts at 0, so the channel and its interrupts stay off while the event reads as enabled. As channel_users[] is shared with raw reads, those can then wait forever for a conversion. Writing 1 twice and then 0 has the opposite effect. Return early when the state doesn't change, as sx_common_write_event_config() does. Fixes: 4193c0f1d863 ("iio: driver for Semtech SX9500 proximity solution") Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
-rw-r--r--drivers/iio/proximity/sx9500.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index dadce9b44227..26522b6c5a2d 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -548,6 +548,12 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,
mutex_lock(&data->mutex);
+ /* The user counts must only change when the state does. */
+ if (data->event_enabled[chan->channel] == state) {
+ ret = 0;
+ goto out_unlock;
+ }
+
if (state) {
ret = sx9500_inc_chan_users(data, chan->channel);
if (ret < 0)