diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> | 2024-08-25 16:14:28 +0200 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2024-09-02 11:56:15 +0200 |
commit | 0fa8ce76b713a31f6aef2f88d08eee74d7d3d8a7 (patch) | |
tree | 0d885a6de7039ad3e2b23f4d7341b66d43c89921 | |
parent | ece222e91f2fb818fd01ff2754cf3b1d6f2bf411 (diff) | |
download | lwn-0fa8ce76b713a31f6aef2f88d08eee74d7d3d8a7.tar.gz lwn-0fa8ce76b713a31f6aef2f88d08eee74d7d3d8a7.zip |
reset: lpc18xx: simplify with devm_clk_get_enabled()
Use devm_clk_get_enabled() to drop clock prepare/unprepare parts and
make the code simpler. Change to dev_err_probe() in handling
reset_controller_register() error to make it even simpler.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Link: https://lore.kernel.org/r/20240825-reset-cleanup-scoped-v1-5-03f6d834f8c0@linaro.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r-- | drivers/reset/reset-lpc18xx.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/drivers/reset/reset-lpc18xx.c b/drivers/reset/reset-lpc18xx.c index e7896e3f1851..e42b2f24a93d 100644 --- a/drivers/reset/reset-lpc18xx.c +++ b/drivers/reset/reset-lpc18xx.c @@ -150,28 +150,16 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) if (IS_ERR(rc->base)) return PTR_ERR(rc->base); - rc->clk_reg = devm_clk_get(&pdev->dev, "reg"); + rc->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg"); if (IS_ERR(rc->clk_reg)) return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_reg), "reg clock not found\n"); - rc->clk_delay = devm_clk_get(&pdev->dev, "delay"); + rc->clk_delay = devm_clk_get_enabled(&pdev->dev, "delay"); if (IS_ERR(rc->clk_delay)) return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_delay), "delay clock not found\n"); - ret = clk_prepare_enable(rc->clk_reg); - if (ret) { - dev_err(&pdev->dev, "unable to enable reg clock\n"); - return ret; - } - - ret = clk_prepare_enable(rc->clk_delay); - if (ret) { - dev_err(&pdev->dev, "unable to enable delay clock\n"); - goto dis_clk_reg; - } - fcclk = clk_get_rate(rc->clk_reg) / USEC_PER_SEC; firc = clk_get_rate(rc->clk_delay) / USEC_PER_SEC; if (fcclk == 0 || firc == 0) @@ -187,10 +175,8 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) rc->rcdev.of_node = pdev->dev.of_node; ret = reset_controller_register(&rc->rcdev); - if (ret) { - dev_err(&pdev->dev, "unable to register device\n"); - goto dis_clks; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, "unable to register device\n"); rc->restart_nb.priority = 192, rc->restart_nb.notifier_call = lpc18xx_rgu_restart, @@ -199,13 +185,6 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "failed to register restart handler\n"); return 0; - -dis_clks: - clk_disable_unprepare(rc->clk_delay); -dis_clk_reg: - clk_disable_unprepare(rc->clk_reg); - - return ret; } static const struct of_device_id lpc18xx_rgu_match[] = { |