summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorSasha Levin <sasha.levin@oracle.com>2013-02-27 20:06:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:24 -0500
commitb67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch)
tree3d465aea12b97683f26ffa38eba8744469de9997 /drivers/clk/clk.c
parent1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (diff)
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived list_for_each_entry(pos, head, member) The hlist ones were greedy and wanted an extra parameter: hlist_for_each_entry(tpos, pos, head, member) Why did they need an extra pos parameter? I'm not quite sure. Not only they don't really need it, it also prevents the iterator from looking exactly like the list iterator, which is unfortunate. Besides the semantic patch, there was some manual work required: - Fix up the actual hlist iterators in linux/list.h - Fix up the declaration of other iterators based on the hlist ones. - A very small amount of places were using the 'node' parameter, this was modified to use 'obj->member' instead. - Coccinelle didn't handle the hlist_for_each_entry_safe iterator properly, so those had to be fixed up manually. The semantic patch which is mostly the work of Peter Senna Tschudin is here: @@ iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host; type T; expression a,c,d,e; identifier b; statement S; @@ -T b; <+... when != b ( hlist_for_each_entry(a, - b, c, d) S | hlist_for_each_entry_continue(a, - b, c) S | hlist_for_each_entry_from(a, - b, c) S | hlist_for_each_entry_rcu(a, - b, c, d) S | hlist_for_each_entry_rcu_bh(a, - b, c, d) S | hlist_for_each_entry_continue_rcu_bh(a, - b, c) S | for_each_busy_worker(a, c, - b, d) S | ax25_uid_for_each(a, - b, c) S | ax25_for_each(a, - b, c) S | inet_bind_bucket_for_each(a, - b, c) S | sctp_for_each_hentry(a, - b, c) S | sk_for_each(a, - b, c) S | sk_for_each_rcu(a, - b, c) S | sk_for_each_from -(a, b) +(a) S + sk_for_each_from(a) S | sk_for_each_safe(a, - b, c, d) S | sk_for_each_bound(a, - b, c) S | hlist_for_each_entry_safe(a, - b, c, d, e) S | hlist_for_each_entry_continue_rcu(a, - b, c) S | nr_neigh_for_each(a, - b, c) S | nr_neigh_for_each_safe(a, - b, c, d) S | nr_node_for_each(a, - b, c) S | nr_node_for_each_safe(a, - b, c, d) S | - for_each_gfn_sp(a, c, d, b) S + for_each_gfn_sp(a, c, d) S | - for_each_gfn_indirect_valid_sp(a, c, d, b) S + for_each_gfn_indirect_valid_sp(a, c, d) S | for_each_host(a, - b, c) S | for_each_host_safe(a, - b, c, d) S | for_each_mesh_entry(a, - b, c, d) S ) ...+> [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c] [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c] [akpm@linux-foundation.org: checkpatch fixes] [akpm@linux-foundation.org: fix warnings] [akpm@linux-foudnation.org: redo intrusive kvm changes] Tested-by: Peter Senna Tschudin <peter.senna@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c59
1 files changed, 22 insertions, 37 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index fabbfe1a9253..ed87b2405806 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -52,31 +52,29 @@ static void clk_summary_show_subtree(struct seq_file *s, struct clk *c,
52 int level) 52 int level)
53{ 53{
54 struct clk *child; 54 struct clk *child;
55 struct hlist_node *tmp;
56 55
57 if (!c) 56 if (!c)
58 return; 57 return;
59 58
60 clk_summary_show_one(s, c, level); 59 clk_summary_show_one(s, c, level);
61 60
62 hlist_for_each_entry(child, tmp, &c->children, child_node) 61 hlist_for_each_entry(child, &c->children, child_node)
63 clk_summary_show_subtree(s, child, level + 1); 62 clk_summary_show_subtree(s, child, level + 1);
64} 63}
65 64
66static int clk_summary_show(struct seq_file *s, void *data) 65static int clk_summary_show(struct seq_file *s, void *data)
67{ 66{
68 struct clk *c; 67 struct clk *c;
69 struct hlist_node *tmp;
70 68
71 seq_printf(s, " clock enable_cnt prepare_cnt rate\n"); 69 seq_printf(s, " clock enable_cnt prepare_cnt rate\n");
72 seq_printf(s, "---------------------------------------------------------------------\n"); 70 seq_printf(s, "---------------------------------------------------------------------\n");
73 71
74 mutex_lock(&prepare_lock); 72 mutex_lock(&prepare_lock);
75 73
76 hlist_for_each_entry(c, tmp, &clk_root_list, child_node) 74 hlist_for_each_entry(c, &clk_root_list, child_node)
77 clk_summary_show_subtree(s, c, 0); 75 clk_summary_show_subtree(s, c, 0);
78 76
79 hlist_for_each_entry(c, tmp, &clk_orphan_list, child_node) 77 hlist_for_each_entry(c, &clk_orphan_list, child_node)
80 clk_summary_show_subtree(s, c, 0); 78 clk_summary_show_subtree(s, c, 0);
81 79
82 mutex_unlock(&prepare_lock); 80 mutex_unlock(&prepare_lock);
@@ -111,14 +109,13 @@ static void clk_dump_one(struct seq_file *s, struct clk *c, int level)
111static void clk_dump_subtree(struct seq_file *s, struct clk *c, int level) 109static void clk_dump_subtree(struct seq_file *s, struct clk *c, int level)
112{ 110{
113 struct clk *child; 111 struct clk *child;
114 struct hlist_node *tmp;
115 112
116 if (!c) 113 if (!c)
117 return; 114 return;
118 115
119 clk_dump_one(s, c, level); 116 clk_dump_one(s, c, level);
120 117
121 hlist_for_each_entry(child, tmp, &c->children, child_node) { 118 hlist_for_each_entry(child, &c->children, child_node) {
122 seq_printf(s, ","); 119 seq_printf(s, ",");
123 clk_dump_subtree(s, child, level + 1); 120 clk_dump_subtree(s, child, level + 1);
124 } 121 }
@@ -129,21 +126,20 @@ static void clk_dump_subtree(struct seq_file *s, struct clk *c, int level)
129static int clk_dump(struct seq_file *s, void *data) 126static int clk_dump(struct seq_file *s, void *data)
130{ 127{
131 struct clk *c; 128 struct clk *c;
132 struct hlist_node *tmp;
133 bool first_node = true; 129 bool first_node = true;
134 130
135 seq_printf(s, "{"); 131 seq_printf(s, "{");
136 132
137 mutex_lock(&prepare_lock); 133 mutex_lock(&prepare_lock);
138 134
139 hlist_for_each_entry(c, tmp, &clk_root_list, child_node) { 135 hlist_for_each_entry(c, &clk_root_list, child_node) {
140 if (!first_node) 136 if (!first_node)
141 seq_printf(s, ","); 137 seq_printf(s, ",");
142 first_node = false; 138 first_node = false;
143 clk_dump_subtree(s, c, 0); 139 clk_dump_subtree(s, c, 0);
144 } 140 }
145 141
146 hlist_for_each_entry(c, tmp, &clk_orphan_list, child_node) { 142 hlist_for_each_entry(c, &clk_orphan_list, child_node) {
147 seq_printf(s, ","); 143 seq_printf(s, ",");
148 clk_dump_subtree(s, c, 0); 144 clk_dump_subtree(s, c, 0);
149 } 145 }
@@ -222,7 +218,6 @@ out:
222static int clk_debug_create_subtree(struct clk *clk, struct dentry *pdentry) 218static int clk_debug_create_subtree(struct clk *clk, struct dentry *pdentry)
223{ 219{
224 struct clk *child; 220 struct clk *child;
225 struct hlist_node *tmp;
226 int ret = -EINVAL;; 221 int ret = -EINVAL;;
227 222
228 if (!clk || !pdentry) 223 if (!clk || !pdentry)
@@ -233,7 +228,7 @@ static int clk_debug_create_subtree(struct clk *clk, struct dentry *pdentry)
233 if (ret) 228 if (ret)
234 goto out; 229 goto out;
235 230
236 hlist_for_each_entry(child, tmp, &clk->children, child_node) 231 hlist_for_each_entry(child, &clk->children, child_node)
237 clk_debug_create_subtree(child, clk->dentry); 232 clk_debug_create_subtree(child, clk->dentry);
238 233
239 ret = 0; 234 ret = 0;
@@ -299,7 +294,6 @@ out:
299static int __init clk_debug_init(void) 294static int __init clk_debug_init(void)
300{ 295{
301 struct clk *clk; 296 struct clk *clk;
302 struct hlist_node *tmp;
303 struct dentry *d; 297 struct dentry *d;
304 298
305 rootdir = debugfs_create_dir("clk", NULL); 299 rootdir = debugfs_create_dir("clk", NULL);
@@ -324,10 +318,10 @@ static int __init clk_debug_init(void)
324 318
325 mutex_lock(&prepare_lock); 319 mutex_lock(&prepare_lock);
326 320
327 hlist_for_each_entry(clk, tmp, &clk_root_list, child_node) 321 hlist_for_each_entry(clk, &clk_root_list, child_node)
328 clk_debug_create_subtree(clk, rootdir); 322 clk_debug_create_subtree(clk, rootdir);
329 323
330 hlist_for_each_entry(clk, tmp, &clk_orphan_list, child_node) 324 hlist_for_each_entry(clk, &clk_orphan_list, child_node)
331 clk_debug_create_subtree(clk, orphandir); 325 clk_debug_create_subtree(clk, orphandir);
332 326
333 inited = 1; 327 inited = 1;
@@ -345,13 +339,12 @@ static inline int clk_debug_register(struct clk *clk) { return 0; }
345static void clk_disable_unused_subtree(struct clk *clk) 339static void clk_disable_unused_subtree(struct clk *clk)
346{ 340{
347 struct clk *child; 341 struct clk *child;
348 struct hlist_node *tmp;
349 unsigned long flags; 342 unsigned long flags;
350 343
351 if (!clk) 344 if (!clk)
352 goto out; 345 goto out;
353 346
354 hlist_for_each_entry(child, tmp, &clk->children, child_node) 347 hlist_for_each_entry(child, &clk->children, child_node)
355 clk_disable_unused_subtree(child); 348 clk_disable_unused_subtree(child);
356 349
357 spin_lock_irqsave(&enable_lock, flags); 350 spin_lock_irqsave(&enable_lock, flags);
@@ -384,14 +377,13 @@ out:
384static int clk_disable_unused(void) 377static int clk_disable_unused(void)
385{ 378{
386 struct clk *clk; 379 struct clk *clk;
387 struct hlist_node *tmp;
388 380
389 mutex_lock(&prepare_lock); 381 mutex_lock(&prepare_lock);
390 382
391 hlist_for_each_entry(clk, tmp, &clk_root_list, child_node) 383 hlist_for_each_entry(clk, &clk_root_list, child_node)
392 clk_disable_unused_subtree(clk); 384 clk_disable_unused_subtree(clk);
393 385
394 hlist_for_each_entry(clk, tmp, &clk_orphan_list, child_node) 386 hlist_for_each_entry(clk, &clk_orphan_list, child_node)
395 clk_disable_unused_subtree(clk); 387 clk_disable_unused_subtree(clk);
396 388
397 mutex_unlock(&prepare_lock); 389 mutex_unlock(&prepare_lock);
@@ -484,12 +476,11 @@ static struct clk *__clk_lookup_subtree(const char *name, struct clk *clk)
484{ 476{
485 struct clk *child; 477 struct clk *child;
486 struct clk *ret; 478 struct clk *ret;
487 struct hlist_node *tmp;
488 479
489 if (!strcmp(clk->name, name)) 480 if (!strcmp(clk->name, name))
490 return clk; 481 return clk;
491 482
492 hlist_for_each_entry(child, tmp, &clk->children, child_node) { 483 hlist_for_each_entry(child, &clk->children, child_node) {
493 ret = __clk_lookup_subtree(name, child); 484 ret = __clk_lookup_subtree(name, child);
494 if (ret) 485 if (ret)
495 return ret; 486 return ret;
@@ -502,20 +493,19 @@ struct clk *__clk_lookup(const char *name)
502{ 493{
503 struct clk *root_clk; 494 struct clk *root_clk;
504 struct clk *ret; 495 struct clk *ret;
505 struct hlist_node *tmp;
506 496
507 if (!name) 497 if (!name)
508 return NULL; 498 return NULL;
509 499
510 /* search the 'proper' clk tree first */ 500 /* search the 'proper' clk tree first */
511 hlist_for_each_entry(root_clk, tmp, &clk_root_list, child_node) { 501 hlist_for_each_entry(root_clk, &clk_root_list, child_node) {
512 ret = __clk_lookup_subtree(name, root_clk); 502 ret = __clk_lookup_subtree(name, root_clk);
513 if (ret) 503 if (ret)
514 return ret; 504 return ret;
515 } 505 }
516 506
517 /* if not found, then search the orphan tree */ 507 /* if not found, then search the orphan tree */
518 hlist_for_each_entry(root_clk, tmp, &clk_orphan_list, child_node) { 508 hlist_for_each_entry(root_clk, &clk_orphan_list, child_node) {
519 ret = __clk_lookup_subtree(name, root_clk); 509 ret = __clk_lookup_subtree(name, root_clk);
520 if (ret) 510 if (ret)
521 return ret; 511 return ret;
@@ -812,7 +802,6 @@ static void __clk_recalc_rates(struct clk *clk, unsigned long msg)
812{ 802{
813 unsigned long old_rate; 803 unsigned long old_rate;
814 unsigned long parent_rate = 0; 804 unsigned long parent_rate = 0;
815 struct hlist_node *tmp;
816 struct clk *child; 805 struct clk *child;
817 806
818 old_rate = clk->rate; 807 old_rate = clk->rate;
@@ -832,7 +821,7 @@ static void __clk_recalc_rates(struct clk *clk, unsigned long msg)
832 if (clk->notifier_count && msg) 821 if (clk->notifier_count && msg)
833 __clk_notify(clk, msg, old_rate, clk->rate); 822 __clk_notify(clk, msg, old_rate, clk->rate);
834 823
835 hlist_for_each_entry(child, tmp, &clk->children, child_node) 824 hlist_for_each_entry(child, &clk->children, child_node)
836 __clk_recalc_rates(child, msg); 825 __clk_recalc_rates(child, msg);
837} 826}
838 827
@@ -878,7 +867,6 @@ EXPORT_SYMBOL_GPL(clk_get_rate);
878 */ 867 */
879static int __clk_speculate_rates(struct clk *clk, unsigned long parent_rate) 868static int __clk_speculate_rates(struct clk *clk, unsigned long parent_rate)
880{ 869{
881 struct hlist_node *tmp;
882 struct clk *child; 870 struct clk *child;
883 unsigned long new_rate; 871 unsigned long new_rate;
884 int ret = NOTIFY_DONE; 872 int ret = NOTIFY_DONE;
@@ -895,7 +883,7 @@ static int __clk_speculate_rates(struct clk *clk, unsigned long parent_rate)
895 if (ret == NOTIFY_BAD) 883 if (ret == NOTIFY_BAD)
896 goto out; 884 goto out;
897 885
898 hlist_for_each_entry(child, tmp, &clk->children, child_node) { 886 hlist_for_each_entry(child, &clk->children, child_node) {
899 ret = __clk_speculate_rates(child, new_rate); 887 ret = __clk_speculate_rates(child, new_rate);
900 if (ret == NOTIFY_BAD) 888 if (ret == NOTIFY_BAD)
901 break; 889 break;
@@ -908,11 +896,10 @@ out:
908static void clk_calc_subtree(struct clk *clk, unsigned long new_rate) 896static void clk_calc_subtree(struct clk *clk, unsigned long new_rate)
909{ 897{
910 struct clk *child; 898 struct clk *child;
911 struct hlist_node *tmp;
912 899
913 clk->new_rate = new_rate; 900 clk->new_rate = new_rate;
914 901
915 hlist_for_each_entry(child, tmp, &clk->children, child_node) { 902 hlist_for_each_entry(child, &clk->children, child_node) {
916 if (child->ops->recalc_rate) 903 if (child->ops->recalc_rate)
917 child->new_rate = child->ops->recalc_rate(child->hw, new_rate); 904 child->new_rate = child->ops->recalc_rate(child->hw, new_rate);
918 else 905 else
@@ -983,7 +970,6 @@ out:
983 */ 970 */
984static struct clk *clk_propagate_rate_change(struct clk *clk, unsigned long event) 971static struct clk *clk_propagate_rate_change(struct clk *clk, unsigned long event)
985{ 972{
986 struct hlist_node *tmp;
987 struct clk *child, *fail_clk = NULL; 973 struct clk *child, *fail_clk = NULL;
988 int ret = NOTIFY_DONE; 974 int ret = NOTIFY_DONE;
989 975
@@ -996,7 +982,7 @@ static struct clk *clk_propagate_rate_change(struct clk *clk, unsigned long even
996 fail_clk = clk; 982 fail_clk = clk;
997 } 983 }
998 984
999 hlist_for_each_entry(child, tmp, &clk->children, child_node) { 985 hlist_for_each_entry(child, &clk->children, child_node) {
1000 clk = clk_propagate_rate_change(child, event); 986 clk = clk_propagate_rate_change(child, event);
1001 if (clk) 987 if (clk)
1002 fail_clk = clk; 988 fail_clk = clk;
@@ -1014,7 +1000,6 @@ static void clk_change_rate(struct clk *clk)
1014 struct clk *child; 1000 struct clk *child;
1015 unsigned long old_rate; 1001 unsigned long old_rate;
1016 unsigned long best_parent_rate = 0; 1002 unsigned long best_parent_rate = 0;
1017 struct hlist_node *tmp;
1018 1003
1019 old_rate = clk->rate; 1004 old_rate = clk->rate;
1020 1005
@@ -1032,7 +1017,7 @@ static void clk_change_rate(struct clk *clk)
1032 if (clk->notifier_count && old_rate != clk->rate) 1017 if (clk->notifier_count && old_rate != clk->rate)
1033 __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate); 1018 __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate);
1034 1019
1035 hlist_for_each_entry(child, tmp, &clk->children, child_node) 1020 hlist_for_each_entry(child, &clk->children, child_node)
1036 clk_change_rate(child); 1021 clk_change_rate(child);
1037} 1022}
1038 1023
@@ -1348,7 +1333,7 @@ int __clk_init(struct device *dev, struct clk *clk)
1348{ 1333{
1349 int i, ret = 0; 1334 int i, ret = 0;
1350 struct clk *orphan; 1335 struct clk *orphan;
1351 struct hlist_node *tmp, *tmp2; 1336 struct hlist_node *tmp2;
1352 1337
1353 if (!clk) 1338 if (!clk)
1354 return -EINVAL; 1339 return -EINVAL;
@@ -1448,7 +1433,7 @@ int __clk_init(struct device *dev, struct clk *clk)
1448 * walk the list of orphan clocks and reparent any that are children of 1433 * walk the list of orphan clocks and reparent any that are children of
1449 * this clock 1434 * this clock
1450 */ 1435 */
1451 hlist_for_each_entry_safe(orphan, tmp, tmp2, &clk_orphan_list, child_node) { 1436 hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
1452 if (orphan->ops->get_parent) { 1437 if (orphan->ops->get_parent) {
1453 i = orphan->ops->get_parent(orphan->hw); 1438 i = orphan->ops->get_parent(orphan->hw);
1454 if (!strcmp(clk->name, orphan->parent_names[i])) 1439 if (!strcmp(clk->name, orphan->parent_names[i]))