aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
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 /net/nfc
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 'net/nfc')
-rw-r--r--net/nfc/llcp/llcp.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 746f5a2f9804..7f8266dd14cb 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -71,14 +71,14 @@ static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock)
71static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) 71static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen)
72{ 72{
73 struct sock *sk; 73 struct sock *sk;
74 struct hlist_node *node, *tmp; 74 struct hlist_node *tmp;
75 struct nfc_llcp_sock *llcp_sock; 75 struct nfc_llcp_sock *llcp_sock;
76 76
77 skb_queue_purge(&local->tx_queue); 77 skb_queue_purge(&local->tx_queue);
78 78
79 write_lock(&local->sockets.lock); 79 write_lock(&local->sockets.lock);
80 80
81 sk_for_each_safe(sk, node, tmp, &local->sockets.head) { 81 sk_for_each_safe(sk, tmp, &local->sockets.head) {
82 llcp_sock = nfc_llcp_sock(sk); 82 llcp_sock = nfc_llcp_sock(sk);
83 83
84 bh_lock_sock(sk); 84 bh_lock_sock(sk);
@@ -171,7 +171,6 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
171 u8 ssap, u8 dsap) 171 u8 ssap, u8 dsap)
172{ 172{
173 struct sock *sk; 173 struct sock *sk;
174 struct hlist_node *node;
175 struct nfc_llcp_sock *llcp_sock, *tmp_sock; 174 struct nfc_llcp_sock *llcp_sock, *tmp_sock;
176 175
177 pr_debug("ssap dsap %d %d\n", ssap, dsap); 176 pr_debug("ssap dsap %d %d\n", ssap, dsap);
@@ -183,7 +182,7 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
183 182
184 llcp_sock = NULL; 183 llcp_sock = NULL;
185 184
186 sk_for_each(sk, node, &local->sockets.head) { 185 sk_for_each(sk, &local->sockets.head) {
187 tmp_sock = nfc_llcp_sock(sk); 186 tmp_sock = nfc_llcp_sock(sk);
188 187
189 if (tmp_sock->ssap == ssap && tmp_sock->dsap == dsap) { 188 if (tmp_sock->ssap == ssap && tmp_sock->dsap == dsap) {
@@ -272,7 +271,6 @@ struct nfc_llcp_sock *nfc_llcp_sock_from_sn(struct nfc_llcp_local *local,
272 u8 *sn, size_t sn_len) 271 u8 *sn, size_t sn_len)
273{ 272{
274 struct sock *sk; 273 struct sock *sk;
275 struct hlist_node *node;
276 struct nfc_llcp_sock *llcp_sock, *tmp_sock; 274 struct nfc_llcp_sock *llcp_sock, *tmp_sock;
277 275
278 pr_debug("sn %zd %p\n", sn_len, sn); 276 pr_debug("sn %zd %p\n", sn_len, sn);
@@ -284,7 +282,7 @@ struct nfc_llcp_sock *nfc_llcp_sock_from_sn(struct nfc_llcp_local *local,
284 282
285 llcp_sock = NULL; 283 llcp_sock = NULL;
286 284
287 sk_for_each(sk, node, &local->sockets.head) { 285 sk_for_each(sk, &local->sockets.head) {
288 tmp_sock = nfc_llcp_sock(sk); 286 tmp_sock = nfc_llcp_sock(sk);
289 287
290 pr_debug("llcp sock %p\n", tmp_sock); 288 pr_debug("llcp sock %p\n", tmp_sock);
@@ -601,14 +599,13 @@ static void nfc_llcp_set_nrns(struct nfc_llcp_sock *sock, struct sk_buff *pdu)
601void nfc_llcp_send_to_raw_sock(struct nfc_llcp_local *local, 599void nfc_llcp_send_to_raw_sock(struct nfc_llcp_local *local,
602 struct sk_buff *skb, u8 direction) 600 struct sk_buff *skb, u8 direction)
603{ 601{
604 struct hlist_node *node;
605 struct sk_buff *skb_copy = NULL, *nskb; 602 struct sk_buff *skb_copy = NULL, *nskb;
606 struct sock *sk; 603 struct sock *sk;
607 u8 *data; 604 u8 *data;
608 605
609 read_lock(&local->raw_sockets.lock); 606 read_lock(&local->raw_sockets.lock);
610 607
611 sk_for_each(sk, node, &local->raw_sockets.head) { 608 sk_for_each(sk, &local->raw_sockets.head) {
612 if (sk->sk_state != LLCP_BOUND) 609 if (sk->sk_state != LLCP_BOUND)
613 continue; 610 continue;
614 611
@@ -697,11 +694,10 @@ static struct nfc_llcp_sock *nfc_llcp_connecting_sock_get(struct nfc_llcp_local
697{ 694{
698 struct sock *sk; 695 struct sock *sk;
699 struct nfc_llcp_sock *llcp_sock; 696 struct nfc_llcp_sock *llcp_sock;
700 struct hlist_node *node;
701 697
702 read_lock(&local->connecting_sockets.lock); 698 read_lock(&local->connecting_sockets.lock);
703 699
704 sk_for_each(sk, node, &local->connecting_sockets.head) { 700 sk_for_each(sk, &local->connecting_sockets.head) {
705 llcp_sock = nfc_llcp_sock(sk); 701 llcp_sock = nfc_llcp_sock(sk);
706 702
707 if (llcp_sock->ssap == ssap) { 703 if (llcp_sock->ssap == ssap) {