diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2013-02-27 20:06:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:24 -0500 |
commit | b67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch) | |
tree | 3d465aea12b97683f26ffa38eba8744469de9997 /drivers/pci | |
parent | 1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (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/pci')
-rw-r--r-- | drivers/pci/pci.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 924e4665bd57..b099e0025d2b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -842,9 +842,8 @@ static struct pci_cap_saved_state *pci_find_saved_cap( | |||
842 | struct pci_dev *pci_dev, char cap) | 842 | struct pci_dev *pci_dev, char cap) |
843 | { | 843 | { |
844 | struct pci_cap_saved_state *tmp; | 844 | struct pci_cap_saved_state *tmp; |
845 | struct hlist_node *pos; | ||
846 | 845 | ||
847 | hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) { | 846 | hlist_for_each_entry(tmp, &pci_dev->saved_cap_space, next) { |
848 | if (tmp->cap.cap_nr == cap) | 847 | if (tmp->cap.cap_nr == cap) |
849 | return tmp; | 848 | return tmp; |
850 | } | 849 | } |
@@ -1041,7 +1040,6 @@ struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev) | |||
1041 | struct pci_saved_state *state; | 1040 | struct pci_saved_state *state; |
1042 | struct pci_cap_saved_state *tmp; | 1041 | struct pci_cap_saved_state *tmp; |
1043 | struct pci_cap_saved_data *cap; | 1042 | struct pci_cap_saved_data *cap; |
1044 | struct hlist_node *pos; | ||
1045 | size_t size; | 1043 | size_t size; |
1046 | 1044 | ||
1047 | if (!dev->state_saved) | 1045 | if (!dev->state_saved) |
@@ -1049,7 +1047,7 @@ struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev) | |||
1049 | 1047 | ||
1050 | size = sizeof(*state) + sizeof(struct pci_cap_saved_data); | 1048 | size = sizeof(*state) + sizeof(struct pci_cap_saved_data); |
1051 | 1049 | ||
1052 | hlist_for_each_entry(tmp, pos, &dev->saved_cap_space, next) | 1050 | hlist_for_each_entry(tmp, &dev->saved_cap_space, next) |
1053 | size += sizeof(struct pci_cap_saved_data) + tmp->cap.size; | 1051 | size += sizeof(struct pci_cap_saved_data) + tmp->cap.size; |
1054 | 1052 | ||
1055 | state = kzalloc(size, GFP_KERNEL); | 1053 | state = kzalloc(size, GFP_KERNEL); |
@@ -1060,7 +1058,7 @@ struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev) | |||
1060 | sizeof(state->config_space)); | 1058 | sizeof(state->config_space)); |
1061 | 1059 | ||
1062 | cap = state->cap; | 1060 | cap = state->cap; |
1063 | hlist_for_each_entry(tmp, pos, &dev->saved_cap_space, next) { | 1061 | hlist_for_each_entry(tmp, &dev->saved_cap_space, next) { |
1064 | size_t len = sizeof(struct pci_cap_saved_data) + tmp->cap.size; | 1062 | size_t len = sizeof(struct pci_cap_saved_data) + tmp->cap.size; |
1065 | memcpy(cap, &tmp->cap, len); | 1063 | memcpy(cap, &tmp->cap, len); |
1066 | cap = (struct pci_cap_saved_data *)((u8 *)cap + len); | 1064 | cap = (struct pci_cap_saved_data *)((u8 *)cap + len); |
@@ -2038,9 +2036,9 @@ void pci_allocate_cap_save_buffers(struct pci_dev *dev) | |||
2038 | void pci_free_cap_save_buffers(struct pci_dev *dev) | 2036 | void pci_free_cap_save_buffers(struct pci_dev *dev) |
2039 | { | 2037 | { |
2040 | struct pci_cap_saved_state *tmp; | 2038 | struct pci_cap_saved_state *tmp; |
2041 | struct hlist_node *pos, *n; | 2039 | struct hlist_node *n; |
2042 | 2040 | ||
2043 | hlist_for_each_entry_safe(tmp, pos, n, &dev->saved_cap_space, next) | 2041 | hlist_for_each_entry_safe(tmp, n, &dev->saved_cap_space, next) |
2044 | kfree(tmp); | 2042 | kfree(tmp); |
2045 | } | 2043 | } |
2046 | 2044 | ||