mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] Input: psxpad-spi - use devm_pm_runtime_enable()
@ 2026-12-01  4:18 Cong Nguyen
  2026-12-01  6:07 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-12-01  4:18 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

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, and
enable it before registering the input device so it is still enabled
when that device is closed on unbind.

Fixes: 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
Changes in v2:
- Enable runtime PM and set the driver data before input_register_device(),
  so runtime PM is still enabled when the input device is closed on
  unbind (Sashiko review of v1).

 drivers/input/joystick/psxpad-spi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
index a2b00e420e38..c97607dbdbfa 100644
--- a/drivers/input/joystick/psxpad-spi.c
+++ b/drivers/input/joystick/psxpad-spi.c
@@ -365,6 +365,12 @@ static int psxpad_spi_probe(struct spi_device *spi)
 	input_set_min_poll_interval(idev, 8);
 	input_set_max_poll_interval(idev, 32);
 
+	spi_set_drvdata(spi, pad);
+
+	err = devm_pm_runtime_enable(&spi->dev);
+	if (err)
+		return err;
+
 	/* register input poll device */
 	err = input_register_device(idev);
 	if (err) {
@@ -373,9 +379,6 @@ static int psxpad_spi_probe(struct spi_device *spi)
 		return err;
 	}
 
-	spi_set_drvdata(spi, pad);
-	pm_runtime_enable(&spi->dev);
-
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Input: psxpad-spi - use devm_pm_runtime_enable()
  2026-12-01  4:18 [PATCH v2] Input: psxpad-spi - use devm_pm_runtime_enable() Cong Nguyen
@ 2026-12-01  6:07 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-12-01  6:07 UTC (permalink / raw)
  To: Cong Nguyen; +Cc: linux-input, linux-kernel

On Tue, Dec 01, 2026 at 11:18:42AM +0700, Cong Nguyen wrote:
> 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, and
> enable it before registering the input device so it is still enabled
> when that device is closed on unbind.
> 
> Fixes: 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01  6:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  4:18 [PATCH v2] Input: psxpad-spi - use devm_pm_runtime_enable() Cong Nguyen
2026-12-01  6:07 ` 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®