summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c171
1 files changed, 45 insertions, 126 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ea67ac81c6f9..940347e38c16 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -548,7 +548,8 @@ static void clk_core_rate_unprotect(struct clk_core *core)
if (!core)
return;
- if (WARN_ON(core->protect_count == 0))
+ if (WARN(core->protect_count == 0,
+ "%s already unprotected\n", core->name))
return;
if (--core->protect_count > 0)
@@ -681,16 +682,18 @@ static void clk_core_unprepare(struct clk_core *core)
if (!core)
return;
- if (WARN_ON(core->prepare_count == 0))
+ if (WARN(core->prepare_count == 0,
+ "%s already unprepared\n", core->name))
return;
- if (WARN_ON(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL))
+ if (WARN(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL,
+ "Unpreparing critical %s\n", core->name))
return;
if (--core->prepare_count > 0)
return;
- WARN_ON(core->enable_count > 0);
+ WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name);
trace_clk_unprepare(core);
@@ -808,10 +811,11 @@ static void clk_core_disable(struct clk_core *core)
if (!core)
return;
- if (WARN_ON(core->enable_count == 0))
+ if (WARN(core->enable_count == 0, "%s already disabled\n", core->name))
return;
- if (WARN_ON(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL))
+ if (WARN(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL,
+ "Disabling critical %s\n", core->name))
return;
if (--core->enable_count > 0)
@@ -866,7 +870,8 @@ static int clk_core_enable(struct clk_core *core)
if (!core)
return 0;
- if (WARN_ON(core->prepare_count == 0))
+ if (WARN(core->prepare_count == 0,
+ "Enabling unprepared %s\n", core->name))
return -ESHUTDOWN;
if (core->enable_count == 0) {
@@ -2170,7 +2175,6 @@ void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent)
bool clk_has_parent(struct clk *clk, struct clk *parent)
{
struct clk_core *core, *parent_core;
- unsigned int i;
/* NULL clocks should be nops, so return success if either is NULL. */
if (!clk || !parent)
@@ -2183,11 +2187,8 @@ bool clk_has_parent(struct clk *clk, struct clk *parent)
if (core->parent == parent_core)
return true;
- for (i = 0; i < core->num_parents; i++)
- if (strcmp(core->parent_names[i], parent_core->name) == 0)
- return true;
-
- return false;
+ return match_string(core->parent_names, core->num_parents,
+ parent_core->name) >= 0;
}
EXPORT_SYMBOL_GPL(clk_has_parent);
@@ -2608,81 +2609,31 @@ static int possible_parents_show(struct seq_file *s, void *data)
}
DEFINE_SHOW_ATTRIBUTE(possible_parents);
-static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
+static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
{
- struct dentry *d;
- int ret = -ENOMEM;
-
- if (!core || !pdentry) {
- ret = -EINVAL;
- goto out;
- }
-
- d = debugfs_create_dir(core->name, pdentry);
- if (!d)
- goto out;
+ struct dentry *root;
- core->dentry = d;
-
- d = debugfs_create_ulong("clk_rate", 0444, core->dentry, &core->rate);
- if (!d)
- goto err_out;
-
- d = debugfs_create_ulong("clk_accuracy", 0444, core->dentry,
- &core->accuracy);
- if (!d)
- goto err_out;
-
- d = debugfs_create_u32("clk_phase", 0444, core->dentry, &core->phase);
- if (!d)
- goto err_out;
-
- d = debugfs_create_file("clk_flags", 0444, core->dentry, core,
- &clk_flags_fops);
- if (!d)
- goto err_out;
-
- d = debugfs_create_u32("clk_prepare_count", 0444, core->dentry,
- &core->prepare_count);
- if (!d)
- goto err_out;
-
- d = debugfs_create_u32("clk_enable_count", 0444, core->dentry,
- &core->enable_count);
- if (!d)
- goto err_out;
-
- d = debugfs_create_u32("clk_protect_count", 0444, core->dentry,
- &core->protect_count);
- if (!d)
- goto err_out;
-
- d = debugfs_create_u32("clk_notifier_count", 0444, core->dentry,
- &core->notifier_count);
- if (!d)
- goto err_out;
+ if (!core || !pdentry)
+ return;
- if (core->num_parents > 1) {
- d = debugfs_create_file("clk_possible_parents", 0444,
- core->dentry, core, &possible_parents_fops);
- if (!d)
- goto err_out;
- }
+ root = debugfs_create_dir(core->name, pdentry);
+ core->dentry = root;
- if (core->ops->debug_init) {
- ret = core->ops->debug_init(core->hw, core->dentry);
- if (ret)
- goto err_out;
- }
+ debugfs_create_ulong("clk_rate", 0444, root, &core->rate);
+ debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy);
+ debugfs_create_u32("clk_phase", 0444, root, &core->phase);
+ debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops);
+ debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count);
+ debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
+ debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
+ debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
- ret = 0;
- goto out;
+ if (core->num_parents > 1)
+ debugfs_create_file("clk_possible_parents", 0444, root, core,
+ &possible_parents_fops);
-err_out:
- debugfs_remove_recursive(core->dentry);
- core->dentry = NULL;
-out:
- return ret;
+ if (core->ops->debug_init)
+ core->ops->debug_init(core->hw, core->dentry);
}
/**
@@ -2693,17 +2644,13 @@ out:
* initialized. Otherwise it bails out early since the debugfs clk directory
* will be created lazily by clk_debug_init as part of a late_initcall.
*/
-static int clk_debug_register(struct clk_core *core)
+static void clk_debug_register(struct clk_core *core)
{
- int ret = 0;
-
mutex_lock(&clk_debug_lock);
hlist_add_head(&core->debug_node, &clk_debug_list);
if (inited)
- ret = clk_debug_create_one(core, rootdir);
+ clk_debug_create_one(core, rootdir);
mutex_unlock(&clk_debug_lock);
-
- return ret;
}
/**
@@ -2723,19 +2670,6 @@ static void clk_debug_unregister(struct clk_core *core)
mutex_unlock(&clk_debug_lock);
}
-struct dentry *clk_debugfs_add_file(struct clk_hw *hw, char *name, umode_t mode,
- void *data, const struct file_operations *fops)
-{
- struct dentry *d = NULL;
-
- if (hw->core->dentry)
- d = debugfs_create_file(name, mode, hw->core->dentry, data,
- fops);
-
- return d;
-}
-EXPORT_SYMBOL_GPL(clk_debugfs_add_file);
-
/**
* clk_debug_init - lazily populate the debugfs clk directory
*
@@ -2748,32 +2682,17 @@ EXPORT_SYMBOL_GPL(clk_debugfs_add_file);
static int __init clk_debug_init(void)
{
struct clk_core *core;
- struct dentry *d;
rootdir = debugfs_create_dir("clk", NULL);
- if (!rootdir)
- return -ENOMEM;
-
- d = debugfs_create_file("clk_summary", 0444, rootdir, &all_lists,
- &clk_summary_fops);
- if (!d)
- return -ENOMEM;
-
- d = debugfs_create_file("clk_dump", 0444, rootdir, &all_lists,
- &clk_dump_fops);
- if (!d)
- return -ENOMEM;
-
- d = debugfs_create_file("clk_orphan_summary", 0444, rootdir,
- &orphan_list, &clk_summary_fops);
- if (!d)
- return -ENOMEM;
-
- d = debugfs_create_file("clk_orphan_dump", 0444, rootdir,
- &orphan_list, &clk_dump_fops);
- if (!d)
- return -ENOMEM;
+ debugfs_create_file("clk_summary", 0444, rootdir, &all_lists,
+ &clk_summary_fops);
+ debugfs_create_file("clk_dump", 0444, rootdir, &all_lists,
+ &clk_dump_fops);
+ debugfs_create_file("clk_orphan_summary", 0444, rootdir, &orphan_list,
+ &clk_summary_fops);
+ debugfs_create_file("clk_orphan_dump", 0444, rootdir, &orphan_list,
+ &clk_dump_fops);
mutex_lock(&clk_debug_lock);
hlist_for_each_entry(core, &clk_debug_list, debug_node)
@@ -2786,7 +2705,7 @@ static int __init clk_debug_init(void)
}
late_initcall(clk_debug_init);
#else
-static inline int clk_debug_register(struct clk_core *core) { return 0; }
+static inline void clk_debug_register(struct clk_core *core) { }
static inline void clk_debug_reparent(struct clk_core *core,
struct clk_core *new_parent)
{
@@ -3906,7 +3825,7 @@ int of_clk_parent_fill(struct device_node *np, const char **parents,
EXPORT_SYMBOL_GPL(of_clk_parent_fill);
struct clock_provider {
- of_clk_init_cb_t clk_init_cb;
+ void (*clk_init_cb)(struct device_node *);
struct device_node *np;
struct list_head node;
};