[PATCH v4 07/17] spi: orion: Simplify clock handling with devm_clk_get_enabled()
Pei Xiao <[email protected]>
| Newsgroups | org.ozlabs.lists.openbmc,dev.linux.lists.imx,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-mediatek,org.infradead.lists.linux-riscv,org.infradead.lists.linux-rockchip,org.kernel.vger.linux-kernel,org.kernel.vger.linux-spi |
|---|---|
| Message-ID | <753e8d3343b4f880fc08628bbf8d3043c27fae5f.1773801401.git.xiaopei01@kylinos.cn> |
Replace devm_clk_get() followed by clk_prepare_enable() with devm_clk_get_enabled() for the "axi" clock. This reduces boilerplate code and error handling, as the managed API automatically disables the clock when the device is removed or if probe fails. Remove the now-unnecessary clk_disable_unprepare() call from the probe error path and the remove callback. Adjust error handling labels accordingly. Signed-off-by: Pei Xiao <[email protected]> --- drivers/spi/spi-orion.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 7a2186b51b4c..d884a18c95a6 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -695,13 +695,11 @@ static int orion_spi_probe(struct platform_device *pdev) } /* The following clock is only used by some SoCs */ - spi->axi_clk = devm_clk_get(&pdev->dev, "axi"); + spi->axi_clk = devm_clk_get_enabled(&pdev->dev, "axi"); if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) { status = -EPROBE_DEFER; goto out; } - if (!IS_ERR(spi->axi_clk)) - clk_prepare_enable(spi->axi_clk); tclk_hz = clk_get_rate(spi->clk); @@ -726,7 +724,7 @@ static int orion_spi_probe(struct platform_device *pdev) spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r); if (IS_ERR(spi->base)) { status = PTR_ERR(spi->base); - goto out_rel_axi_clk; + goto out; } for_each_available_child_of_node(pdev->dev.of_node, np) { @@ -764,7 +762,7 @@ static int orion_spi_probe(struct platform_device *pdev) if (!dir_acc->vaddr) { status = -ENOMEM; of_node_put(np); - goto out_rel_axi_clk; + goto out; } dir_acc->size = PAGE_SIZE; @@ -788,8 +786,6 @@ static int orion_spi_probe(struct platform_device *pdev) out_rel_pm: pm_runtime_disable(&pdev->dev); -out_rel_axi_clk: - clk_disable_unprepare(spi->axi_clk); out: spi_controller_put(host); return status; @@ -802,7 +798,6 @@ static void orion_spi_remove(struct platform_device *pdev) struct orion_spi *spi = spi_controller_get_devdata(host); pm_runtime_get_sync(&pdev->dev); - clk_disable_unprepare(spi->axi_clk); spi_unregister_controller(host); pm_runtime_disable(&pdev->dev); -- 2.25.1