summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2026-05-05 10:29:02 +0300
committerMark Brown <broonie@kernel.org>2026-05-11 03:55:49 +0300
commit9864636b1cd95dd2b3c702a2ff22e9d169f6523a (patch)
treef81f65cab81cd81b67283ca8652b692bbe6303bc
parent02b36d644ded410e8f70cdd78d0c5d523252bafd (diff)
downloadlinux-9864636b1cd95dd2b3c702a2ff22e9d169f6523a.tar.xz
spi: sun6i: 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/20260505072909.618363-14-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-sun6i.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index 5ac73d324d06..4631e9c7ca1d 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -633,7 +633,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
struct resource *mem;
int ret = 0, irq;
- host = spi_alloc_host(&pdev->dev, sizeof(struct sun6i_spi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(struct sun6i_spi));
if (!host) {
dev_err(&pdev->dev, "Unable to allocate SPI Host\n");
return -ENOMEM;
@@ -643,22 +643,18 @@ static int sun6i_spi_probe(struct platform_device *pdev)
sspi = spi_controller_get_devdata(host);
sspi->base_addr = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
- if (IS_ERR(sspi->base_addr)) {
- ret = PTR_ERR(sspi->base_addr);
- goto err_free_host;
- }
+ if (IS_ERR(sspi->base_addr))
+ return PTR_ERR(sspi->base_addr);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = -ENXIO;
- goto err_free_host;
- }
+ if (irq < 0)
+ return -ENXIO;
ret = devm_request_irq(&pdev->dev, irq, sun6i_spi_handler,
0, "sun6i-spi", sspi);
if (ret) {
dev_err(&pdev->dev, "Cannot request IRQ\n");
- goto err_free_host;
+ return ret;
}
sspi->host = host;
@@ -679,15 +675,13 @@ static int sun6i_spi_probe(struct platform_device *pdev)
sspi->hclk = devm_clk_get(&pdev->dev, "ahb");
if (IS_ERR(sspi->hclk)) {
dev_err(&pdev->dev, "Unable to acquire AHB clock\n");
- ret = PTR_ERR(sspi->hclk);
- goto err_free_host;
+ return PTR_ERR(sspi->hclk);
}
sspi->mclk = devm_clk_get(&pdev->dev, "mod");
if (IS_ERR(sspi->mclk)) {
dev_err(&pdev->dev, "Unable to acquire module clock\n");
- ret = PTR_ERR(sspi->mclk);
- goto err_free_host;
+ return PTR_ERR(sspi->mclk);
}
init_completion(&sspi->done);
@@ -696,17 +690,14 @@ static int sun6i_spi_probe(struct platform_device *pdev)
sspi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(sspi->rstc)) {
dev_err(&pdev->dev, "Couldn't get reset controller\n");
- ret = PTR_ERR(sspi->rstc);
- goto err_free_host;
+ return PTR_ERR(sspi->rstc);
}
host->dma_tx = dma_request_chan(&pdev->dev, "tx");
if (IS_ERR(host->dma_tx)) {
/* Check tx to see if we need defer probing driver */
- if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
- goto err_free_host;
- }
+ if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
dev_warn(&pdev->dev, "Failed to request TX DMA channel\n");
host->dma_tx = NULL;
}
@@ -759,8 +750,7 @@ err_free_dma_rx:
err_free_dma_tx:
if (host->dma_tx)
dma_release_channel(host->dma_tx);
-err_free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -768,8 +758,6 @@ static void sun6i_spi_remove(struct platform_device *pdev)
{
struct spi_controller *host = platform_get_drvdata(pdev);
- spi_controller_get(host);
-
spi_unregister_controller(host);
pm_runtime_force_suspend(&pdev->dev);
@@ -778,8 +766,6 @@ static void sun6i_spi_remove(struct platform_device *pdev)
dma_release_channel(host->dma_tx);
if (host->dma_rx)
dma_release_channel(host->dma_rx);
-
- spi_controller_put(host);
}
static const struct sun6i_spi_cfg sun6i_a31_spi_cfg = {