Skip to contentSkip to conversation

spi/qspi: cleanup qspi remova path and error check.

PATCH In review Sourav Poddar 2 participants 4 messages Nov 19, 2013 2 messages not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi/qspi: cleanup qspi remova path and error check.

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.

---
 drivers/spi/spi-ti-qspi.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
drivers/spi/spi-ti-qspi.c +18 -2
index 0b71270..033ef8d 100644
@@ -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;
 }
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · 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.

This is on Mark Brown SPI tree, branch: topic/qspi

Quoted 35 lines
---
  drivers/spi/spi-ti-qspi.c |   20 ++++++++++++++++++--
  1 files changed, 18 insertions(+), 2 deletions(-)
drivers/spi/spi-ti-qspi.c +13 -2
index 0b71270..033ef8d 100644
@@ -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;
+	}
 

drivers/spi/spi-ti-qspi.c free_master: · line 542

Quoted 10 lines
drivers/spi/spi-ti-qspi.c +5 -0
  	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;
  }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to a message not in the archive
Quoted 3 lines · 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.

What is the bug? The important bit of information is what's actually being changed.

Quoted 1 line

Also align the runtime error path check through out the code.

This should be split out.

#5 lore raw
In reply to a message not in the archive
Quoted 7 lines · Mark Brown
Quoted 3 lines · 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.

What is the bug? The important bit of information is what's actually being changed.

pm_runtime api is not used to properly disable the PM part. spi_unregister_master(qspi->master) shows a NULL pointer dereference.

Quoted 1 line
Quoted 1 line

Also align the runtime error path check through out the code.

Ok.

Quoted 1 line

This should be split out.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html