Input: psxpad-spi - use devm_pm_runtime_enable()
Subsystems (2)
PATCH 1/1 Input: psxpad-spi - use devm_pm_runtime_enable()
psxpad_spi_probe() calls pm_runtime_enable(), but the driver has no remove callback and nothing disables runtime PM on unbind. A later probe of the same device then calls pm_runtime_enable() with the disable depth already zero and warns about an unbalanced enable.
Use devm_pm_runtime_enable() so runtime PM is disabled on unbind.
--- drivers/input/joystick/psxpad-spi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/joystick/psxpad-spi.c +3 -1
@@ -374,7 +374,9 @@ static int psxpad_spi_probe(struct spi_device *spi) }spi_set_drvdata (spi, pad); -pm_runtime_enable (&spi->dev); + err =devm_pm_runtime_enable (&spi->dev); +if (err) +return err;return 0 ; }
Signature · 1 line
2.25.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] Input: psxpad-spi - devm_pm_runtime_enable() called after input_register_device() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] Input: psxpad-spi - devm_pm_runtime_enable() called after input_register_device()
--
commit 205ce29d7867cdc1a73d714ec01719f31658c807
Author: Cong Nguyen <[email protected]>
Input: psxpad-spi - use devm_pm_runtime_enable()
This commit replaces pm_runtime_enable() with devm_pm_runtime_enable() in psxpad_spi_probe() so runtime PM is disabled when the driver unbinds.
drivers/input/joystick/psxpad-spi.c static int psxpad_spi_probe(struct spi_device *spi) · line 379
Quoted 12 lines
drivers/input/joystick/psxpad-spi.c +3
-1@@ -374,7 +374,9 @@ static int psxpad_spi_probe(struct spi_device *spi) }spi_set_drvdata (spi, pad); -pm_runtime_enable (&spi->dev); + err =devm_pm_runtime_enable (&spi->dev); +if (err) +return err;
[Severity: Medium]
Should devm_pm_runtime_enable() and spi_set_drvdata() be called before input_register_device()?
Because idev is allocated with devm_input_allocate_device(), calling devm_pm_runtime_enable() after input_register_device() queues pm_runtime_disable_action after devm_input_device_unregister in devres. If the device is unbound while idev is open, devres disables runtime PM on spi->dev first, and the subsequent devm_input_device_unregister() -> psxpad_spi_poll_close() -> pm_runtime_put_sync() fails with -EACCES, leaving spi->dev in RPM_ACTIVE and leaking an active child count on the parent SPI controller. It also leaves a window after input_register_device() where psxpad_spi_poll_open() can call pm_runtime_get_sync() before runtime PM is enabled.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1