spi: orion: use devm_clk_get_optional_enabled for axi clock
PATCH 1/1 spi: orion: use devm_clk_get_optional_enabled for axi clock
Replace the open-coded optional axi clock get/prepare/enable and the manual cleanup in probe/remove/runtime_resume with the managed helper devm_clk_get_optional_enabled(). This removes the now-unused out_rel_axi_clk error path and simplifies the clock lifecycle.
--- drivers/spi/spi-orion.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/spi/spi-orion.c +7 -17
@@ -691,12 +691,9 @@ static int orion_spi_probe(struct platform_device *pdev)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 ) -return -EPROBE_DEFER ; - -if (!IS_ERR (spi->axi_clk)) -clk_prepare_enable (spi->axi_clk); + spi->axi_clk =devm_clk_get_optional_enabled (&pdev->dev,"axi" ); +if (IS_ERR (spi->axi_clk)) +return PTR_ERR (spi->axi_clk); tclk_hz =clk_get_rate (spi->clk);
@@ -719,10 +716,8 @@ static int orion_spi_probe(struct platform_device *pdev) host->min_speed_hz =DIV_ROUND_UP (tclk_hz, devdata->max_divisor); 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; - } +if (IS_ERR (spi->base)) +return PTR_ERR (spi->base);for_each_available_child_of_node (pdev->dev.of_node, np) {struct orion_direct_acc *dir_acc;
@@ -757,9 +752,8 @@ static int orion_spi_probe(struct platform_device *pdev) dir_acc = &spi->child[cs].direct_access; dir_acc->vaddr =devm_ioremap (&pdev->dev, r->start,PAGE_SIZE );if (!dir_acc->vaddr) { - status = -ENOMEM ;of_node_put (np); - goto out_rel_axi_clk; +return -ENOMEM ; } dir_acc->size =PAGE_SIZE ;
@@ -789,8 +783,6 @@ static int orion_spi_probe(struct platform_device *pdev)pm_runtime_put_noidle (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);pm_runtime_dont_use_autosuspend (&pdev->dev); -out_rel_axi_clk: -clk_disable_unprepare (spi->axi_clk);return status; }
@@ -804,7 +796,6 @@ static void orion_spi_remove(struct platform_device *pdev)spi_unregister_controller (host);pm_runtime_get_sync (&pdev->dev); -clk_disable_unprepare (spi->axi_clk);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);
@@ -830,8 +821,7 @@ static int orion_spi_runtime_resume(struct device *dev)struct spi_controller *host =dev_get_drvdata (dev);struct orion_spi *spi =spi_controller_get_devdata (host); -if (!IS_ERR (spi->axi_clk)) -clk_prepare_enable (spi->axi_clk); +clk_prepare_enable (spi->axi_clk); return clk_prepare_enable(spi->clk); }#endif
Signature · 1 line
2.55.0
Mark Brown
maintainerdrivers/spi/spi-orion.c static void orion_spi_remove(struct platform_device *pdev) · line 801
Quoted 13 lines · Rosen Penev
Replace the open-coded optional axi clock get/prepare/enable and the manual cleanup in probe/remove/runtime_resume with the managed helper
devm_clk_get_optional_enabled(). This removes the now-unusedout_rel_axi_clkerror path and simplifies the clock lifecycle.drivers/spi/spi-orion.c +0
-1@@ -804,7 +796,6 @@ static void orion_spi_remove(struct platform_device *pdev)spi_unregister_controller (host);pm_runtime_get_sync (&pdev->dev); -clk_disable_unprepare (spi->axi_clk);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);
This breaks the build since it removes the only use of 'spi' in the function.