mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
spi: orion: 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-20-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
@@ -651,11 +651,9 @@ static int orion_spi_probe(struct platform_device *pdev)
|
||||
struct device_node *np;
|
||||
int status;
|
||||
|
||||
host = spi_alloc_host(&pdev->dev, sizeof(*spi));
|
||||
if (host == NULL) {
|
||||
dev_dbg(&pdev->dev, "host allocation failed\n");
|
||||
host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi));
|
||||
if (host == NULL)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (pdev->id != -1)
|
||||
host->bus_num = pdev->id;
|
||||
@@ -689,17 +687,14 @@ static int orion_spi_probe(struct platform_device *pdev)
|
||||
spi->devdata = devdata;
|
||||
|
||||
spi->clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||
if (IS_ERR(spi->clk)) {
|
||||
status = PTR_ERR(spi->clk);
|
||||
goto out;
|
||||
}
|
||||
if (IS_ERR(spi->clk))
|
||||
return PTR_ERR(spi->clk);
|
||||
|
||||
/* The following clock is only used by some SoCs */
|
||||
spi->axi_clk = devm_clk_get(&pdev->dev, "axi");
|
||||
if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) {
|
||||
status = -EPROBE_DEFER;
|
||||
goto out;
|
||||
}
|
||||
if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
if (!IS_ERR(spi->axi_clk))
|
||||
clk_prepare_enable(spi->axi_clk);
|
||||
|
||||
@@ -796,8 +791,7 @@ static int orion_spi_probe(struct platform_device *pdev)
|
||||
pm_runtime_dont_use_autosuspend(&pdev->dev);
|
||||
out_rel_axi_clk:
|
||||
clk_disable_unprepare(spi->axi_clk);
|
||||
out:
|
||||
spi_controller_put(host);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -807,15 +801,11 @@ static void orion_spi_remove(struct platform_device *pdev)
|
||||
struct spi_controller *host = platform_get_drvdata(pdev);
|
||||
struct orion_spi *spi = spi_controller_get_devdata(host);
|
||||
|
||||
spi_controller_get(host);
|
||||
|
||||
spi_unregister_controller(host);
|
||||
|
||||
pm_runtime_get_sync(&pdev->dev);
|
||||
clk_disable_unprepare(spi->axi_clk);
|
||||
|
||||
spi_controller_put(host);
|
||||
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
pm_runtime_put_noidle(&pdev->dev);
|
||||
pm_runtime_set_suspended(&pdev->dev);
|
||||
|
||||
Reference in New Issue
Block a user