spi: rspi: 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/20260505072909.618363-6-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Johan Hovold 2026-05-05 09:28:54 +02:00 committed by Mark Brown
parent 86e8160240
commit 368d0e6c6f
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1171,14 +1171,10 @@ static void rspi_remove(struct platform_device *pdev)
{
struct rspi_data *rspi = platform_get_drvdata(pdev);
spi_controller_get(rspi->ctlr);
spi_unregister_controller(rspi->ctlr);
rspi_release_dma(rspi->ctlr);
pm_runtime_disable(&pdev->dev);
spi_controller_put(rspi->ctlr);
}
static const struct spi_ops rspi_ops = {
@ -1294,7 +1290,7 @@ static int rspi_probe(struct platform_device *pdev)
const struct spi_ops *ops;
unsigned long clksrc;
ctlr = spi_alloc_host(&pdev->dev, sizeof(struct rspi_data));
ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(struct rspi_data));
if (ctlr == NULL)
return -ENOMEM;
@ -1302,7 +1298,7 @@ static int rspi_probe(struct platform_device *pdev)
if (ops) {
ret = rspi_parse_dt(&pdev->dev, ctlr);
if (ret)
goto error1;
return ret;
} else {
ops = (struct spi_ops *)pdev->id_entry->driver_data;
ctlr->num_chipselect = 2; /* default */
@ -1314,16 +1310,13 @@ static int rspi_probe(struct platform_device *pdev)
rspi->ctlr = ctlr;
rspi->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(rspi->addr)) {
ret = PTR_ERR(rspi->addr);
goto error1;
}
if (IS_ERR(rspi->addr))
return PTR_ERR(rspi->addr);
rspi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(rspi->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
ret = PTR_ERR(rspi->clk);
goto error1;
return PTR_ERR(rspi->clk);
}
rspi->pdev = pdev;
@ -1396,8 +1389,6 @@ static int rspi_probe(struct platform_device *pdev)
rspi_release_dma(ctlr);
error2:
pm_runtime_disable(&pdev->dev);
error1:
spi_controller_put(ctlr);
return ret;
}