]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
clk: mvebu: share locks between gate clocks
authorMike Turquette <mturquette@linaro.org>
Wed, 27 Aug 2014 22:36:37 +0000 (15:36 -0700)
committerMike Turquette <mturquette@linaro.org>
Tue, 2 Sep 2014 00:43:52 +0000 (17:43 -0700)
Refactor mvebu_clk_gating_setup() to use a common spinlock instead of a
unique lock for every instance of a struct clk_gating_ctrl object. This
will be used later for a separate mux clock type that shares a register
with gate clock types and needs to use the same lock to protect access
to the register.

Cc: Andrew Lunn <andrew@lunn.ch>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/mvebu/common.c
drivers/clk/mvebu/common.h

index 25ceccf939ad2f33cdc71907d91e68b8e69a64be..8145c4efc381ffa211da406ca57ce124aec982c4 100644 (file)
@@ -89,8 +89,10 @@ void __init mvebu_coreclk_setup(struct device_node *np,
  * Clock Gating Control
  */
 
+DEFINE_SPINLOCK(ctrl_gating_lock);
+
 struct clk_gating_ctrl {
-       spinlock_t lock;
+       spinlock_t *lock;
        struct clk **gates;
        int num_gates;
 };
@@ -138,7 +140,8 @@ void __init mvebu_clk_gating_setup(struct device_node *np,
        if (WARN_ON(!ctrl))
                goto ctrl_out;
 
-       spin_lock_init(&ctrl->lock);
+       /* lock must already be initialized */
+       ctrl->lock = &ctrl_gating_lock;
 
        /* Count, allocate, and register clock gates */
        for (n = 0; desc[n].name;)
@@ -155,7 +158,7 @@ void __init mvebu_clk_gating_setup(struct device_node *np,
                        (desc[n].parent) ? desc[n].parent : default_parent;
                ctrl->gates[n] = clk_register_gate(NULL, desc[n].name, parent,
                                        desc[n].flags, base, desc[n].bit_idx,
-                                       0, &ctrl->lock);
+                                       0, ctrl->lock);
                WARN_ON(IS_ERR(ctrl->gates[n]));
        }
 
index f968b4d9df922cff17e9f404ca211c3aa56e53f1..8cd28e47471c3234e22610721fbcb563917737e5 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <linux/kernel.h>
 
+extern spinlock_t ctrl_gating_lock;
+
 struct device_node;
 
 struct coreclk_ratio {