summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtish Patra <atish.patra@wdc.com>2021-07-10 19:18:07 +0300
committerAnup Patel <anup@brainfault.org>2021-07-11 07:45:29 +0300
commit41ae63cd0a75474ce380a944d5b4f1fb9b6fd2e0 (patch)
treeb8281693c04a7672b25b17db230ca7b784eaf3ef
parent9c9b4ad24bf5891272679a6e994c64463db8ca03 (diff)
downloadopensbi-41ae63cd0a75474ce380a944d5b4f1fb9b6fd2e0.tar.xz
include: Add a list empty check function
Implement a list helper function that checks for empty lists. Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
-rw-r--r--include/sbi/sbi_list.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/sbi/sbi_list.h b/include/sbi/sbi_list.h
index 1174ad2..b1178df 100644
--- a/include/sbi/sbi_list.h
+++ b/include/sbi/sbi_list.h
@@ -44,6 +44,17 @@ static inline void __sbi_list_add(struct sbi_dlist *new,
}
/**
+ * Checks if the list is empty or not.
+ * @param head List head
+ *
+ * Retruns TRUE if list is empty, FALSE otherwise.
+ */
+static inline bool sbi_list_empty(struct sbi_dlist *head)
+{
+ return head->next == head;
+}
+
+/**
* Adds the new node after the given head.
* @param new New node that needs to be added to list.
* @param head List head after which the "new" node should be added.