[PATCH 14/19] spi: lantiq-ssc: switch to managed controller allocation

From: Johan Hovold

Date: Wed Apr 29 2026 - 05:19:27 EST


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@xxxxxxxxxx>
---
drivers/spi/spi-lantiq-ssc.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c
index 75b9af8cb5db..ecae50a50b14 100644
--- a/drivers/spi/spi-lantiq-ssc.c
+++ b/drivers/spi/spi-lantiq-ssc.c
@@ -913,7 +913,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev)

hwcfg = of_device_get_match_data(dev);

- host = spi_alloc_host(dev, sizeof(struct lantiq_ssc_spi));
+ host = devm_spi_alloc_host(dev, sizeof(struct lantiq_ssc_spi));
if (!host)
return -ENOMEM;

@@ -923,20 +923,16 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
spi->hwcfg = hwcfg;
platform_set_drvdata(pdev, spi);
spi->regbase = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(spi->regbase)) {
- err = PTR_ERR(spi->regbase);
- goto err_host_put;
- }
+ if (IS_ERR(spi->regbase))
+ return PTR_ERR(spi->regbase);

err = hwcfg->cfg_irq(pdev, spi);
if (err)
- goto err_host_put;
+ return err;

spi->spi_clk = devm_clk_get_enabled(dev, "gate");
- if (IS_ERR(spi->spi_clk)) {
- err = PTR_ERR(spi->spi_clk);
- goto err_host_put;
- }
+ if (IS_ERR(spi->spi_clk))
+ return PTR_ERR(spi->spi_clk);

/*
* Use the old clk_get_fpi() function on Lantiq platform, till it
@@ -947,10 +943,8 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
#else
spi->fpi_clk = clk_get(dev, "freq");
#endif
- if (IS_ERR(spi->fpi_clk)) {
- err = PTR_ERR(spi->fpi_clk);
- goto err_host_put;
- }
+ if (IS_ERR(spi->fpi_clk))
+ return PTR_ERR(spi->fpi_clk);

num_cs = 8;
of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs);
@@ -1006,8 +1000,6 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
destroy_workqueue(spi->wq);
err_clk_put:
clk_put(spi->fpi_clk);
-err_host_put:
- spi_controller_put(host);

return err;
}
@@ -1016,8 +1008,6 @@ static void lantiq_ssc_remove(struct platform_device *pdev)
{
struct lantiq_ssc_spi *spi = platform_get_drvdata(pdev);

- spi_controller_get(spi->host);
-
spi_unregister_controller(spi->host);

lantiq_ssc_writel(spi, 0, LTQ_SPI_IRNEN);
@@ -1028,8 +1018,6 @@ static void lantiq_ssc_remove(struct platform_device *pdev)

destroy_workqueue(spi->wq);
clk_put(spi->fpi_clk);
-
- spi_controller_put(spi->host);
}

static struct platform_driver lantiq_ssc_driver = {
--
2.53.0