X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=lib%2Frandom32.c;h=1e5b2df442916de82ef497f844c068724f8cd555;hb=8051aa1a3d5aaa7bd4c062cad94d09c3d567ef2e;hp=82da4f4c3489eb0fa2a814adf477be16c14cbed4;hpb=9066d9b250679f259f06c10f489dfdfa75fb54dd;p=deliverable%2Flinux.git diff --git a/lib/random32.c b/lib/random32.c index 82da4f4c3489..1e5b2df44291 100644 --- a/lib/random32.c +++ b/lib/random32.c @@ -214,18 +214,22 @@ static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0); static void __prandom_timer(unsigned long dontcare) { u32 entropy; + unsigned long expires; get_random_bytes(&entropy, sizeof(entropy)); prandom_seed(entropy); + /* reseed every ~60 seconds, in [40 .. 80) interval with slack */ - seed_timer.expires = jiffies + (40 * HZ + (prandom_u32() % (40 * HZ))); + expires = 40 + (prandom_u32() % 40); + seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC); + add_timer(&seed_timer); } -static void prandom_start_seed_timer(void) +static void __init __prandom_start_seed_timer(void) { set_timer_slack(&seed_timer, HZ); - seed_timer.expires = jiffies + 40 * HZ; + seed_timer.expires = jiffies + msecs_to_jiffies(40 * MSEC_PER_SEC); add_timer(&seed_timer); } @@ -270,7 +274,7 @@ void prandom_reseed_late(void) static int __init prandom_reseed(void) { __prandom_reseed(false); - prandom_start_seed_timer(); + __prandom_start_seed_timer(); return 0; } late_initcall(prandom_reseed);