]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: fsl: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Wed, 29 Apr 2026 09:13:25 +0000 (11:13 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 4 May 2026 13:09:26 +0000 (22:09 +0900)
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-12-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-fsl-spi.c

index 1252c41c206f870569f56866e81c04442c5a176c..e45816ef7b6567fd1b00512c84f3a77332a04271 100644 (file)
@@ -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");