X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Flinux%2Frculist.h;h=3863352656e7d6e02431038e38e084febf3fe996;hb=75faafd41c3c6312b7df51ce8cda5ba84495a8f1;hp=d079290843a93f9b508f9d05cd9489ea263dc380;hpb=ed8f37370d83e695c0a4fa5d5fc7a83ecb947526;p=pandora-kernel.git diff --git a/include/linux/rculist.h b/include/linux/rculist.h index d079290843a9..3863352656e7 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -241,6 +241,24 @@ static inline void list_splice_init_rcu(struct list_head *list, #define list_first_entry_rcu(ptr, type, member) \ list_entry_rcu((ptr)->next, type, member) +/** + * list_first_or_null_rcu - get the first element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + * + * Note that if the list is empty, it returns NULL. + * + * This primitive may safely run concurrently with the _rcu list-mutation + * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). + */ +#define list_first_or_null_rcu(ptr, type, member) \ + ({struct list_head *__ptr = (ptr); \ + struct list_head *__next = ACCESS_ONCE(__ptr->next); \ + likely(__ptr != __next) ? \ + list_entry_rcu(__next, type, member) : NULL; \ + }) + /** * list_for_each_entry_rcu - iterate over rcu list of given type * @pos: the type * to use as a loop cursor.