]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
clocksource/drivers/ingenic: Use devm_clk_get_enabled() helpers
authorHuan Yang <link@vivo.com>
Tue, 20 Aug 2024 09:46:03 +0000 (17:46 +0800)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Fri, 6 Sep 2024 12:49:20 +0000 (14:49 +0200)
The devm_clk_get_enabled() helpers:
    - call devm_clk_get()
    - call clk_prepare_enable() and register what is needed in order to
     call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the calls to clk_disable_unprepare().

Signed-off-by: Huan Yang <link@vivo.com>
Link: https://lore.kernel.org/r/20240820094603.103598-1-link@vivo.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/clocksource/ingenic-ost.c

index 9f7c280a1336e315e747add0c0db2e1dc88ea515..e0ec33307c8489220b75990624af455586982df8 100644 (file)
@@ -93,14 +93,10 @@ static int __init ingenic_ost_probe(struct platform_device *pdev)
                return PTR_ERR(map);
        }
 
-       ost->clk = devm_clk_get(dev, "ost");
+       ost->clk = devm_clk_get_enabled(dev, "ost");
        if (IS_ERR(ost->clk))
                return PTR_ERR(ost->clk);
 
-       err = clk_prepare_enable(ost->clk);
-       if (err)
-               return err;
-
        /* Clear counter high/low registers */
        if (soc_info->is64bit)
                regmap_write(map, TCU_REG_OST_CNTL, 0);
@@ -129,7 +125,6 @@ static int __init ingenic_ost_probe(struct platform_device *pdev)
        err = clocksource_register_hz(cs, rate);
        if (err) {
                dev_err(dev, "clocksource registration failed");
-               clk_disable_unprepare(ost->clk);
                return err;
        }