Skip to content

Commit 4f12ee0

Browse files
committed
spi: cadence-quadspi: Probe and unbind fixes
Several fixes from Johan for probe failure and unbind issues in the cadence-quadspi driver.
2 parents 8d0189c + 5e8bb0c commit 4f12ee0

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

drivers/spi/spi-cadence-quadspi.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,14 +1860,10 @@ static int cqspi_probe(struct platform_device *pdev)
18601860
if (irq < 0)
18611861
return -ENXIO;
18621862

1863-
ret = pm_runtime_set_active(dev);
1864-
if (ret)
1865-
return ret;
1866-
18671863
ret = clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks);
18681864
if (ret) {
18691865
dev_err(dev, "Cannot enable QSPI clocks.\n");
1870-
goto disable_rpm;
1866+
return ret;
18711867
}
18721868

18731869
/* Obtain QSPI reset control */
@@ -1962,10 +1958,11 @@ static int cqspi_probe(struct platform_device *pdev)
19621958
cqspi->sclk = 0;
19631959

19641960
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
1965-
pm_runtime_enable(dev);
19661961
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
19671962
pm_runtime_use_autosuspend(dev);
19681963
pm_runtime_get_noresume(dev);
1964+
pm_runtime_set_active(dev);
1965+
pm_runtime_enable(dev);
19691966
}
19701967

19711968
host->num_chipselect = cqspi->num_chipselect;
@@ -1977,7 +1974,7 @@ static int cqspi_probe(struct platform_device *pdev)
19771974
ret = cqspi_request_mmap_dma(cqspi);
19781975
if (ret == -EPROBE_DEFER) {
19791976
dev_err_probe(&pdev->dev, ret, "Failed to request mmap DMA\n");
1980-
goto disable_controller;
1977+
goto disable_rpm;
19811978
}
19821979
}
19831980

@@ -1995,14 +1992,16 @@ static int cqspi_probe(struct platform_device *pdev)
19951992
release_dma_chan:
19961993
if (cqspi->rx_chan)
19971994
dma_release_channel(cqspi->rx_chan);
1998-
disable_controller:
1999-
cqspi_controller_enable(cqspi, 0);
2000-
disable_clks:
2001-
if (pm_runtime_get_sync(&pdev->dev) >= 0)
2002-
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
20031995
disable_rpm:
2004-
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
1996+
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
20051997
pm_runtime_disable(dev);
1998+
pm_runtime_set_suspended(dev);
1999+
pm_runtime_put_noidle(dev);
2000+
pm_runtime_dont_use_autosuspend(dev);
2001+
}
2002+
cqspi_controller_enable(cqspi, 0);
2003+
disable_clks:
2004+
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
20062005

20072006
return ret;
20082007
}
@@ -2026,18 +2025,19 @@ static void cqspi_remove(struct platform_device *pdev)
20262025
if (cqspi->rx_chan)
20272026
dma_release_channel(cqspi->rx_chan);
20282027

2029-
cqspi_controller_enable(cqspi, 0);
2030-
2031-
20322028
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
20332029
ret = pm_runtime_get_sync(&pdev->dev);
20342030

2035-
if (ret >= 0)
2031+
if (ret >= 0) {
2032+
cqspi_controller_enable(cqspi, 0);
20362033
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
2034+
}
20372035

20382036
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
2039-
pm_runtime_put_sync(&pdev->dev);
20402037
pm_runtime_disable(&pdev->dev);
2038+
pm_runtime_set_suspended(&pdev->dev);
2039+
pm_runtime_put_noidle(&pdev->dev);
2040+
pm_runtime_dont_use_autosuspend(&pdev->dev);
20412041
}
20422042
}
20432043

0 commit comments

Comments
 (0)