aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sock.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 /net/bluetooth/hci_sock.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 'net/bluetooth/hci_sock.c')
-rw-r--r--net/bluetooth/hci_sock.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 07f073935811..6a93614f2c49 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -70,14 +70,13 @@ static struct bt_sock_list hci_sk_list = {
70void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) 70void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
71{ 71{
72 struct sock *sk; 72 struct sock *sk;
73 struct hlist_node *node;
74 struct sk_buff *skb_copy = NULL; 73 struct sk_buff *skb_copy = NULL;
75 74
76 BT_DBG("hdev %p len %d", hdev, skb->len); 75 BT_DBG("hdev %p len %d", hdev, skb->len);
77 76
78 read_lock(&hci_sk_list.lock); 77 read_lock(&hci_sk_list.lock);
79 78
80 sk_for_each(sk, node, &hci_sk_list.head) { 79 sk_for_each(sk, &hci_sk_list.head) {
81 struct hci_filter *flt; 80 struct hci_filter *flt;
82 struct sk_buff *nskb; 81 struct sk_buff *nskb;
83 82
@@ -142,13 +141,12 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
142void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk) 141void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk)
143{ 142{
144 struct sock *sk; 143 struct sock *sk;
145 struct hlist_node *node;
146 144
147 BT_DBG("len %d", skb->len); 145 BT_DBG("len %d", skb->len);
148 146
149 read_lock(&hci_sk_list.lock); 147 read_lock(&hci_sk_list.lock);
150 148
151 sk_for_each(sk, node, &hci_sk_list.head) { 149 sk_for_each(sk, &hci_sk_list.head) {
152 struct sk_buff *nskb; 150 struct sk_buff *nskb;
153 151
154 /* Skip the original socket */ 152 /* Skip the original socket */
@@ -176,7 +174,6 @@ void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk)
176void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb) 174void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb)
177{ 175{
178 struct sock *sk; 176 struct sock *sk;
179 struct hlist_node *node;
180 struct sk_buff *skb_copy = NULL; 177 struct sk_buff *skb_copy = NULL;
181 __le16 opcode; 178 __le16 opcode;
182 179
@@ -210,7 +207,7 @@ void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb)
210 207
211 read_lock(&hci_sk_list.lock); 208 read_lock(&hci_sk_list.lock);
212 209
213 sk_for_each(sk, node, &hci_sk_list.head) { 210 sk_for_each(sk, &hci_sk_list.head) {
214 struct sk_buff *nskb; 211 struct sk_buff *nskb;
215 212
216 if (sk->sk_state != BT_BOUND) 213 if (sk->sk_state != BT_BOUND)
@@ -251,13 +248,12 @@ void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb)
251static void send_monitor_event(struct sk_buff *skb) 248static void send_monitor_event(struct sk_buff *skb)
252{ 249{
253 struct sock *sk; 250 struct sock *sk;
254 struct hlist_node *node;
255 251
256 BT_DBG("len %d", skb->len); 252 BT_DBG("len %d", skb->len);
257 253
258 read_lock(&hci_sk_list.lock); 254 read_lock(&hci_sk_list.lock);
259 255
260 sk_for_each(sk, node, &hci_sk_list.head) { 256 sk_for_each(sk, &hci_sk_list.head) {
261 struct sk_buff *nskb; 257 struct sk_buff *nskb;
262 258
263 if (sk->sk_state != BT_BOUND) 259 if (sk->sk_state != BT_BOUND)
@@ -393,11 +389,10 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
393 389
394 if (event == HCI_DEV_UNREG) { 390 if (event == HCI_DEV_UNREG) {
395 struct sock *sk; 391 struct sock *sk;
396 struct hlist_node *node;
397 392
398 /* Detach sockets from device */ 393 /* Detach sockets from device */
399 read_lock(&hci_sk_list.lock); 394 read_lock(&hci_sk_list.lock);
400 sk_for_each(sk, node, &hci_sk_list.head) { 395 sk_for_each(sk, &hci_sk_list.head) {
401 bh_lock_sock_nested(sk); 396 bh_lock_sock_nested(sk);
402 if (hci_pi(sk)->hdev == hdev) { 397 if (hci_pi(sk)->hdev == hdev) {
403 hci_pi(sk)->hdev = NULL; 398 hci_pi(sk)->hdev = NULL;