[PATCH 17/19] spi: npcm-pspi: switch to managed controller allocation

From: Johan Hovold

Date: Wed Apr 29 2026 - 05:21:50 EST


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@xxxxxxxxxx>
---
drivers/spi/spi-npcm-pspi.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c
index cffef0a5977d..a437a30d636c 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[] = {
--
2.53.0