* [PATCH] Input: s6sy761 - fix error handling in power management paths
@ 2026-09-30 5:18 Dmitry Torokhov
2026-09-30 16:15 ` David Heidelberg
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 5:18 UTC (permalink / raw)
To: linux-input; +Cc: David Heidelberg, linux-kernel
In s6sy761_power_on(), if any of the I2C operations or status checks
fail after enabling the regulators, the function returns an error while
leaving the regulators enabled. Conversely, in s6sy761_resume(), if
powering on the controller fails, enable_irq() is skipped while the PM
core still marks the device as resumed. A subsequent system suspend or
driver unbind then invokes s6sy761_power_off() again, attempting to
disable already disabled regulators and incrementing the IRQ disable
depth a second time, which leaves the interrupt permanently disabled on
later resumes. Additionally, if restoring sensing in s6sy761_resume()
fails, the controller is left powered on.
Track whether the controller is powered up with a powered_up flag,
unwind regulator enablement on error in s6sy761_power_on(), move
disable_irq() to s6sy761_suspend() so it is only called during system
sleep when the controller is powered up, and power off the controller
if restoring sensing fails during resume.
Reported-by: sashiko-bot@kernel.org
Assisted-by: LLM
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/s6sy761.c | 59 +++++++++++++++++++++--------
1 file changed, 43 insertions(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
index 899c179fb2d3..a770628d2b94 100644
--- a/drivers/input/touchscreen/s6sy761.c
+++ b/drivers/input/touchscreen/s6sy761.c
@@ -108,6 +108,8 @@ struct s6sy761_data {
u16 devid;
u8 tx_channel;
+
+ bool powered_up;
};
/*
@@ -307,32 +309,41 @@ static int s6sy761_power_on(struct s6sy761_data *sdata)
S6SY761_EVENT_SIZE,
buffer);
if (ret < 0)
- return ret;
+ goto err_disable_regulators;
event = (buffer[0] >> 2) & 0xf;
if ((event != S6SY761_EVENT_INFO &&
event != S6SY761_EVENT_VENDOR_INFO) ||
buffer[1] != S6SY761_INFO_BOOT_COMPLETE) {
- return -ENODEV;
+ ret = -ENODEV;
+ goto err_disable_regulators;
}
ret = i2c_smbus_read_byte_data(sdata->client, S6SY761_BOOT_STATUS);
if (ret < 0)
- return ret;
+ goto err_disable_regulators;
/* for some reasons the device might be stuck in the bootloader */
- if (ret != S6SY761_BS_APPLICATION)
- return -ENODEV;
+ if (ret != S6SY761_BS_APPLICATION) {
+ ret = -ENODEV;
+ goto err_disable_regulators;
+ }
/* enable touch functionality */
ret = i2c_smbus_write_word_data(sdata->client,
S6SY761_TOUCH_FUNCTION,
S6SY761_MASK_TOUCH);
if (ret)
- return ret;
+ goto err_disable_regulators;
+ sdata->powered_up = true;
return 0;
+
+err_disable_regulators:
+ regulator_bulk_disable(ARRAY_SIZE(sdata->regulators),
+ sdata->regulators);
+ return ret;
}
static int s6sy761_hw_init(struct s6sy761_data *sdata,
@@ -381,9 +392,11 @@ static void s6sy761_power_off(void *data)
{
struct s6sy761_data *sdata = data;
- disable_irq(sdata->client->irq);
- regulator_bulk_disable(ARRAY_SIZE(sdata->regulators),
- sdata->regulators);
+ if (!sdata->powered_up)
+ return;
+
+ regulator_bulk_disable(ARRAY_SIZE(sdata->regulators), sdata->regulators);
+ sdata->powered_up = false;
}
static int s6sy761_probe(struct i2c_client *client)
@@ -492,11 +505,24 @@ static int s6sy761_suspend(struct device *dev)
{
struct s6sy761_data *sdata = dev_get_drvdata(dev);
- s6sy761_power_off(sdata);
+ if (sdata->powered_up) {
+ disable_irq(sdata->client->irq);
+ s6sy761_power_off(sdata);
+ }
return 0;
}
+static int s6sy761_restore_sense(struct s6sy761_data *sdata)
+{
+ guard(mutex)(&sdata->input->mutex);
+
+ if (!input_device_enabled(sdata->input))
+ return 0;
+
+ return i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON);
+}
+
static int s6sy761_resume(struct device *dev)
{
struct s6sy761_data *sdata = dev_get_drvdata(dev);
@@ -506,15 +532,16 @@ static int s6sy761_resume(struct device *dev)
if (err)
return err;
- enable_irq(sdata->client->irq);
-
- guard(mutex)(&sdata->input->mutex);
+ err = s6sy761_restore_sense(sdata);
+ if (err)
+ goto err_power_off;
- if (!input_device_enabled(sdata->input))
- return 0;
+ enable_irq(sdata->client->irq);
- err = i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON);
+ return 0;
+err_power_off:
+ s6sy761_power_off(sdata);
return err;
}
--
2.56.0.rc1.315.gc6ed9934b7-goog
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: s6sy761 - fix error handling in power management paths
2026-09-30 5:18 [PATCH] Input: s6sy761 - fix error handling in power management paths Dmitry Torokhov
@ 2026-09-30 16:15 ` David Heidelberg
2026-09-30 16:26 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: David Heidelberg @ 2026-09-30 16:15 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input; +Cc: linux-kernel
On 30/09/2026 07:18, Dmitry Torokhov wrote:
> In s6sy761_power_on(), if any of the I2C operations or status checks
> fail after enabling the regulators, the function returns an error while
> leaving the regulators enabled. Conversely, in s6sy761_resume(), if
> powering on the controller fails, enable_irq() is skipped while the PM
> core still marks the device as resumed. A subsequent system suspend or
> driver unbind then invokes s6sy761_power_off() again, attempting to
> disable already disabled regulators and incrementing the IRQ disable
> depth a second time, which leaves the interrupt permanently disabled on
> later resumes. Additionally, if restoring sensing in s6sy761_resume()
> fails, the controller is left powered on.
>
> Track whether the controller is powered up with a powered_up flag,
> unwind regulator enablement on error in s6sy761_power_on(), move
> disable_irq() to s6sy761_suspend() so it is only called during system
> sleep when the controller is powered up, and power off the controller
> if restoring sensing fails during resume.
>
> Reported-by: sashiko-bot@kernel.org
> Assisted-by: LLM
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/input/touchscreen/s6sy761.c | 59 +++++++++++++++++++++--------
> 1 file changed, 43 insertions(+), 16 deletions(-)
>
+<<<<<<< HEAD
return s6sy761_power_on(sdata);
+=======
+ return 0;
+
+err_power_off:
+ s6sy761_power_off(sdata);
+ return err;
+>>>>>>> Input: s6sy761 - fix error handling in power management paths
doesn't apply cleanly on linux-next, against which branch was it build? (I don't
see anything touch it in input)
Thanks
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: s6sy761 - fix error handling in power management paths
2026-09-30 16:15 ` David Heidelberg
@ 2026-09-30 16:26 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 16:26 UTC (permalink / raw)
To: David Heidelberg; +Cc: linux-input, linux-kernel
On Wed, Sep 30, 2026 at 06:15:29PM +0200, David Heidelberg wrote:
> On 30/09/2026 07:18, Dmitry Torokhov wrote:
> > In s6sy761_power_on(), if any of the I2C operations or status checks
> > fail after enabling the regulators, the function returns an error while
> > leaving the regulators enabled. Conversely, in s6sy761_resume(), if
> > powering on the controller fails, enable_irq() is skipped while the PM
> > core still marks the device as resumed. A subsequent system suspend or
> > driver unbind then invokes s6sy761_power_off() again, attempting to
> > disable already disabled regulators and incrementing the IRQ disable
> > depth a second time, which leaves the interrupt permanently disabled on
> > later resumes. Additionally, if restoring sensing in s6sy761_resume()
> > fails, the controller is left powered on.
> >
> > Track whether the controller is powered up with a powered_up flag,
> > unwind regulator enablement on error in s6sy761_power_on(), move
> > disable_irq() to s6sy761_suspend() so it is only called during system
> > sleep when the controller is powered up, and power off the controller
> > if restoring sensing fails during resume.
> >
> > Reported-by: sashiko-bot@kernel.org
> > Assisted-by: LLM
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > drivers/input/touchscreen/s6sy761.c | 59 +++++++++++++++++++++--------
> > 1 file changed, 43 insertions(+), 16 deletions(-)
> >
>
> +<<<<<<< HEAD
> return s6sy761_power_on(sdata);
> +=======
> + return 0;
> +
> +err_power_off:
> + s6sy761_power_off(sdata);
> + return err;
> +>>>>>>> Input: s6sy761 - fix error handling in power management paths
>
> doesn't apply cleanly on linux-next, against which branch was it build? (I
> don't see anything touch it in input)
It's on top of your change, I just pushed my queue out, should be in
next next.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-30 16:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 5:18 [PATCH] Input: s6sy761 - fix error handling in power management paths Dmitry Torokhov
2026-09-30 16:15 ` David Heidelberg
2026-09-30 16:26 ` Dmitry Torokhov
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®