From: Johan Hovold Date: Wed, 29 Apr 2026 09:13:25 +0000 (+0200) Subject: spi: fsl: switch to managed controller allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6afe041c2ce9068b2b6c64eddb5537911752050c;p=thirdparty%2Fkernel%2Flinux.git spi: fsl: 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-12-johan@kernel.org Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 1252c41c206f8..e45816ef7b656 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -535,7 +535,7 @@ static struct spi_controller *fsl_spi_probe(struct device *dev, u32 regval; int ret = 0; - host = spi_alloc_host(dev, sizeof(struct mpc8xxx_spi)); + host = devm_spi_alloc_host(dev, sizeof(struct mpc8xxx_spi)); if (host == NULL) { ret = -ENOMEM; goto err; @@ -559,7 +559,7 @@ static struct spi_controller *fsl_spi_probe(struct device *dev, ret = fsl_spi_cpm_init(mpc8xxx_spi); if (ret) - goto err_cpm_init; + goto err; mpc8xxx_spi->reg_base = devm_ioremap_resource(dev, mem); if (IS_ERR(mpc8xxx_spi->reg_base)) { @@ -625,8 +625,6 @@ static struct spi_controller *fsl_spi_probe(struct device *dev, err_probe: fsl_spi_cpm_free(mpc8xxx_spi); -err_cpm_init: - spi_controller_put(host); err: return ERR_PTR(ret); } @@ -705,13 +703,9 @@ static void of_fsl_spi_remove(struct platform_device *ofdev) struct spi_controller *host = platform_get_drvdata(ofdev); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host); - spi_controller_get(host); - spi_unregister_controller(host); fsl_spi_cpm_free(mpc8xxx_spi); - - spi_controller_put(host); } static struct platform_driver of_fsl_spi_driver = { @@ -757,13 +751,9 @@ static void plat_mpc8xxx_spi_remove(struct platform_device *pdev) struct spi_controller *host = platform_get_drvdata(pdev); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host); - spi_controller_get(host); - spi_unregister_controller(host); fsl_spi_cpm_free(mpc8xxx_spi); - - spi_controller_put(host); } MODULE_ALIAS("platform:mpc8xxx_spi");