From cbcabb7a300bf5ab868c632048889a933e7cdae5 Mon Sep 17 00:00:00 2001 From: Sourav Poddar Date: Tue, 19 Nov 2013 18:37:16 +0530 Subject: spi/qspi: Fix qspi remove path. There is a bug in qspi removal path, as a result of which qspi cannot be removed when used as a module. The patch solves the bug and qspi can be removed cleanly. The bugs fixed are: -pm_runtime used around register access. - pm_runtime_disable need to be done before removal. - spi_unregister_master need to be called to unregister the spi device. Tested on DRA7 board. Signed-off-by: Sourav Poddar Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c index f3c3c3f..4396bd4 100644 --- a/drivers/spi/spi-ti-qspi.c +++ b/drivers/spi/spi-ti-qspi.c @@ -516,10 +516,26 @@ free_master: static int ti_qspi_remove(struct platform_device *pdev) { - struct ti_qspi *qspi = platform_get_drvdata(pdev); + struct spi_master *master; + struct ti_qspi *qspi; + int ret; + + master = platform_get_drvdata(pdev); + qspi = spi_master_get_devdata(master); + + ret = pm_runtime_get_sync(qspi->dev); + if (ret < 0) { + dev_err(qspi->dev, "pm_runtime_get_sync() failed\n"); + return ret; + } ti_qspi_write(qspi, QSPI_WC_INT_DISABLE, QSPI_INTR_ENABLE_CLEAR_REG); + pm_runtime_put(qspi->dev); + pm_runtime_disable(&pdev->dev); + + spi_unregister_master(master); + return 0; } -- cgit v0.10.2