From: Masami Hiramatsu Date: Mon, 28 Apr 2008 09:14:27 +0000 (-0700) Subject: list.h: add list_is_singular() X-Git-Tag: v2.6.26-rc1~873 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99602572812442d47403d85f376ad51298dd82a6;p=platform%2Fkernel%2Flinux-exynos.git list.h: add list_is_singular() Add list_is_singular() to check a list has just one entry. list_is_singular() is useful to check whether a list_head which have been temporarily allocated for listing objects can be released or not. Signed-off-by: Masami Hiramatsu Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/list.h b/include/linux/list.h index dac16f9..b4a939b 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -319,6 +319,15 @@ static inline int list_empty_careful(const struct list_head *head) return (next == head) && (next == head->prev); } +/** + * list_is_singular - tests whether a list has just one entry. + * @head: the list to test. + */ +static inline int list_is_singular(const struct list_head *head) +{ + return !list_empty(head) && (head->next == head->prev); +} + static inline void __list_splice(struct list_head *list, struct list_head *head) {