diff options
| author | Johan Hovold <johan@kernel.org> | 2026-04-29 11:13:24 +0200 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-05-04 22:09:25 +0900 |
| commit | 01500b2cb05ab60b6eb7b8a24a56bad45296227c (patch) | |
| tree | 52e0fac50e42820a4c9ee85b466969a2b60ada97 | |
| parent | 6bd505e710aa612cf57f7894a10d00c99d600226 (diff) | |
spi: ep93xx: switch to managed controller allocation
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>
Link: https://patch.msgid.link/20260429091333.165363-11-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | drivers/spi/spi-ep93xx.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index db50018050e5..d7e82d80c35a 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c @@ -629,7 +629,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev) if (irq < 0) return irq; - host = spi_alloc_host(&pdev->dev, sizeof(*espi)); + host = devm_spi_alloc_host(&pdev->dev, sizeof(*espi)); if (!host) return -ENOMEM; @@ -654,8 +654,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev) espi->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(espi->clk)) { dev_err(&pdev->dev, "unable to get spi clock\n"); - error = PTR_ERR(espi->clk); - goto fail_release_host; + return PTR_ERR(espi->clk); } /* @@ -666,22 +665,21 @@ static int ep93xx_spi_probe(struct platform_device *pdev) host->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); espi->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(espi->mmio)) { - error = PTR_ERR(espi->mmio); - goto fail_release_host; - } + if (IS_ERR(espi->mmio)) + return PTR_ERR(espi->mmio); + espi->sspdr_phys = res->start + SSPDR; error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt, 0, "ep93xx-spi", host); if (error) { dev_err(&pdev->dev, "failed to request irq\n"); - goto fail_release_host; + return error; } error = ep93xx_spi_setup_dma(&pdev->dev, espi); if (error == -EPROBE_DEFER) - goto fail_release_host; + return error; if (error) dev_warn(&pdev->dev, "DMA setup failed. Falling back to PIO\n"); @@ -702,8 +700,6 @@ static int ep93xx_spi_probe(struct platform_device *pdev) fail_free_dma: ep93xx_spi_release_dma(espi); -fail_release_host: - spi_controller_put(host); return error; } @@ -713,13 +709,9 @@ static void ep93xx_spi_remove(struct platform_device *pdev) struct spi_controller *host = platform_get_drvdata(pdev); struct ep93xx_spi *espi = spi_controller_get_devdata(host); - spi_controller_get(host); - spi_unregister_controller(host); ep93xx_spi_release_dma(espi); - - spi_controller_put(host); } static const struct of_device_id ep93xx_spi_of_ids[] = { |
