aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/atmel-quadspi.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index f480c7ae93fa..7e05b48dbd71 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -672,18 +672,28 @@ static int atmel_qspi_remove(struct platform_device *pdev)
struct atmel_qspi *aq = spi_controller_get_devdata(ctrl);
int ret;
- ret = pm_runtime_resume_and_get(&pdev->dev);
- if (ret < 0)
- return ret;
-
spi_unregister_controller(ctrl);
- atmel_qspi_write(QSPI_CR_QSPIDIS, aq, QSPI_CR);
+
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret >= 0) {
+ atmel_qspi_write(QSPI_CR_QSPIDIS, aq, QSPI_CR);
+ clk_disable(aq->qspick);
+ clk_disable(aq->pclk);
+ } else {
+ /*
+ * atmel_qspi_runtime_{suspend,resume} just disable and enable
+ * the two clks respectively. So after resume failed these are
+ * off, and we skip hardware access and disabling these clks again.
+ */
+ dev_warn(&pdev->dev, "Failed to resume device on remove\n");
+ }
+
+ clk_unprepare(aq->qspick);
+ clk_unprepare(aq->pclk);
pm_runtime_disable(&pdev->dev);
pm_runtime_put_noidle(&pdev->dev);
- clk_disable_unprepare(aq->qspick);
- clk_disable_unprepare(aq->pclk);
return 0;
}