mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 11:37:31 -04:00
spi: fsl-espi: 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-13-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
@@ -667,7 +667,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
|
||||
struct fsl_espi *espi;
|
||||
int ret;
|
||||
|
||||
host = spi_alloc_host(dev, sizeof(struct fsl_espi));
|
||||
host = devm_spi_alloc_host(dev, sizeof(struct fsl_espi));
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -690,8 +690,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
|
||||
espi->spibrg = fsl_get_sys_freq();
|
||||
if (espi->spibrg == -1) {
|
||||
dev_err(dev, "Can't get sys frequency!\n");
|
||||
ret = -EINVAL;
|
||||
goto err_probe;
|
||||
return -EINVAL;
|
||||
}
|
||||
/* determined by clock divider fields DIV16/PM in register SPMODEx */
|
||||
host->min_speed_hz = DIV_ROUND_UP(espi->spibrg, 4 * 16 * 16);
|
||||
@@ -700,15 +699,13 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
|
||||
init_completion(&espi->done);
|
||||
|
||||
espi->reg_base = devm_ioremap_resource(dev, mem);
|
||||
if (IS_ERR(espi->reg_base)) {
|
||||
ret = PTR_ERR(espi->reg_base);
|
||||
goto err_probe;
|
||||
}
|
||||
if (IS_ERR(espi->reg_base))
|
||||
return PTR_ERR(espi->reg_base);
|
||||
|
||||
/* Register for SPI Interrupt */
|
||||
ret = devm_request_irq(dev, irq, fsl_espi_irq, 0, "fsl_espi", espi);
|
||||
if (ret)
|
||||
goto err_probe;
|
||||
return ret;
|
||||
|
||||
fsl_espi_init_regs(dev, true);
|
||||
|
||||
@@ -732,8 +729,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
|
||||
pm_runtime_put_noidle(dev);
|
||||
pm_runtime_disable(dev);
|
||||
pm_runtime_set_suspended(dev);
|
||||
err_probe:
|
||||
spi_controller_put(host);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -784,13 +780,9 @@ static void of_fsl_espi_remove(struct platform_device *dev)
|
||||
{
|
||||
struct spi_controller *host = platform_get_drvdata(dev);
|
||||
|
||||
spi_controller_get(host);
|
||||
|
||||
spi_unregister_controller(host);
|
||||
|
||||
pm_runtime_disable(&dev->dev);
|
||||
|
||||
spi_controller_put(host);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
||||
Reference in New Issue
Block a user