* [PATCH] iio: proximity: sx9360: keep the IRQ balanced across suspend and resume
@ 2026-10-26 10:04 Arnav Kapoor
2026-10-26 10:38 ` Joshua Crofts
0 siblings, 1 reply; 2+ messages in thread
From: Arnav Kapoor @ 2026-10-26 10:04 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, linux-iio,
linux-kernel, Arnav Kapoor
sx9360_suspend() disables the interrupt first and returns with it still
disabled if a register access fails. Resume isn't called after a failed
suspend, so the interrupt is never enabled again. sx9360_resume() also
returns without enabling it on error. Without an interrupt line,
client->irq is 0 and both callbacks act on IRQ 0, which the driver
doesn't own.
Disable the interrupt only once the device is asleep, always enable it
in resume, and skip both when there is no interrupt.
Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
I'm sending the same fix for sx9310, sx9324 and sx9360 as separate
patches, as the Fixes tags differ.
Compile-tested only (W=1); I don't have SX9360 hardware and haven't
reproduced a failing suspend.
drivers/iio/proximity/sx9360.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
index ed83d809ecf5..85b83d86a433 100644
--- a/drivers/iio/proximity/sx9360.c
+++ b/drivers/iio/proximity/sx9360.c
@@ -797,8 +797,6 @@ static int sx9360_suspend(struct device *dev)
unsigned int regval;
int ret;
- disable_irq_nosync(data->client->irq);
-
guard(mutex)(&data->mutex);
ret = regmap_read(data->regmap, SX9360_REG_GNRL_CTRL0, ®val);
if (ret < 0)
@@ -809,23 +807,32 @@ static int sx9360_suspend(struct device *dev)
/* Disable all phases, send the device to sleep. */
- return regmap_write(data->regmap, SX9360_REG_GNRL_CTRL0, 0);
+ ret = regmap_write(data->regmap, SX9360_REG_GNRL_CTRL0, 0);
+ if (ret)
+ return ret;
+
+ /* Only once nothing can fail, as resume isn't called on failure. */
+ if (data->client->irq)
+ disable_irq_nosync(data->client->irq);
+
+ return 0;
}
static int sx9360_resume(struct device *dev)
{
struct sx_common_data *data = iio_priv(dev_get_drvdata(dev));
+ int ret;
- scoped_guard(mutex, &data->mutex) {
- int ret = regmap_update_bits(data->regmap,
- SX9360_REG_GNRL_CTRL0,
- SX9360_REG_GNRL_CTRL0_PHEN_MASK,
- data->suspend_ctrl);
- if (ret)
- return ret;
- }
- enable_irq(data->client->irq);
- return 0;
+ scoped_guard(mutex, &data->mutex)
+ ret = regmap_update_bits(data->regmap, SX9360_REG_GNRL_CTRL0,
+ SX9360_REG_GNRL_CTRL0_PHEN_MASK,
+ data->suspend_ctrl);
+
+ /* Balance the suspend even if the device couldn't be woken up. */
+ if (data->client->irq)
+ enable_irq(data->client->irq);
+
+ return ret;
}
static DEFINE_SIMPLE_DEV_PM_OPS(sx9360_pm_ops, sx9360_suspend, sx9360_resume);
base-commit: 2ef6f5c4ee56e90c237c5f7687f09e635f7d30a9
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: proximity: sx9360: keep the IRQ balanced across suspend and resume
2026-10-26 10:04 [PATCH] iio: proximity: sx9360: keep the IRQ balanced across suspend and resume Arnav Kapoor
@ 2026-10-26 10:38 ` Joshua Crofts
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-10-26 10:38 UTC (permalink / raw)
To: Arnav Kapoor
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, linux-iio,
linux-kernel
On Mon, 26 Oct 2026 15:34:47 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:
> sx9360_suspend() disables the interrupt first and returns with it still
> disabled if a register access fails. Resume isn't called after a failed
> suspend, so the interrupt is never enabled again. sx9360_resume() also
> returns without enabling it on error. Without an interrupt line,
> client->irq is 0 and both callbacks act on IRQ 0, which the driver
> doesn't own.
>
> Disable the interrupt only once the device is asleep, always enable it
> in resume, and skip both when there is no interrupt.
>
> Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support")
> Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
> ---
> I'm sending the same fix for sx9310, sx9324 and sx9360 as separate
> patches, as the Fixes tags differ.
Shame you didn't send the patches as a series with a cover letter
given it's the same logical change and that it concerns the sx93xx
series.
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-26 10:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 10:04 [PATCH] iio: proximity: sx9360: keep the IRQ balanced across suspend and resume Arnav Kapoor
2026-10-26 10:38 ` Joshua Crofts
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®