spi: lantiq-ssc: 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/20260429091333.165363-15-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Johan Hovold
2026-04-29 11:13:28 +02:00
committed by Mark Brown
parent 8015cac85a
commit 8cecd707d5

View File

@@ -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 = {