From: Solomon Peachy Date: Sat, 17 Aug 2013 13:02:56 +0000 (-0400) Subject: backport: Add an implementation of get_random_int() for <3.10 kernels. X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=5c34a9c8909cf7534e1298993cae574b682b8d5a;p=openwrt%2Fstaging%2Fblogic.git 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 --- 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);