diff mbox series

[40/75] headers: backport get_random_u16, get_random_u8

Message ID 20240627234808.1253337-41-hauke@hauke-m.de (mailing list archive)
State New, archived
Headers show
Series backports: Update to kernel 6.1.95 | expand

Commit Message

Hauke Mehrtens June 27, 2024, 11:47 p.m. UTC
From: Felix Fietkau <nbd@nbd.name>

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 backport/backport-include/linux/random.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 backport/backport-include/linux/random.h
diff mbox series

Patch

diff --git a/backport/backport-include/linux/random.h b/backport/backport-include/linux/random.h
new file mode 100644
index 00000000..f4fd47dc
--- /dev/null
+++ b/backport/backport-include/linux/random.h
@@ -0,0 +1,18 @@ 
+#ifndef __BACKPORT_RANDOM_H
+#define __BACKPORT_RANDOM_H
+#include_next <linux/random.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_IS_LESS(6,1,0)
+static inline u8 get_random_u8(void)
+{
+	return get_random_u32() & 0xff;
+}
+
+static inline u16 get_random_u16(void)
+{
+	return get_random_u32() & 0xffff;
+}
+#endif
+
+#endif /* __BACKPORT_RANDOM_H */