forked from Minki/linux
spi: stm32-qspi: Fix error path in case of -EPROBE_DEFER
In case of -EPROBE_DEFER, stm32_qspi_release() was called
in any case which unregistered driver from pm_runtime framework
even if it has not been registered yet to it. This leads to:
stm32-qspi 58003000.spi: can't setup spi0.0, status -13
spi_master spi0: spi_device register error /soc/spi@58003000/mx66l51235l@0
spi_master spi0: Failed to create SPI device for /soc/spi@58003000/mx66l51235l@0
stm32-qspi 58003000.spi: can't setup spi0.1, status -13
spi_master spi0: spi_device register error /soc/spi@58003000/mx66l51235l@1
spi_master spi0: Failed to create SPI device for /soc/spi@58003000/mx66l51235l@1
On v5.7 kernel,this issue was not "visible", qspi driver was probed
successfully.
Fixes: 9d282c17b0
("spi: stm32-qspi: Add pm_runtime support")
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Link: https://lore.kernel.org/r/20200616113035.4514-1-patrice.chotard@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
27784a256c
commit
35700e221b
@ -553,20 +553,6 @@ static const struct spi_controller_mem_ops stm32_qspi_mem_ops = {
|
||||
.exec_op = stm32_qspi_exec_op,
|
||||
};
|
||||
|
||||
static void stm32_qspi_release(struct stm32_qspi *qspi)
|
||||
{
|
||||
pm_runtime_get_sync(qspi->dev);
|
||||
/* disable qspi */
|
||||
writel_relaxed(0, qspi->io_base + QSPI_CR);
|
||||
stm32_qspi_dma_free(qspi);
|
||||
mutex_destroy(&qspi->lock);
|
||||
pm_runtime_put_noidle(qspi->dev);
|
||||
pm_runtime_disable(qspi->dev);
|
||||
pm_runtime_set_suspended(qspi->dev);
|
||||
pm_runtime_dont_use_autosuspend(qspi->dev);
|
||||
clk_disable_unprepare(qspi->clk);
|
||||
}
|
||||
|
||||
static int stm32_qspi_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@ -642,7 +628,7 @@ static int stm32_qspi_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(rstc)) {
|
||||
ret = PTR_ERR(rstc);
|
||||
if (ret == -EPROBE_DEFER)
|
||||
goto err_qspi_release;
|
||||
goto err_clk_disable;
|
||||
} else {
|
||||
reset_control_assert(rstc);
|
||||
udelay(2);
|
||||
@ -653,7 +639,7 @@ static int stm32_qspi_probe(struct platform_device *pdev)
|
||||
platform_set_drvdata(pdev, qspi);
|
||||
ret = stm32_qspi_dma_setup(qspi);
|
||||
if (ret)
|
||||
goto err_qspi_release;
|
||||
goto err_dma_free;
|
||||
|
||||
mutex_init(&qspi->lock);
|
||||
|
||||
@ -673,15 +659,26 @@ static int stm32_qspi_probe(struct platform_device *pdev)
|
||||
|
||||
ret = devm_spi_register_master(dev, ctrl);
|
||||
if (ret)
|
||||
goto err_qspi_release;
|
||||
goto err_pm_runtime_free;
|
||||
|
||||
pm_runtime_mark_last_busy(dev);
|
||||
pm_runtime_put_autosuspend(dev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_qspi_release:
|
||||
stm32_qspi_release(qspi);
|
||||
err_pm_runtime_free:
|
||||
pm_runtime_get_sync(qspi->dev);
|
||||
/* disable qspi */
|
||||
writel_relaxed(0, qspi->io_base + QSPI_CR);
|
||||
mutex_destroy(&qspi->lock);
|
||||
pm_runtime_put_noidle(qspi->dev);
|
||||
pm_runtime_disable(qspi->dev);
|
||||
pm_runtime_set_suspended(qspi->dev);
|
||||
pm_runtime_dont_use_autosuspend(qspi->dev);
|
||||
err_dma_free:
|
||||
stm32_qspi_dma_free(qspi);
|
||||
err_clk_disable:
|
||||
clk_disable_unprepare(qspi->clk);
|
||||
err_master_put:
|
||||
spi_master_put(qspi->ctrl);
|
||||
|
||||
@ -692,7 +689,16 @@ static int stm32_qspi_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct stm32_qspi *qspi = platform_get_drvdata(pdev);
|
||||
|
||||
stm32_qspi_release(qspi);
|
||||
pm_runtime_get_sync(qspi->dev);
|
||||
/* disable qspi */
|
||||
writel_relaxed(0, qspi->io_base + QSPI_CR);
|
||||
stm32_qspi_dma_free(qspi);
|
||||
mutex_destroy(&qspi->lock);
|
||||
pm_runtime_put_noidle(qspi->dev);
|
||||
pm_runtime_disable(qspi->dev);
|
||||
pm_runtime_set_suspended(qspi->dev);
|
||||
pm_runtime_dont_use_autosuspend(qspi->dev);
|
||||
clk_disable_unprepare(qspi->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user