+50
scripts/include/list.h
+50
scripts/include/list.h
···
128
128
}
129
129
130
130
/**
131
+
* list_replace - replace old entry by new one
132
+
* @old : the element to be replaced
133
+
* @new : the new element to insert
134
+
*
135
+
* If @old was empty, it will be overwritten.
136
+
*/
137
+
static inline void list_replace(struct list_head *old,
138
+
struct list_head *new)
139
+
{
140
+
new->next = old->next;
141
+
new->next->prev = new;
142
+
new->prev = old->prev;
143
+
new->prev->next = new;
144
+
}
145
+
146
+
/**
147
+
* list_replace_init - replace old entry by new one and initialize the old one
148
+
* @old : the element to be replaced
149
+
* @new : the new element to insert
150
+
*
151
+
* If @old was empty, it will be overwritten.
152
+
*/
153
+
static inline void list_replace_init(struct list_head *old,
154
+
struct list_head *new)
155
+
{
156
+
list_replace(old, new);
157
+
INIT_LIST_HEAD(old);
158
+
}
159
+
160
+
/**
131
161
* list_move - delete from one list and add as another's head
132
162
* @list: the entry to move
133
163
* @head: the head that will precede our entry
···
178
148
{
179
149
__list_del_entry(list);
180
150
list_add_tail(list, head);
151
+
}
152
+
153
+
/**
154
+
* list_is_first -- tests whether @list is the first entry in list @head
155
+
* @list: the entry to test
156
+
* @head: the head of the list
157
+
*/
158
+
static inline int list_is_first(const struct list_head *list, const struct list_head *head)
159
+
{
160
+
return list->prev == head;
161
+
}
162
+
163
+
/**
164
+
* list_is_last - tests whether @list is the last entry in list @head
165
+
* @list: the entry to test
166
+
* @head: the head of the list
167
+
*/
168
+
static inline int list_is_last(const struct list_head *list, const struct list_head *head)
169
+
{
170
+
return list->next == head;
181
171
}
182
172
183
173
/**