提交 00625113 编写于 作者: Y Yang Shi 提交者: Shile Zhang

alinux: list: add list_is_first() and list_rotate_to_front()

to #26589565

The list_is_first() and list_rotate_to_front() functions are needed by
free page hinting.  list_is_first() was used by i915 driver, so moved it
to common header file.

Backported list_rotate_to_front() from commit a16b53849913 ("list: add
function list_rotate_to_front()"). Not backport the whole patch, just
copy the implementation of the function.
Signed-off-by: NYang Shi <yang.shi@linux.alibaba.com>
Reviewed-by: NXunlei Pang <xlpang@linux.alibaba.com>
Signed-off-by: NShile Zhang <shile.zhang@linux.alibaba.com>
上级 65bae25e
......@@ -120,12 +120,6 @@ static inline u64 ptr_to_u64(const void *ptr)
#include <linux/list.h>
static inline int list_is_first(const struct list_head *list,
const struct list_head *head)
{
return head->next == list;
}
static inline void __list_del_many(struct list_head *head,
struct list_head *first)
{
......
......@@ -183,6 +183,17 @@ static inline void list_move_tail(struct list_head *list,
list_add_tail(list, head);
}
/**
* list_is_first -- tests whether @ list is the first entry in list @head
* @list: the entry to test
* @head: the head of the list
*/
static inline int list_is_first(const struct list_head *list,
const struct list_head *head)
{
return list->prev == head;
}
/**
* list_is_last - tests whether @list is the last entry in list @head
* @list: the entry to test
......@@ -236,6 +247,24 @@ static inline void list_rotate_left(struct list_head *head)
}
}
/**
* list_rotate_to_front() - Rotate list to specific item.
* @list: The desired new front of the list.
* @head: The head of the list.
*
* Rotates list so that @list becomes the new front of the list.
*/
static inline void list_rotate_to_front(struct list_head *list,
struct list_head *head)
{
/*
* Deletes the list head from the list denoted by @head and
* places it as the tail of @list, this effectively rotates the
* list so that @list is at the front.
*/
list_move_tail(head, list);
}
/**
* list_is_singular - tests whether a list has just one entry.
* @head: the list to test.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册