CLOCKSOURCE: mips-gic: Enable the clock before using it
authorEzequiel Garcia <[email protected]>
Mon, 27 Jul 2015 14:00:12 +0000 (15:00 +0100)
committerRalf Baechle <[email protected]>
Thu, 3 Sep 2015 10:08:05 +0000 (12:08 +0200)
For the clock to be used (e.g. get its rate through clk_get_rate)
it should be prepared and enabled first.

Also, while the clock is enabled the driver must hold a reference to it,
so let's remove the call to clk_put.

Reviewed-by: Andrew Bresticker <[email protected]>
Signed-off-by: Ezequiel Garcia <[email protected]>
Acked-by: Daniel Lezcano <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Cc: James Hartley <[email protected]>
Cc: Govindraj Raja <[email protected]>
Cc: Damien Horsley <[email protected]>
Cc: James Hogan <[email protected]>
Cc: Ezequiel Garcia <[email protected]>
Patchwork: https://patchwork.linux-mips.org/patch/10779/
Signed-off-by: Ralf Baechle <[email protected]>
drivers/clocksource/mips-gic-timer.c

index b81ed1a5342d90ca7481dd48c0bf928da5bcc6e7..913585d93466af0f19a4cb54f2fe1eb3241bb8ce 100644 (file)
@@ -158,8 +158,13 @@ static void __init gic_clocksource_of_init(struct device_node *node)
 
        clk = of_clk_get(node, 0);
        if (!IS_ERR(clk)) {
+               if (clk_prepare_enable(clk) < 0) {
+                       pr_err("GIC failed to enable clock\n");
+                       clk_put(clk);
+                       return;
+               }
+
                gic_frequency = clk_get_rate(clk);
-               clk_put(clk);
        } else if (of_property_read_u32(node, "clock-frequency",
                                        &gic_frequency)) {
                pr_err("GIC frequency not specified.\n");