Input: s6sy761 - fix error handling in power management paths

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
Link: https://patch.msgid.link/arya1u_Rqtt85lyc@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 file changed