summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-fixed-rate.c
diff options
context:
space:
mode:
authorMike Turquette <mturquette@linaro.org>2012-03-27 02:51:03 +0200
committerMike Turquette <mturquette@linaro.org>2012-04-25 01:37:39 +0200
commit27d545915fd49cbe18a3877d82359896e9851efb (patch)
treeca3234eef7925fc068f6f55cd965abe21dfa399c /drivers/clk/clk-fixed-rate.c
parentclk: core: copy parent_names & return error codes (diff)
downloadlinux-27d545915fd49cbe18a3877d82359896e9851efb.tar.xz
linux-27d545915fd49cbe18a3877d82359896e9851efb.zip
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-fixed-rate.c')
-rw-r--r--drivers/clk/clk-fixed-rate.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c
index 027e47704de9..b555a04c8df8 100644
--- a/drivers/clk/clk-fixed-rate.c
+++ b/drivers/clk/clk-fixed-rate.c
@@ -38,16 +38,23 @@ const struct clk_ops clk_fixed_rate_ops = {
};
EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);
+/**
+ * clk_register_fixed_rate - register fixed-rate clock with the clock framework
+ * @dev: device that is registering this clock
+ * @name: name of this clock
+ * @parent_name: name of clock's parent
+ * @flags: framework-specific flags
+ * @fixed_rate: non-adjustable clock rate
+ */
struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
unsigned long fixed_rate)
{
struct clk_fixed_rate *fixed;
- char **parent_names = NULL;
- u8 len;
+ struct clk *clk;
+ /* allocate fixed-rate clock */
fixed = kzalloc(sizeof(struct clk_fixed_rate), GFP_KERNEL);
-
if (!fixed) {
pr_err("%s: could not allocate fixed clk\n", __func__);
return ERR_PTR(-ENOMEM);
@@ -56,26 +63,15 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
/* struct clk_fixed_rate assignments */
fixed->fixed_rate = fixed_rate;
- if (parent_name) {
- parent_names = kmalloc(sizeof(char *), GFP_KERNEL);
-
- if (! parent_names)
- goto out;
-
- len = sizeof(char) * strlen(parent_name);
-
- parent_names[0] = kmalloc(len, GFP_KERNEL);
-
- if (!parent_names[0])
- goto out;
-
- strncpy(parent_names[0], parent_name, len);
- }
-
-out:
- return clk_register(dev, name,
+ /* register the clock */
+ clk = clk_register(dev, name,
&clk_fixed_rate_ops, &fixed->hw,
- parent_names,
+ (parent_name ? &parent_name : NULL),
(parent_name ? 1 : 0),
flags);
+
+ if (IS_ERR(clk))
+ kfree(fixed);
+
+ return clk;
}