CHROMIUM: devfreq: rockchip: remove wait dcf irq evnet
[firefly-linux-kernel-4.4.55.git] / drivers / clk / clk-gate.c
index 790306e921c8ad55bcad26adaeb77c2b378c8db7..de0b322f5f58d4a57677455e6a5a2a78dcf0687d 100644 (file)
@@ -45,20 +45,22 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable)
 {
        struct clk_gate *gate = to_clk_gate(hw);
        int set = gate->flags & CLK_GATE_SET_TO_DISABLE ? 1 : 0;
-       unsigned long flags = 0;
+       unsigned long uninitialized_var(flags);
        u32 reg;
 
        set ^= enable;
 
        if (gate->lock)
                spin_lock_irqsave(gate->lock, flags);
+       else
+               __acquire(gate->lock);
 
        if (gate->flags & CLK_GATE_HIWORD_MASK) {
                reg = BIT(gate->bit_idx + 16);
                if (set)
                        reg |= BIT(gate->bit_idx);
        } else {
-               reg = readl(gate->reg);
+               reg = clk_readl(gate->reg);
 
                if (set)
                        reg |= BIT(gate->bit_idx);
@@ -66,10 +68,12 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable)
                        reg &= ~BIT(gate->bit_idx);
        }
 
-       writel(reg, gate->reg);
+       clk_writel(reg, gate->reg);
 
        if (gate->lock)
                spin_unlock_irqrestore(gate->lock, flags);
+       else
+               __release(gate->lock);
 }
 
 static int clk_gate_enable(struct clk_hw *hw)
@@ -89,7 +93,7 @@ static int clk_gate_is_enabled(struct clk_hw *hw)
        u32 reg;
        struct clk_gate *gate = to_clk_gate(hw);
 
-       reg = readl(gate->reg);
+       reg = clk_readl(gate->reg);
 
        /* if a set bit disables this clk, flip it before masking */
        if (gate->flags & CLK_GATE_SET_TO_DISABLE)
@@ -128,18 +132,16 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
        struct clk_init_data init;
 
        if (clk_gate_flags & CLK_GATE_HIWORD_MASK) {
-               if (bit_idx > 16) {
+               if (bit_idx > 15) {
                        pr_err("gate bit exceeds LOWORD field\n");
                        return ERR_PTR(-EINVAL);
                }
        }
 
        /* allocate the gate */
-       gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
-       if (!gate) {
-               pr_err("%s: could not allocate gated clk\n", __func__);
+       gate = kzalloc(sizeof(*gate), GFP_KERNEL);
+       if (!gate)
                return ERR_PTR(-ENOMEM);
-       }
 
        init.name = name;
        init.ops = &clk_gate_ops;
@@ -161,3 +163,20 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
 
        return clk;
 }
+EXPORT_SYMBOL_GPL(clk_register_gate);
+
+void clk_unregister_gate(struct clk *clk)
+{
+       struct clk_gate *gate;
+       struct clk_hw *hw;
+
+       hw = __clk_get_hw(clk);
+       if (!hw)
+               return;
+
+       gate = to_clk_gate(hw);
+
+       clk_unregister(clk);
+       kfree(gate);
+}
+EXPORT_SYMBOL_GPL(clk_unregister_gate);