diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-11-12 18:10:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-12 22:09:23 -0500 |
commit | 008208c6b26f21c2648c250a09c55e737c02c5f8 (patch) | |
tree | 14710b8640457d3377b8ddc5d9ed5e41234ed561 | |
parent | 92a2e1cb53ba649e620b7f02a15ad1fb949c6355 (diff) |
list: introduce list_next_entry() and list_prev_entry()
Add two trivial helpers list_next_entry() and list_prev_entry(), they
can have a lot of users including list.h itself. In fact the 1st one is
already defined in events/core.c and bnx2x_sp.c, so the patch simply
moves the definition to list.h.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Eilon Greenstein <eilong@broadcom.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 3 | ||||
-rw-r--r-- | include/linux/list.h | 16 | ||||
-rw-r--r-- | kernel/events/core.c | 3 |
3 files changed, 16 insertions, 6 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 9fbeee522d2c..32c92abf5094 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | |||
@@ -1217,9 +1217,6 @@ static void bnx2x_set_one_vlan_mac_e1h(struct bnx2x *bp, | |||
1217 | ETH_VLAN_FILTER_CLASSIFY, config); | 1217 | ETH_VLAN_FILTER_CLASSIFY, config); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | #define list_next_entry(pos, member) \ | ||
1221 | list_entry((pos)->member.next, typeof(*(pos)), member) | ||
1222 | |||
1223 | /** | 1220 | /** |
1224 | * bnx2x_vlan_mac_restore - reconfigure next MAC/VLAN/VLAN-MAC element | 1221 | * bnx2x_vlan_mac_restore - reconfigure next MAC/VLAN/VLAN-MAC element |
1225 | * | 1222 | * |
diff --git a/include/linux/list.h b/include/linux/list.h index f4d8a2f12a33..2ece63847001 100644 --- a/include/linux/list.h +++ b/include/linux/list.h | |||
@@ -373,6 +373,22 @@ static inline void list_splice_tail_init(struct list_head *list, | |||
373 | (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) | 373 | (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) |
374 | 374 | ||
375 | /** | 375 | /** |
376 | * list_next_entry - get the next element in list | ||
377 | * @pos: the type * to cursor | ||
378 | * @member: the name of the list_struct within the struct. | ||
379 | */ | ||
380 | #define list_next_entry(pos, member) \ | ||
381 | list_entry((pos)->member.next, typeof(*(pos)), member) | ||
382 | |||
383 | /** | ||
384 | * list_prev_entry - get the prev element in list | ||
385 | * @pos: the type * to cursor | ||
386 | * @member: the name of the list_struct within the struct. | ||
387 | */ | ||
388 | #define list_prev_entry(pos, member) \ | ||
389 | list_entry((pos)->member.prev, typeof(*(pos)), member) | ||
390 | |||
391 | /** | ||
376 | * list_for_each - iterate over a list | 392 | * list_for_each - iterate over a list |
377 | * @pos: the &struct list_head to use as a loop cursor. | 393 | * @pos: the &struct list_head to use as a loop cursor. |
378 | * @head: the head for your list. | 394 | * @head: the head for your list. |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 8c875ef6e120..d724e7757cd1 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -2234,9 +2234,6 @@ static void __perf_event_sync_stat(struct perf_event *event, | |||
2234 | perf_event_update_userpage(next_event); | 2234 | perf_event_update_userpage(next_event); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | #define list_next_entry(pos, member) \ | ||
2238 | list_entry(pos->member.next, typeof(*pos), member) | ||
2239 | |||
2240 | static void perf_event_sync_stat(struct perf_event_context *ctx, | 2237 | static void perf_event_sync_stat(struct perf_event_context *ctx, |
2241 | struct perf_event_context *next_ctx) | 2238 | struct perf_event_context *next_ctx) |
2242 | { | 2239 | { |