Messages in this thread Patch in this message |  | | From | Johan Hovold <> | | Subject | [PATCH 08/19] spi: coldfire-qspi: switch to managed controller allocation | | Date | Wed, 29 Apr 2026 11:13:22 +0200 |
| |
Switch to device managed controller allocation to simplify error handling and to avoid having to take another reference during deregistration.
Signed-off-by: Johan Hovold <johan@kernel.org> --- drivers/spi/spi-coldfire-qspi.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index b45f44de85dc..3b175c1da36b 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c @@ -353,39 +353,33 @@ static int mcfqspi_probe(struct platform_device *pdev) return -EINVAL; } - host = spi_alloc_host(&pdev->dev, sizeof(*mcfqspi)); - if (host == NULL) { - dev_dbg(&pdev->dev, "spi_alloc_host failed\n"); + host = devm_spi_alloc_host(&pdev->dev, sizeof(*mcfqspi)); + if (host == NULL) return -ENOMEM; - } mcfqspi = spi_controller_get_devdata(host); mcfqspi->iobase = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(mcfqspi->iobase)) { - status = PTR_ERR(mcfqspi->iobase); - goto fail0; - } + if (IS_ERR(mcfqspi->iobase)) + return PTR_ERR(mcfqspi->iobase); mcfqspi->irq = platform_get_irq(pdev, 0); if (mcfqspi->irq < 0) { dev_dbg(&pdev->dev, "platform_get_irq failed\n"); - status = -ENXIO; - goto fail0; + return -ENXIO; } status = devm_request_irq(&pdev->dev, mcfqspi->irq, mcfqspi_irq_handler, 0, pdev->name, mcfqspi); if (status) { dev_dbg(&pdev->dev, "request_irq failed\n"); - goto fail0; + return status; } mcfqspi->clk = devm_clk_get_enabled(&pdev->dev, "qspi_clk"); if (IS_ERR(mcfqspi->clk)) { dev_dbg(&pdev->dev, "clk_get failed\n"); - status = PTR_ERR(mcfqspi->clk); - goto fail0; + return PTR_ERR(mcfqspi->clk); } host->bus_num = pdata->bus_num; @@ -395,7 +389,7 @@ static int mcfqspi_probe(struct platform_device *pdev) status = mcfqspi_cs_setup(mcfqspi); if (status) { dev_dbg(&pdev->dev, "error initializing cs_control\n"); - goto fail0; + return status; } init_waitqueue_head(&mcfqspi->waitq); @@ -423,8 +417,6 @@ static int mcfqspi_probe(struct platform_device *pdev) fail1: pm_runtime_disable(&pdev->dev); mcfqspi_cs_teardown(mcfqspi); -fail0: - spi_controller_put(host); dev_dbg(&pdev->dev, "Coldfire QSPI probe failed\n"); @@ -436,8 +428,6 @@ static void mcfqspi_remove(struct platform_device *pdev) struct spi_controller *host = platform_get_drvdata(pdev); struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); - spi_controller_get(host); - spi_unregister_controller(host); pm_runtime_disable(&pdev->dev); @@ -445,8 +435,6 @@ static void mcfqspi_remove(struct platform_device *pdev) mcfqspi_wr_qmr(mcfqspi, MCFQSPI_QMR_MSTR); mcfqspi_cs_teardown(mcfqspi); - - spi_controller_put(host); } #ifdef CONFIG_PM_SLEEP -- 2.53.0
|  |