All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi/qspi: cleanup qspi remova path and error check.
@ 2013-11-19 10:58 Sourav Poddar
       [not found] ` <1384858703-30938-1-git-send-email-sourav.poddar-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Sourav Poddar @ 2013-11-19 10:58 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Sourav Poddar

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.
Also align the runtime error path check through out the code.

Tested on DRA7 board.

Signed-off-by: Sourav Poddar <sourav.poddar-l0cyMroinI0@public.gmane.org>
---
 drivers/spi/spi-ti-qspi.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index 0b71270..033ef8d 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -161,7 +161,7 @@ static int ti_qspi_setup(struct spi_device *spi)
 			qspi->spi_max_frequency, clk_div);
 
 	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret) {
+	if (ret < 0) {
 		dev_err(qspi->dev, "pm_runtime_get_sync() failed\n");
 		return ret;
 	}
@@ -517,10 +517,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;
 }
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-19 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-19 10:58 [PATCH] spi/qspi: cleanup qspi remova path and error check Sourav Poddar
     [not found] ` <1384858703-30938-1-git-send-email-sourav.poddar-l0cyMroinI0@public.gmane.org>
2013-11-19 11:00   ` Sourav Poddar
2013-11-19 11:31   ` Mark Brown
     [not found]     ` <20131119113125.GZ2674-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-19 11:50       ` Sourav Poddar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.