Messages in this thread Patch in this message |  | | From | Johan Hovold <> | | Subject | [PATCH 03/19] spi: bcm63xx: switch to managed controller allocation | | Date | Wed, 29 Apr 2026 11:13:17 +0200 |
| |
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> --- drivers/spi/spi-bcm63xx.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index 40cd7efc4b54..f8cfe535b2a3 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c @@ -541,11 +541,9 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) if (IS_ERR(reset)) return PTR_ERR(reset); - host = spi_alloc_host(dev, sizeof(*bs)); - if (!host) { - dev_err(dev, "out of memory\n"); + host = devm_spi_alloc_host(dev, sizeof(*bs)); + if (!host) return -ENOMEM; - } bs = spi_controller_get_devdata(host); init_completion(&bs->done); @@ -554,10 +552,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) bs->pdev = pdev; bs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r); - if (IS_ERR(bs->regs)) { - ret = PTR_ERR(bs->regs); - goto out_err; - } + if (IS_ERR(bs->regs)) + return PTR_ERR(bs->regs); bs->irq = irq; bs->clk = clk; @@ -568,7 +564,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) pdev->name, host); if (ret) { dev_err(dev, "unable to request irq\n"); - goto out_err; + return ret; } host->bus_num = bus_num; @@ -587,7 +583,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) /* Initialize hardware */ ret = clk_prepare_enable(bs->clk); if (ret) - goto out_err; + return ret; ret = reset_control_reset(reset); if (ret) { @@ -615,8 +611,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) out_clk_disable: clk_disable_unprepare(clk); -out_err: - spi_controller_put(host); + return ret; } @@ -625,8 +620,6 @@ static void bcm63xx_spi_remove(struct platform_device *pdev) struct spi_controller *host = platform_get_drvdata(pdev); struct bcm63xx_spi *bs = spi_controller_get_devdata(host); - spi_controller_get(host); - spi_unregister_controller(host); /* reset spi block */ @@ -634,8 +627,6 @@ static void bcm63xx_spi_remove(struct platform_device *pdev) /* HW shutdown */ clk_disable_unprepare(bs->clk); - - spi_controller_put(host); } static int bcm63xx_spi_suspend(struct device *dev) -- 2.53.0
|  |