diff mbox series

[1/3] backports: add list_count_nodes()

Message ID 20240524194829.f11312298857.I2921f495b9feefbfe464ffd71c7350c66be119a8@changeid (mailing list archive)
State New, archived
Headers show
Series [1/3] backports: add list_count_nodes() | expand

Commit Message

Johannes Berg May 24, 2024, 5:48 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 backport/backport-include/linux/list.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 backport/backport-include/linux/list.h
diff mbox series

Patch

diff --git a/backport/backport-include/linux/list.h b/backport/backport-include/linux/list.h
new file mode 100644
index 000000000000..8495fd419a95
--- /dev/null
+++ b/backport/backport-include/linux/list.h
@@ -0,0 +1,19 @@ 
+#ifndef __BP_LINUX_LIST_H
+#define __BP_LINUX_LIST_H
+#include_next <linux/list.h>
+
+#if LINUX_VERSION_IS_LESS(6,3,0)
+#define list_count_nodes LINUX_BACKPORT(list_count_nodes)
+static inline size_t list_count_nodes(struct list_head *head)
+{
+	struct list_head *pos;
+	size_t count = 0;
+
+	list_for_each(pos, head)
+		count++;
+
+	return count;
+}
+#endif
+
+#endif /* __BP_LINUX_LIST_H */