From: Johan Hovold <johan@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Linus Walleij <linusw@kernel.org>,
Masahisa Kojima <kojima.masahisa@socionext.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
Laxman Dewangan <ldewangan@nvidia.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 19/20] spi: uniphier: switch to managed controller allocation
Date: Tue, 5 May 2026 09:29:08 +0200 [thread overview]
Message-ID: <20260505072909.618363-20-johan@kernel.org> (raw)
In-Reply-To: <20260505072909.618363-1-johan@kernel.org>
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-uniphier.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c
index eac6c3e8908b..5f0abc59b716 100644
--- a/drivers/spi/spi-uniphier.c
+++ b/drivers/spi/spi-uniphier.c
@@ -649,7 +649,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
int irq;
int ret;
- host = spi_alloc_host(&pdev->dev, sizeof(*priv));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*priv));
if (!host)
return -ENOMEM;
@@ -660,30 +660,26 @@ static int uniphier_spi_probe(struct platform_device *pdev)
priv->is_save_param = false;
priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
- if (IS_ERR(priv->base)) {
- ret = PTR_ERR(priv->base);
- goto out_host_put;
- }
+ if (IS_ERR(priv->base))
+ return PTR_ERR(priv->base);
+
priv->base_dma_addr = res->start;
priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
- ret = PTR_ERR(priv->clk);
- goto out_host_put;
+ return PTR_ERR(priv->clk);
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- ret = irq;
- goto out_host_put;
- }
+ if (irq < 0)
+ return irq;
ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
0, "uniphier-spi", priv);
if (ret) {
dev_err(&pdev->dev, "failed to request IRQ\n");
- goto out_host_put;
+ return ret;
}
init_completion(&priv->xfer_done);
@@ -710,10 +706,9 @@ static int uniphier_spi_probe(struct platform_device *pdev)
host->dma_tx = dma_request_chan(&pdev->dev, "tx");
if (IS_ERR_OR_NULL(host->dma_tx)) {
- if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
- goto out_host_put;
- }
+ if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
host->dma_tx = NULL;
dma_tx_burst = INT_MAX;
} else {
@@ -762,8 +757,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
host->dma_tx = NULL;
}
-out_host_put:
- spi_controller_put(host);
return ret;
}
@@ -771,16 +764,12 @@ static void uniphier_spi_remove(struct platform_device *pdev)
{
struct spi_controller *host = platform_get_drvdata(pdev);
- spi_controller_get(host);
-
spi_unregister_controller(host);
if (host->dma_tx)
dma_release_channel(host->dma_tx);
if (host->dma_rx)
dma_release_channel(host->dma_rx);
-
- spi_controller_put(host);
}
static const struct of_device_id uniphier_spi_match[] = {
--
2.53.0
next prev parent reply other threads:[~2026-05-05 7:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 7:28 [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Johan Hovold
2026-05-05 7:28 ` [PATCH 01/20] spi: pic32: switch to managed controller allocation Johan Hovold
2026-05-05 7:28 ` [PATCH 02/20] spi: pic32-sqi: " Johan Hovold
2026-05-05 7:28 ` [PATCH 03/20] spi: pl022: " Johan Hovold
2026-05-05 9:12 ` Linus Walleij
2026-05-05 7:28 ` [PATCH 04/20] spi: qup: " Johan Hovold
2026-05-05 7:28 ` [PATCH 05/20] spi: rspi: " Johan Hovold
2026-05-05 7:28 ` [PATCH 06/20] spi: sh-hspi: " Johan Hovold
2026-05-05 7:28 ` [PATCH 07/20] spi: sh-msiof: " Johan Hovold
2026-05-05 7:28 ` [PATCH 08/20] spi: sifive: " Johan Hovold
2026-05-05 7:28 ` [PATCH 09/20] spi: slave-mt27xx: " Johan Hovold
2026-05-05 7:28 ` [PATCH 10/20] spi: sprd: " Johan Hovold
2026-05-05 7:29 ` [PATCH 11/20] spi: st-ssc4: " Johan Hovold
2026-05-05 7:29 ` [PATCH 12/20] spi: sun4i: " Johan Hovold
2026-05-05 7:29 ` [PATCH 13/20] spi: sun6i: " Johan Hovold
2026-05-05 7:29 ` [PATCH 14/20] spi: syncuacer: " Johan Hovold
2026-05-05 7:29 ` [PATCH 15/20] spi: tegra114: " Johan Hovold
2026-05-05 7:29 ` [PATCH 16/20] spi: tegra20-sflash: " Johan Hovold
2026-05-05 7:29 ` [PATCH 17/20] spi: ti-qspi: " Johan Hovold
2026-05-05 7:29 ` [PATCH 18/20] spi: ti-qspi: cleanup registration error path Johan Hovold
2026-05-05 7:29 ` Johan Hovold [this message]
2026-05-05 7:29 ` [PATCH 20/20] spi: zync-qspi: switch to managed controller allocation Johan Hovold
2026-05-11 0:56 ` [PATCH 00/20] spi: switch to managed controller allocation (part 2/3) Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260505072909.618363-20-johan@kernel.org \
--to=johan@kernel.org \
--cc=broonie@kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=kojima.masahisa@socionext.com \
--cc=ldewangan@nvidia.com \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.