aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_hashtab.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/gpu/drm/drm_hashtab.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/gpu/drm/drm_hashtab.c')
-rw-r--r--drivers/gpu/drm/drm_hashtab.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c
index 80254547a3f8..7e4bae760e27 100644
--- a/drivers/gpu/drm/drm_hashtab.c
+++ b/drivers/gpu/drm/drm_hashtab.c
@@ -60,14 +60,13 @@ void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key)
60{ 60{
61 struct drm_hash_item *entry; 61 struct drm_hash_item *entry;
62 struct hlist_head *h_list; 62 struct hlist_head *h_list;
63 struct hlist_node *list;
64 unsigned int hashed_key; 63 unsigned int hashed_key;
65 int count = 0; 64 int count = 0;
66 65
67 hashed_key = hash_long(key, ht->order); 66 hashed_key = hash_long(key, ht->order);
68 DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key); 67 DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key);
69 h_list = &ht->table[hashed_key]; 68 h_list = &ht->table[hashed_key];
70 hlist_for_each_entry(entry, list, h_list, head) 69 hlist_for_each_entry(entry, h_list, head)
71 DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key); 70 DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key);
72} 71}
73 72
@@ -76,14 +75,13 @@ static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht,
76{ 75{
77 struct drm_hash_item *entry; 76 struct drm_hash_item *entry;
78 struct hlist_head *h_list; 77 struct hlist_head *h_list;
79 struct hlist_node *list;
80 unsigned int hashed_key; 78 unsigned int hashed_key;
81 79
82 hashed_key = hash_long(key, ht->order); 80 hashed_key = hash_long(key, ht->order);
83 h_list = &ht->table[hashed_key]; 81 h_list = &ht->table[hashed_key];
84 hlist_for_each_entry(entry, list, h_list, head) { 82 hlist_for_each_entry(entry, h_list, head) {
85 if (entry->key == key) 83 if (entry->key == key)
86 return list; 84 return &entry->head;
87 if (entry->key > key) 85 if (entry->key > key)
88 break; 86 break;
89 } 87 }
@@ -95,14 +93,13 @@ static struct hlist_node *drm_ht_find_key_rcu(struct drm_open_hash *ht,
95{ 93{
96 struct drm_hash_item *entry; 94 struct drm_hash_item *entry;
97 struct hlist_head *h_list; 95 struct hlist_head *h_list;
98 struct hlist_node *list;
99 unsigned int hashed_key; 96 unsigned int hashed_key;
100 97
101 hashed_key = hash_long(key, ht->order); 98 hashed_key = hash_long(key, ht->order);
102 h_list = &ht->table[hashed_key]; 99 h_list = &ht->table[hashed_key];
103 hlist_for_each_entry_rcu(entry, list, h_list, head) { 100 hlist_for_each_entry_rcu(entry, h_list, head) {
104 if (entry->key == key) 101 if (entry->key == key)
105 return list; 102 return &entry->head;
106 if (entry->key > key) 103 if (entry->key > key)
107 break; 104 break;
108 } 105 }
@@ -113,19 +110,19 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item)
113{ 110{
114 struct drm_hash_item *entry; 111 struct drm_hash_item *entry;
115 struct hlist_head *h_list; 112 struct hlist_head *h_list;
116 struct hlist_node *list, *parent; 113 struct hlist_node *parent;
117 unsigned int hashed_key; 114 unsigned int hashed_key;
118 unsigned long key = item->key; 115 unsigned long key = item->key;
119 116
120 hashed_key = hash_long(key, ht->order); 117 hashed_key = hash_long(key, ht->order);
121 h_list = &ht->table[hashed_key]; 118 h_list = &ht->table[hashed_key];
122 parent = NULL; 119 parent = NULL;
123 hlist_for_each_entry(entry, list, h_list, head) { 120 hlist_for_each_entry(entry, h_list, head) {
124 if (entry->key == key) 121 if (entry->key == key)
125 return -EINVAL; 122 return -EINVAL;
126 if (entry->key > key) 123 if (entry->key > key)
127 break; 124 break;
128 parent = list; 125 parent = &entry->head;
129 } 126 }
130 if (parent) { 127 if (parent) {
131 hlist_add_after_rcu(parent, &item->head); 128 hlist_add_after_rcu(parent, &item->head);