Skip to content

Commit

Permalink
list: Introduce list_rotate_left()
Browse files Browse the repository at this point in the history
Bring a new list_rotate_left() helper that rotates a list to
the left. This is useful for codes that need to round roubin
elements which queue priority increases from tail to head.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
  • Loading branch information
Frederic Weisbecker committed Jan 16, 2010
1 parent 889ff01 commit 5908cdc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ static inline int list_empty_careful(const struct list_head *head)
return (next == head) && (next == head->prev);
}

/**
* list_rotate_left - rotate the list to the left
* @head: the head of the list
*/
static inline void list_rotate_left(struct list_head *head)
{
struct list_head *first;

if (!list_empty(head)) {
first = head->next;
list_move_tail(first, head);
}
}

/**
* list_is_singular - tests whether a list has just one entry.
* @head: the list to test.
Expand Down

0 comments on commit 5908cdc

Please sign in to comment.