[PATCH 28/74] backports: add get_random_u16()

Johannes Berg <[email protected]> Fri, 24 May 2024 19:07:40 +0200
Newsgroups org.kernel.vger.backports
Message-ID <20240524190907.0ee01bdbffe9.Iac1c83457034d19878457df15d9f93a8c4781308@changeid>
From: Gregory Greenman <[email protected]>

Signed-off-by: Gregory Greenman <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
---
 backport/backport-include/linux/random.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/backport/backport-include/linux/random.h b/backport/backport-include/linux/random.h
index 0a247321785a..89e9ce022505 100644
--- a/backport/backport-include/linux/random.h
+++ b/backport/backport-include/linux/random.h
@@ -3,6 +3,13 @@
 #include_next <linux/random.h>
 #include <linux/version.h>
 
+#if LINUX_VERSION_IS_LESS(6,1,0)
+static inline u16 get_random_u16(void)
+{
+	return get_random_int() & 0xffff;
+}
+#endif
+
 #if LINUX_VERSION_IS_LESS(6,2,0)
 static inline u32 get_random_u32_below(u32 ceil)
 {
-- 
2.45.1