aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-divider.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-divider.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-divider.c')
-rw-r--r--drivers/clk/clk-divider.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index b1c4b02aaaf1..5fc541d017f1 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -153,6 +153,18 @@ const struct clk_ops clk_divider_ops = {
153}; 153};
154EXPORT_SYMBOL_GPL(clk_divider_ops); 154EXPORT_SYMBOL_GPL(clk_divider_ops);
155 155
156/**
157 * clk_register_divider - register a divider clock with the clock framework
158 * @dev: device registering this clock
159 * @name: name of this clock
160 * @parent_name: name of clock's parent
161 * @flags: framework-specific flags
162 * @reg: register address to adjust divider
163 * @shift: number of bits to shift the bitfield
164 * @width: width of the bitfield
165 * @clk_divider_flags: divider-specific flags for this clock
166 * @lock: shared register lock for this clock
167 */
156struct clk *clk_register_divider(struct device *dev, const char *name, 168struct clk *clk_register_divider(struct device *dev, const char *name,
157 const char *parent_name, unsigned long flags, 169 const char *parent_name, unsigned long flags,
158 void __iomem *reg, u8 shift, u8 width, 170 void __iomem *reg, u8 shift, u8 width,
@@ -161,11 +173,11 @@ struct clk *clk_register_divider(struct device *dev, const char *name,
161 struct clk_divider *div; 173 struct clk_divider *div;
162 struct clk *clk; 174 struct clk *clk;
163 175
176 /* allocate the divider */
164 div = kzalloc(sizeof(struct clk_divider), GFP_KERNEL); 177 div = kzalloc(sizeof(struct clk_divider), GFP_KERNEL);
165
166 if (!div) { 178 if (!div) {
167 pr_err("%s: could not allocate divider clk\n", __func__); 179 pr_err("%s: could not allocate divider clk\n", __func__);
168 return NULL; 180 return ERR_PTR(-ENOMEM);
169 } 181 }
170 182
171 /* struct clk_divider assignments */ 183 /* struct clk_divider assignments */
@@ -175,23 +187,15 @@ struct clk *clk_register_divider(struct device *dev, const char *name,
175 div->flags = clk_divider_flags; 187 div->flags = clk_divider_flags;
176 div->lock = lock; 188 div->lock = lock;
177 189
178 if (parent_name) { 190 /* register the clock */
179 div->parent[0] = kstrdup(parent_name, GFP_KERNEL);
180 if (!div->parent[0])
181 goto out;
182 }
183
184 clk = clk_register(dev, name, 191 clk = clk_register(dev, name,
185 &clk_divider_ops, &div->hw, 192 &clk_divider_ops, &div->hw,
186 div->parent, 193 (parent_name ? &parent_name: NULL),
187 (parent_name ? 1 : 0), 194 (parent_name ? 1 : 0),
188 flags); 195 flags);
189 if (clk)
190 return clk;
191 196
192out: 197 if (IS_ERR(clk))
193 kfree(div->parent[0]); 198 kfree(div);
194 kfree(div);
195 199
196 return NULL; 200 return clk;
197} 201}