From 5c34a9c8909cf7534e1298993cae574b682b8d5a Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 17 Aug 2013 09:02:56 -0400 Subject: [PATCH] backport: Add an implementation of get_random_int() for <3.10 kernels. get_random_int() was present, but simply not exported for use in modules until 3.10. Implement it in terms of the more expensive get_random_bytes() This is needed by the cw1200 driver. Signed-off-by: Solomon Peachy Signed-off-by: Luis R. Rodriguez --- backport/compat/backport-3.10.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backport/compat/backport-3.10.c b/backport/compat/backport-3.10.c index 980ed59d8e4e..5273758eeae1 100644 --- a/backport/compat/backport-3.10.c +++ b/backport/compat/backport-3.10.c @@ -12,6 +12,7 @@ #include #include #include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) #include @@ -77,3 +78,15 @@ void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) de->gid = gid; } EXPORT_SYMBOL_GPL(proc_set_user); + +/* get_random_int() was not exported for module use until 3.10-rc. + Implement it here in terms of the more expensive get_random_bytes() + */ +unsigned int get_random_int(void) +{ + unsigned int r; + get_random_bytes(&r, sizeof(r)); + + return r; +} +EXPORT_SYMBOL_GPL(get_random_int); -- 2.30.2