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

* Re: [PATCH] spi/qspi: cleanup qspi remova path and error check.
       [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
  1 sibling, 0 replies; 4+ messages in thread
From: Sourav Poddar @ 2013-11-19 11:00 UTC (permalink / raw)
  To: Sourav Poddar
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-spi-u79uwXL29TY76Z2rM5mHXA

On Tuesday 19 November 2013 04:28 PM, Sourav Poddar wrote:
> 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>
This is on Mark Brown SPI tree, branch: topic/qspi
> ---
>   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;
>   }
>

--
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	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi/qspi: cleanup qspi remova path and error check.
       [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>
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2013-11-19 11:31 UTC (permalink / raw)
  To: Sourav Poddar; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

On Tue, Nov 19, 2013 at 04:28:23PM +0530, Sourav Poddar wrote:
> 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.

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

This should be split out.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] spi/qspi: cleanup qspi remova path and error check.
       [not found]     ` <20131119113125.GZ2674-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2013-11-19 11:50       ` Sourav Poddar
  0 siblings, 0 replies; 4+ messages in thread
From: Sourav Poddar @ 2013-11-19 11:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

On Tuesday 19 November 2013 05:01 PM, Mark Brown wrote:
> On Tue, Nov 19, 2013 at 04:28:23PM +0530, Sourav Poddar wrote:
>> 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.
>> Also align the runtime error path check through out the code.
Ok.
> This should be split out.

--
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	[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.