diff options
author | Matt Mackall <mpm@selenic.com> | 2008-04-29 04:03:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:25 -0400 |
commit | feee76972bcc54b2b1d1dc28bc6c16a8daa9aff8 (patch) | |
tree | db031968e6a4f76b060298d5d0b3499566ad944d | |
parent | 433582093a9dc5454ba03b4a7ea201d85e6aa4de (diff) |
random: eliminate redundant new_rotate variable
- eliminate new_rotate
- move input_rotate masking
- simplify input_rotate update
- move input_rotate update to end of inner loop for readability
Signed-off-by: Matt Mackall <mpm@selenic.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/char/random.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 973706e97e77..3823cb2e3b9a 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -455,7 +455,7 @@ static void __add_entropy_words(struct entropy_store *r, const __u32 *in, | |||
455 | 0x00000000, 0x3b6e20c8, 0x76dc4190, 0x4db26158, | 455 | 0x00000000, 0x3b6e20c8, 0x76dc4190, 0x4db26158, |
456 | 0xedb88320, 0xd6d6a3e8, 0x9b64c2b0, 0xa00ae278 }; | 456 | 0xedb88320, 0xd6d6a3e8, 0x9b64c2b0, 0xa00ae278 }; |
457 | unsigned long i, add_ptr, tap1, tap2, tap3, tap4, tap5; | 457 | unsigned long i, add_ptr, tap1, tap2, tap3, tap4, tap5; |
458 | int new_rotate, input_rotate; | 458 | int input_rotate; |
459 | int wordmask = r->poolinfo->poolwords - 1; | 459 | int wordmask = r->poolinfo->poolwords - 1; |
460 | __u32 w, next_w; | 460 | __u32 w, next_w; |
461 | unsigned long flags; | 461 | unsigned long flags; |
@@ -474,20 +474,10 @@ static void __add_entropy_words(struct entropy_store *r, const __u32 *in, | |||
474 | add_ptr = r->add_ptr; | 474 | add_ptr = r->add_ptr; |
475 | 475 | ||
476 | while (nwords--) { | 476 | while (nwords--) { |
477 | w = rol32(next_w, input_rotate); | 477 | w = rol32(next_w, input_rotate & 31); |
478 | if (nwords > 0) | 478 | if (nwords > 0) |
479 | next_w = *in++; | 479 | next_w = *in++; |
480 | i = add_ptr = (add_ptr - 1) & wordmask; | 480 | i = add_ptr = (add_ptr - 1) & wordmask; |
481 | /* | ||
482 | * Normally, we add 7 bits of rotation to the pool. | ||
483 | * At the beginning of the pool, add an extra 7 bits | ||
484 | * rotation, so that successive passes spread the | ||
485 | * input bits across the pool evenly. | ||
486 | */ | ||
487 | new_rotate = input_rotate + 14; | ||
488 | if (i) | ||
489 | new_rotate = input_rotate + 7; | ||
490 | input_rotate = new_rotate & 31; | ||
491 | 481 | ||
492 | /* XOR in the various taps */ | 482 | /* XOR in the various taps */ |
493 | w ^= r->pool[(i + tap1) & wordmask]; | 483 | w ^= r->pool[(i + tap1) & wordmask]; |
@@ -497,6 +487,14 @@ static void __add_entropy_words(struct entropy_store *r, const __u32 *in, | |||
497 | w ^= r->pool[(i + tap5) & wordmask]; | 487 | w ^= r->pool[(i + tap5) & wordmask]; |
498 | w ^= r->pool[i]; | 488 | w ^= r->pool[i]; |
499 | r->pool[i] = (w >> 3) ^ twist_table[w & 7]; | 489 | r->pool[i] = (w >> 3) ^ twist_table[w & 7]; |
490 | |||
491 | /* | ||
492 | * Normally, we add 7 bits of rotation to the pool. | ||
493 | * At the beginning of the pool, add an extra 7 bits | ||
494 | * rotation, so that successive passes spread the | ||
495 | * input bits across the pool evenly. | ||
496 | */ | ||
497 | input_rotate += i ? 7 : 14; | ||
500 | } | 498 | } |
501 | 499 | ||
502 | r->input_rotate = input_rotate; | 500 | r->input_rotate = input_rotate; |