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>
This commit is contained in:
Johan Hovold
2026-04-29 11:13:24 +02:00
committed by Mark Brown
parent 6bd505e710
commit 01500b2cb0

View File

@@ -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[] = {