lkml.org 
[lkml]   [2026]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 10/19] spi: ep93xx: switch to managed controller allocation
Date
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-ep93xx.c | 22 +++++++---------------
1 file 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[] = {
--
2.53.0

\
 
 \ /
  Last update: 2026-04-29 11:15    [W:0.154 / U:15.027 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog