diff mbox

spi: pxa2xx: Disable runtime PM if controller registration fails

Message ID 20180307150504.16214-1-jarkko.nikula@linux.intel.com (mailing list archive)
State Accepted
Commit e2b714afee32d368e0fda825c48181626979a551
Headers show

Commit Message

Jarkko Nikula March 7, 2018, 3:05 p.m. UTC
Don't leave runtime PM enabled in case devm_spi_register_controller()
returns with an error. Otherwise runtime PM will complain when driver is
reloaded:

[  693.855811] pxa2xx-spi pxa2xx-spi.13: Unbalanced pm_runtime_enable!

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
This can be hit quite easily when breaking the rmmod/modprobe loop with
CTRL+C and kthread startup in spi_init_queue() is interrupted.

while :; do rmmod spi_pxa2xx_platform ; modprobe spi_pxa2xx_platform; done
[  688.501525] spi_master spi2: failed to create message pump task
[  688.508235] spi_master spi2: problem initializing queue
[  688.514328] pxa2xx-spi pxa2xx-spi.13: problem registering spi master
[  688.521529] pxa2xx-spi: probe of pxa2xx-spi.13 failed with error -4
...
[  693.855811] pxa2xx-spi pxa2xx-spi.13: Unbalanced pm_runtime_enable!
---
 drivers/spi/spi-pxa2xx.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 713506eff07d..82dcb88fcfba 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1806,6 +1806,8 @@  static int pxa2xx_spi_probe(struct platform_device *pdev)
 	return status;
 
 out_error_clock_enabled:
+	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	clk_disable_unprepare(ssp->clk);
 	pxa2xx_spi_dma_release(drv_data);
 	free_irq(ssp->irq, drv_data);