Message ID | 20190307103008.19841-1-volker.haspel@linutronix.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | spi: spi-fsl-qspi: call spi_unregister_controller | expand |
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?
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
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; }