spi: orion: use devm_clk_get_optional_enabled for axi clock
PATCH v2 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.
---
v2: remove unused variable
drivers/spi/spi-orion.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
drivers/spi/spi-orion.c +7 -18
@@ -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; }
@@ -799,12 +791,10 @@ static int orion_spi_probe(struct platform_device *pdev)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_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 +820,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
maintainerQuoted 1 line · Rosen Penev
spi: orion: use
devm_clk_get_optional_enabledfor axi clock
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3
Thanks!
[1/1] spi: orion: use devm_clk_get_optional_enabled for axi clock
https://git.kernel.org/broonie/spi/c/61c2eaa653c2
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark