diff options
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r-- | drivers/char/random.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index e027e7fa1472..c8ec1e70abde 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -427,7 +427,7 @@ struct crng_state primary_crng = { | |||
427 | * its value (from 0->1->2). | 427 | * its value (from 0->1->2). |
428 | */ | 428 | */ |
429 | static int crng_init = 0; | 429 | static int crng_init = 0; |
430 | #define crng_ready() (likely(crng_init > 0)) | 430 | #define crng_ready() (likely(crng_init > 1)) |
431 | static int crng_init_cnt = 0; | 431 | static int crng_init_cnt = 0; |
432 | #define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE) | 432 | #define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE) |
433 | static void _extract_crng(struct crng_state *crng, | 433 | static void _extract_crng(struct crng_state *crng, |
@@ -794,7 +794,7 @@ static int crng_fast_load(const char *cp, size_t len) | |||
794 | 794 | ||
795 | if (!spin_trylock_irqsave(&primary_crng.lock, flags)) | 795 | if (!spin_trylock_irqsave(&primary_crng.lock, flags)) |
796 | return 0; | 796 | return 0; |
797 | if (crng_ready()) { | 797 | if (crng_init != 0) { |
798 | spin_unlock_irqrestore(&primary_crng.lock, flags); | 798 | spin_unlock_irqrestore(&primary_crng.lock, flags); |
799 | return 0; | 799 | return 0; |
800 | } | 800 | } |
@@ -856,7 +856,7 @@ static void _extract_crng(struct crng_state *crng, | |||
856 | { | 856 | { |
857 | unsigned long v, flags; | 857 | unsigned long v, flags; |
858 | 858 | ||
859 | if (crng_init > 1 && | 859 | if (crng_ready() && |
860 | time_after(jiffies, crng->init_time + CRNG_RESEED_INTERVAL)) | 860 | time_after(jiffies, crng->init_time + CRNG_RESEED_INTERVAL)) |
861 | crng_reseed(crng, crng == &primary_crng ? &input_pool : NULL); | 861 | crng_reseed(crng, crng == &primary_crng ? &input_pool : NULL); |
862 | spin_lock_irqsave(&crng->lock, flags); | 862 | spin_lock_irqsave(&crng->lock, flags); |
@@ -1139,7 +1139,7 @@ void add_interrupt_randomness(int irq, int irq_flags) | |||
1139 | fast_mix(fast_pool); | 1139 | fast_mix(fast_pool); |
1140 | add_interrupt_bench(cycles); | 1140 | add_interrupt_bench(cycles); |
1141 | 1141 | ||
1142 | if (!crng_ready()) { | 1142 | if (unlikely(crng_init == 0)) { |
1143 | if ((fast_pool->count >= 64) && | 1143 | if ((fast_pool->count >= 64) && |
1144 | crng_fast_load((char *) fast_pool->pool, | 1144 | crng_fast_load((char *) fast_pool->pool, |
1145 | sizeof(fast_pool->pool))) { | 1145 | sizeof(fast_pool->pool))) { |
@@ -2212,7 +2212,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, | |||
2212 | { | 2212 | { |
2213 | struct entropy_store *poolp = &input_pool; | 2213 | struct entropy_store *poolp = &input_pool; |
2214 | 2214 | ||
2215 | if (!crng_ready()) { | 2215 | if (unlikely(crng_init == 0)) { |
2216 | crng_fast_load(buffer, count); | 2216 | crng_fast_load(buffer, count); |
2217 | return; | 2217 | return; |
2218 | } | 2218 | } |