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 <johan@kernel.org>
Link: https://patch.msgid.link/20260429091333.165363-12-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Johan Hovold 2026-04-29 11:13:25 +02:00 committed by Mark Brown
parent 01500b2cb0
commit 6afe041c2c
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View 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");