summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-gate.c
diff options
context:
space:
mode:
authorMike Turquette <mturquette@linaro.org>2012-03-26 20:51:03 -0400
committerMike Turquette <mturquette@linaro.org>2012-04-24 19:37:39 -0400
commit27d545915fd49cbe18a3877d82359896e9851efb (patch)
treeca3234eef7925fc068f6f55cd965abe21dfa399c /drivers/clk/clk-gate.c
parentd1302a36a7f1c33d1a8babc6a510e1401a5e5aed (diff)
clk: basic: improve parent_names & return errors
This patch is the basic clk version of 'clk: core: copy parent_names & return error codes'. The registration functions are changed to allow the core code to copy the array of strings and allow platforms to declare those arrays as __initdata. This patch also converts all of the basic clk registration functions to return error codes which better aligns them with the existing clk.h api. Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk-gate.c')
-rw-r--r--drivers/clk/clk-gate.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
index fe2ff9e774c2..42a4b941b6e7 100644
--- a/drivers/clk/clk-gate.c
+++ b/drivers/clk/clk-gate.c
@@ -105,6 +105,17 @@ const struct clk_ops clk_gate_ops = {
105}; 105};
106EXPORT_SYMBOL_GPL(clk_gate_ops); 106EXPORT_SYMBOL_GPL(clk_gate_ops);
107 107
108/**
109 * clk_register_gate - register a gate clock with the clock framework
110 * @dev: device that is registering this clock
111 * @name: name of this clock
112 * @parent_name: name of this clock's parent
113 * @flags: framework-specific flags for this clock
114 * @reg: register address to control gating of this clock
115 * @bit_idx: which bit in the register controls gating of this clock
116 * @clk_gate_flags: gate-specific flags for this clock
117 * @lock: shared register lock for this clock
118 */
108struct clk *clk_register_gate(struct device *dev, const char *name, 119struct clk *clk_register_gate(struct device *dev, const char *name,
109 const char *parent_name, unsigned long flags, 120 const char *parent_name, unsigned long flags,
110 void __iomem *reg, u8 bit_idx, 121 void __iomem *reg, u8 bit_idx,
@@ -113,11 +124,11 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
113 struct clk_gate *gate; 124 struct clk_gate *gate;
114 struct clk *clk; 125 struct clk *clk;
115 126
127 /* allocate the gate */
116 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL); 128 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
117
118 if (!gate) { 129 if (!gate) {
119 pr_err("%s: could not allocate gated clk\n", __func__); 130 pr_err("%s: could not allocate gated clk\n", __func__);
120 return NULL; 131 return ERR_PTR(-ENOMEM);
121 } 132 }
122 133
123 /* struct clk_gate assignments */ 134 /* struct clk_gate assignments */
@@ -126,22 +137,15 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
126 gate->flags = clk_gate_flags; 137 gate->flags = clk_gate_flags;
127 gate->lock = lock; 138 gate->lock = lock;
128 139
129 if (parent_name) { 140 /* register the clock */
130 gate->parent[0] = kstrdup(parent_name, GFP_KERNEL);
131 if (!gate->parent[0])
132 goto out;
133 }
134
135 clk = clk_register(dev, name, 141 clk = clk_register(dev, name,
136 &clk_gate_ops, &gate->hw, 142 &clk_gate_ops, &gate->hw,
137 gate->parent, 143 (parent_name ? &parent_name : NULL),
138 (parent_name ? 1 : 0), 144 (parent_name ? 1 : 0),
139 flags); 145 flags);
140 if (clk)
141 return clk;
142out:
143 kfree(gate->parent[0]);
144 kfree(gate);
145 146
146 return NULL; 147 if (IS_ERR(clk))
148 kfree(gate);
149
150 return clk;
147} 151}