aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/clk/clk.c73
-rw-r--r--include/linux/clk-private.h1
2 files changed, 28 insertions, 46 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b76fa69b44cb..8ca28189e4e9 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -100,6 +100,8 @@ static void clk_enable_unlock(unsigned long flags)
100 100
101static struct dentry *rootdir; 101static struct dentry *rootdir;
102static int inited = 0; 102static int inited = 0;
103static DEFINE_MUTEX(clk_debug_lock);
104static HLIST_HEAD(clk_debug_list);
103 105
104static struct hlist_head *all_lists[] = { 106static struct hlist_head *all_lists[] = {
105 &clk_root_list, 107 &clk_root_list,
@@ -300,28 +302,6 @@ out:
300 return ret; 302 return ret;
301} 303}
302 304
303/* caller must hold prepare_lock */
304static int clk_debug_create_subtree(struct clk *clk, struct dentry *pdentry)
305{
306 struct clk *child;
307 int ret = -EINVAL;;
308
309 if (!clk || !pdentry)
310 goto out;
311
312 ret = clk_debug_create_one(clk, pdentry);
313
314 if (ret)
315 goto out;
316
317 hlist_for_each_entry(child, &clk->children, child_node)
318 clk_debug_create_subtree(child, pdentry);
319
320 ret = 0;
321out:
322 return ret;
323}
324
325/** 305/**
326 * clk_debug_register - add a clk node to the debugfs clk tree 306 * clk_debug_register - add a clk node to the debugfs clk tree
327 * @clk: the clk being added to the debugfs clk tree 307 * @clk: the clk being added to the debugfs clk tree
@@ -329,20 +309,21 @@ out:
329 * Dynamically adds a clk to the debugfs clk tree if debugfs has been 309 * Dynamically adds a clk to the debugfs clk tree if debugfs has been
330 * initialized. Otherwise it bails out early since the debugfs clk tree 310 * initialized. Otherwise it bails out early since the debugfs clk tree
331 * will be created lazily by clk_debug_init as part of a late_initcall. 311 * will be created lazily by clk_debug_init as part of a late_initcall.
332 *
333 * Caller must hold prepare_lock. Only clk_init calls this function (so
334 * far) so this is taken care.
335 */ 312 */
336static int clk_debug_register(struct clk *clk) 313static int clk_debug_register(struct clk *clk)
337{ 314{
338 int ret = 0; 315 int ret = 0;
339 316
317 mutex_lock(&clk_debug_lock);
318 hlist_add_head(&clk->debug_node, &clk_debug_list);
319
340 if (!inited) 320 if (!inited)
341 goto out; 321 goto unlock;
342 322
343 ret = clk_debug_create_subtree(clk, rootdir); 323 ret = clk_debug_create_one(clk, rootdir);
324unlock:
325 mutex_unlock(&clk_debug_lock);
344 326
345out:
346 return ret; 327 return ret;
347} 328}
348 329
@@ -353,12 +334,18 @@ out:
353 * Dynamically removes a clk and all it's children clk nodes from the 334 * Dynamically removes a clk and all it's children clk nodes from the
354 * debugfs clk tree if clk->dentry points to debugfs created by 335 * debugfs clk tree if clk->dentry points to debugfs created by
355 * clk_debug_register in __clk_init. 336 * clk_debug_register in __clk_init.
356 *
357 * Caller must hold prepare_lock.
358 */ 337 */
359static void clk_debug_unregister(struct clk *clk) 338static void clk_debug_unregister(struct clk *clk)
360{ 339{
340 mutex_lock(&clk_debug_lock);
341 if (!clk->dentry)
342 goto out;
343
344 hlist_del_init(&clk->debug_node);
361 debugfs_remove_recursive(clk->dentry); 345 debugfs_remove_recursive(clk->dentry);
346 clk->dentry = NULL;
347out:
348 mutex_unlock(&clk_debug_lock);
362} 349}
363 350
364struct dentry *clk_debugfs_add_file(struct clk *clk, char *name, umode_t mode, 351struct dentry *clk_debugfs_add_file(struct clk *clk, char *name, umode_t mode,
@@ -415,17 +402,12 @@ static int __init clk_debug_init(void)
415 if (!d) 402 if (!d)
416 return -ENOMEM; 403 return -ENOMEM;
417 404
418 clk_prepare_lock(); 405 mutex_lock(&clk_debug_lock);
419 406 hlist_for_each_entry(clk, &clk_debug_list, debug_node)
420 hlist_for_each_entry(clk, &clk_root_list, child_node) 407 clk_debug_create_one(clk, rootdir);
421 clk_debug_create_subtree(clk, rootdir);
422
423 hlist_for_each_entry(clk, &clk_orphan_list, child_node)
424 clk_debug_create_subtree(clk, rootdir);
425 408
426 inited = 1; 409 inited = 1;
427 410 mutex_unlock(&clk_debug_lock);
428 clk_prepare_unlock();
429 411
430 return 0; 412 return 0;
431} 413}
@@ -2087,14 +2069,16 @@ void clk_unregister(struct clk *clk)
2087{ 2069{
2088 unsigned long flags; 2070 unsigned long flags;
2089 2071
2090 if (!clk || WARN_ON_ONCE(IS_ERR(clk))) 2072 if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
2091 return; 2073 return;
2074
2075 clk_debug_unregister(clk);
2092 2076
2093 clk_prepare_lock(); 2077 clk_prepare_lock();
2094 2078
2095 if (clk->ops == &clk_nodrv_ops) { 2079 if (clk->ops == &clk_nodrv_ops) {
2096 pr_err("%s: unregistered clock: %s\n", __func__, clk->name); 2080 pr_err("%s: unregistered clock: %s\n", __func__, clk->name);
2097 goto out; 2081 return;
2098 } 2082 }
2099 /* 2083 /*
2100 * Assign empty clock ops for consumers that might still hold 2084 * Assign empty clock ops for consumers that might still hold
@@ -2113,16 +2097,13 @@ void clk_unregister(struct clk *clk)
2113 clk_set_parent(child, NULL); 2097 clk_set_parent(child, NULL);
2114 } 2098 }
2115 2099
2116 clk_debug_unregister(clk);
2117
2118 hlist_del_init(&clk->child_node); 2100 hlist_del_init(&clk->child_node);
2119 2101
2120 if (clk->prepare_count) 2102 if (clk->prepare_count)
2121 pr_warn("%s: unregistering prepared clock: %s\n", 2103 pr_warn("%s: unregistering prepared clock: %s\n",
2122 __func__, clk->name); 2104 __func__, clk->name);
2123
2124 kref_put(&clk->ref, __clk_release); 2105 kref_put(&clk->ref, __clk_release);
2125out: 2106
2126 clk_prepare_unlock(); 2107 clk_prepare_unlock();
2127} 2108}
2128EXPORT_SYMBOL_GPL(clk_unregister); 2109EXPORT_SYMBOL_GPL(clk_unregister);
diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h
index efbf70b9fd84..4ed34105c371 100644
--- a/include/linux/clk-private.h
+++ b/include/linux/clk-private.h
@@ -48,6 +48,7 @@ struct clk {
48 unsigned long accuracy; 48 unsigned long accuracy;
49 struct hlist_head children; 49 struct hlist_head children;
50 struct hlist_node child_node; 50 struct hlist_node child_node;
51 struct hlist_node debug_node;
51 unsigned int notifier_count; 52 unsigned int notifier_count;
52#ifdef CONFIG_DEBUG_FS 53#ifdef CONFIG_DEBUG_FS
53 struct dentry *dentry; 54 struct dentry *dentry;