Skip to content

Commit 7999d25

Browse files
Alain Volmatbroonie
authored andcommitted
spi: stm32: fixes pm_runtime calls in probe/remove
Add pm_runtime calls in probe/probe error path and remove in order to be consistent in all places in ordering and ensure that pm_runtime is disabled prior to resources used by the SPI controller. This patch also fixes the 2 following warnings on driver remove: WARNING: CPU: 0 PID: 743 at drivers/clk/clk.c:594 clk_core_disable_lock+0x18/0x24 WARNING: CPU: 0 PID: 743 at drivers/clk/clk.c:476 clk_unprepare+0x24/0x2c Fixes: 038ac86 ("spi: stm32: add runtime PM support") Signed-off-by: Amelie Delaunay <[email protected]> Signed-off-by: Alain Volmat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 135cbd3 commit 7999d25

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/spi/spi-stm32.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
19281928
master->can_dma = stm32_spi_can_dma;
19291929

19301930
pm_runtime_set_active(&pdev->dev);
1931+
pm_runtime_get_noresume(&pdev->dev);
19311932
pm_runtime_enable(&pdev->dev);
19321933

19331934
ret = spi_register_master(master);
@@ -1943,6 +1944,8 @@ static int stm32_spi_probe(struct platform_device *pdev)
19431944

19441945
err_pm_disable:
19451946
pm_runtime_disable(&pdev->dev);
1947+
pm_runtime_put_noidle(&pdev->dev);
1948+
pm_runtime_set_suspended(&pdev->dev);
19461949
err_dma_release:
19471950
if (spi->dma_tx)
19481951
dma_release_channel(spi->dma_tx);
@@ -1959,17 +1962,21 @@ static int stm32_spi_remove(struct platform_device *pdev)
19591962
struct spi_master *master = platform_get_drvdata(pdev);
19601963
struct stm32_spi *spi = spi_master_get_devdata(master);
19611964

1965+
pm_runtime_get_sync(&pdev->dev);
1966+
19621967
spi_unregister_master(master);
19631968
spi->cfg->disable(spi);
19641969

1970+
pm_runtime_disable(&pdev->dev);
1971+
pm_runtime_put_noidle(&pdev->dev);
1972+
pm_runtime_set_suspended(&pdev->dev);
19651973
if (master->dma_tx)
19661974
dma_release_channel(master->dma_tx);
19671975
if (master->dma_rx)
19681976
dma_release_channel(master->dma_rx);
19691977

19701978
clk_disable_unprepare(spi->clk);
19711979

1972-
pm_runtime_disable(&pdev->dev);
19731980

19741981
pinctrl_pm_select_sleep_state(&pdev->dev);
19751982

0 commit comments

Comments
 (0)