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 16/20] spi: tegra20-sflash: switch to managed controller allocation
Date: Tue, 5 May 2026 09:29:05 +0200 [thread overview]
Message-ID: <20260505072909.618363-17-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-tegra20-sflash.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index 9256729f2d49..2caa33f0a52c 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -427,11 +427,9 @@ static int tegra_sflash_probe(struct platform_device *pdev)
return -ENODEV;
}
- host = spi_alloc_host(&pdev->dev, sizeof(*tsd));
- if (!host) {
- dev_err(&pdev->dev, "host allocation failed\n");
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*tsd));
+ if (!host)
return -ENOMEM;
- }
/* the spi->mode bits understood by this driver: */
host->mode_bits = SPI_CPOL | SPI_CPHA;
@@ -450,14 +448,13 @@ static int tegra_sflash_probe(struct platform_device *pdev)
host->max_speed_hz = 25000000; /* 25MHz */
tsd->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(tsd->base)) {
- ret = PTR_ERR(tsd->base);
- goto exit_free_host;
- }
+ if (IS_ERR(tsd->base))
+ return PTR_ERR(tsd->base);
ret = platform_get_irq(pdev, 0);
if (ret < 0)
- goto exit_free_host;
+ return ret;
+
tsd->irq = ret;
ret = request_irq(tsd->irq, tegra_sflash_isr, 0,
@@ -465,7 +462,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
tsd->irq);
- goto exit_free_host;
+ return ret;
}
tsd->clk = devm_clk_get(&pdev->dev, NULL);
@@ -518,8 +515,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
tegra_sflash_runtime_suspend(&pdev->dev);
exit_free_irq:
free_irq(tsd->irq, tsd);
-exit_free_host:
- spi_controller_put(host);
+
return ret;
}
@@ -528,8 +524,6 @@ static void tegra_sflash_remove(struct platform_device *pdev)
struct spi_controller *host = platform_get_drvdata(pdev);
struct tegra_sflash_data *tsd = spi_controller_get_devdata(host);
- spi_controller_get(host);
-
spi_unregister_controller(host);
free_irq(tsd->irq, tsd);
@@ -537,8 +531,6 @@ static void tegra_sflash_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
tegra_sflash_runtime_suspend(&pdev->dev);
-
- spi_controller_put(host);
}
#ifdef CONFIG_PM_SLEEP
--
2.53.0
next prev parent reply other threads:[~2026-05-05 7:29 UTC|newest]
Thread overview: 22+ 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 ` Johan Hovold [this message]
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 ` [PATCH 19/20] spi: uniphier: switch to managed controller allocation Johan Hovold
2026-05-05 7:29 ` [PATCH 20/20] spi: zync-qspi: " Johan Hovold
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-17-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox