From: Johan Hovold Date: Wed, 29 Apr 2026 09:13:31 +0000 (+0200) Subject: spi: npcm-pspi: switch to managed controller allocation X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=c0c6875f0b7de6094f15ffd5b1dcebb3cebe53e1;p=thirdparty%2Flinux.git spi: npcm-pspi: 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-18-johan@kernel.org Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index cffef0a5977d0..a437a30d636c2 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -345,7 +345,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) int irq; int ret; - host = spi_alloc_host(&pdev->dev, sizeof(*priv)); + host = devm_spi_alloc_host(&pdev->dev, sizeof(*priv)); if (!host) return -ENOMEM; @@ -356,21 +356,18 @@ static int npcm_pspi_probe(struct platform_device *pdev) priv->is_save_param = false; priv->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(priv->base)) { - ret = PTR_ERR(priv->base); - goto out_host_put; - } + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); priv->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "failed to get clock\n"); - ret = PTR_ERR(priv->clk); - goto out_host_put; + return PTR_ERR(priv->clk); } ret = clk_prepare_enable(priv->clk); if (ret) - goto out_host_put; + return ret; irq = platform_get_irq(pdev, 0); if (irq < 0) { @@ -424,8 +421,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) out_disable_clk: clk_disable_unprepare(priv->clk); -out_host_put: - spi_controller_put(host); return ret; } @@ -434,14 +429,10 @@ static void npcm_pspi_remove(struct platform_device *pdev) struct spi_controller *host = platform_get_drvdata(pdev); struct npcm_pspi *priv = spi_controller_get_devdata(host); - spi_controller_get(host); - spi_unregister_controller(host); npcm_pspi_reset_hw(priv); clk_disable_unprepare(priv->clk); - - spi_controller_put(host); } static const struct of_device_id npcm_pspi_match[] = {