From: Johan Hovold Date: Wed, 29 Apr 2026 09:13:28 +0000 (+0200) Subject: spi: lantiq-ssc: switch to managed controller allocation X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=8cecd707d5358b88bcd0ae49f2f38e143d6bf7da;p=thirdparty%2Flinux.git 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 Link: https://patch.msgid.link/20260429091333.165363-15-johan@kernel.org Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c index 75b9af8cb5db7..ecae50a50b142 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 @@ err_wq_destroy: 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 = {