summaryrefslogtreecommitdiff
path: root/drivers/clk/clk-divider.c
diff options
context:
space:
mode:
authorMike Turquette <mturquette@linaro.org>2012-03-26 17:51:03 -0700
committerMike Turquette <mturquette@linaro.org>2012-04-24 16:37:39 -0700
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 = {
};
EXPORT_SYMBOL_GPL(clk_divider_ops);
+/**
+ * clk_register_divider - register a divider clock with the clock framework
+ * @dev: device registering this clock
+ * @name: name of this clock
+ * @parent_name: name of clock's parent
+ * @flags: framework-specific flags
+ * @reg: register address to adjust divider
+ * @shift: number of bits to shift the bitfield
+ * @width: width of the bitfield
+ * @clk_divider_flags: divider-specific flags for this clock
+ * @lock: shared register lock for this clock
+ */
struct clk *clk_register_divider(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
void __iomem *reg, u8 shift, u8 width,
@@ -161,11 +173,11 @@ struct clk *clk_register_divider(struct device *dev, const char *name,
struct clk_divider *div;
struct clk *clk;
+ /* allocate the divider */
div = kzalloc(sizeof(struct clk_divider), GFP_KERNEL);
-
if (!div) {
pr_err("%s: could not allocate divider clk\n", __func__);
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
/* struct clk_divider assignments */
@@ -175,23 +187,15 @@ struct clk *clk_register_divider(struct device *dev, const char *name,
div->flags = clk_divider_flags;
div->lock = lock;
- if (parent_name) {
- div->parent[0] = kstrdup(parent_name, GFP_KERNEL);
- if (!div->parent[0])
- goto out;
- }
-
+ /* register the clock */
clk = clk_register(dev, name,
&clk_divider_ops, &div->hw,
- div->parent,
+ (parent_name ? &parent_name: NULL),
(parent_name ? 1 : 0),
flags);
- if (clk)
- return clk;
-out:
- kfree(div->parent[0]);
- kfree(div);
+ if (IS_ERR(clk))
+ kfree(div);
- return NULL;
+ return clk;
}