This was added in the following upstream commit:
commit 6d7581e62f8be462440d7b22c6361f7c9fa4902b
Author: Jiri Pirko <[email protected]>
Date: Wed May 29 05:02:56 2013 +0000
list: introduce list_first_entry_or_null
Signed-off-by: Hauke Mehrtens <[email protected]>
---
backport/backport-include/linux/list.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/backport/backport-include/linux/list.h
b/backport/backport-include/linux/list.h
index fb5ee4b..3835595 100644
--- a/backport/backport-include/linux/list.h
+++ b/backport/backport-include/linux/list.h
@@ -115,4 +115,17 @@ static inline void list_splice_tail_init(struct list_head
*list,
}
#endif
+#ifndef list_first_entry_or_null
+/**
+ * list_first_entry_or_null - 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.
+ */
+#define list_first_entry_or_null(ptr, type, member) \
+ (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
+#endif /* list_first_entry_or_null */
+
#endif /* __BACKPORT_LIST_H */
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe backports" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html