linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-fsl-qspi: call spi_unregister_controller
@ 2019-03-07 10:30 Volker Haspel
  2019-03-11 17:03 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Volker Haspel @ 2019-03-07 10:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-spi, Han Xu, Mark Brown, john.ogness, volker.haspel

The driver does not clearly unregister the spi controller.
Therefore calling an unbind and bind again will end up in a
Kernel crash.
Each driver who calls spi_register_controller() in the probe function
has to call spi_unregister_controller() too.

Signed-off-by: Volker Haspel <volker.haspel@linutronix.de>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 drivers/spi/spi-fsl-qspi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 6a713f78a62e..373c4a82e8e3 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -248,6 +248,7 @@ struct fsl_qspi {
 	struct mutex lock;
 	struct pm_qos_request pm_qos_req;
 	int selected;
+	struct spi_controller *ctlr;
 };
 
 static inline int needs_swap_endian(struct fsl_qspi *q)
@@ -812,6 +813,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 			  SPI_TX_DUAL | SPI_TX_QUAD;
 
 	q = spi_controller_get_devdata(ctlr);
+	q->ctlr = ctlr;
 	q->dev = dev;
 	q->devtype_data = of_device_get_match_data(dev);
 	if (!q->devtype_data) {
@@ -912,6 +914,7 @@ static int fsl_qspi_remove(struct platform_device *pdev)
 	fsl_qspi_clk_disable_unprep(q);
 
 	mutex_destroy(&q->lock);
+	spi_unregister_controller(q->ctlr);
 
 	return 0;
 }
-- 
2.11.0


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

* Re: [PATCH] spi: spi-fsl-qspi: call spi_unregister_controller
  2019-03-07 10:30 [PATCH] spi: spi-fsl-qspi: call spi_unregister_controller Volker Haspel
@ 2019-03-11 17:03 ` Mark Brown
  2019-03-12  8:43   ` Volker Haspel
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2019-03-11 17:03 UTC (permalink / raw)
  To: Volker Haspel; +Cc: linux-kernel, linux-spi, Han Xu, john.ogness

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

On Thu, Mar 07, 2019 at 11:30:08AM +0100, Volker Haspel wrote:
> The driver does not clearly unregister the spi controller.
> Therefore calling an unbind and bind again will end up in a
> Kernel crash.
> Each driver who calls spi_register_controller() in the probe function
> has to call spi_unregister_controller() too.

Why not change it to use devm?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] spi: spi-fsl-qspi: call spi_unregister_controller
  2019-03-11 17:03 ` Mark Brown
@ 2019-03-12  8:43   ` Volker Haspel
  0 siblings, 0 replies; 3+ messages in thread
From: Volker Haspel @ 2019-03-12  8:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, linux-spi, Han Xu, john.ogness

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

On Mon, 11 Mar 2019 17:03:34 +0000
Mark Brown <broonie@kernel.org> wrote:

> On Thu, Mar 07, 2019 at 11:30:08AM +0100, Volker Haspel wrote:
> > The driver does not clearly unregister the spi controller.
> > Therefore calling an unbind and bind again will end up in a
> > Kernel crash.
> > Each driver who calls spi_register_controller() in the probe function
> > has to call spi_unregister_controller() too.  
> 
> Why not change it to use devm?

Hi Mark,

I agree, this is a much nicer solution! I will test it and send a v2.

Thanks

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-03-12  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:30 [PATCH] spi: spi-fsl-qspi: call spi_unregister_controller Volker Haspel
2019-03-11 17:03 ` Mark Brown
2019-03-12  8:43   ` Volker Haspel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).