diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-06 18:02:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-06 18:02:00 -0500 |
commit | 7a222156bcf010dbf77fe7d803c375bcc4a51160 (patch) | |
tree | 2689bf892bd9de873ac3887fbd6ff59bb811da38 | |
parent | 2c364faabb8ef400e4632bb989287bcd7c0a9148 (diff) | |
parent | cf833d0b9937874b50ef2867c4e8badfd64948ce (diff) |
Merge branch 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
random: Use arch_get_random_int instead of cycle counter if avail
-rw-r--r-- | drivers/char/random.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 6035ab8d5ef7..85da8740586b 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -624,8 +624,8 @@ static struct timer_rand_state input_timer_state; | |||
624 | static void add_timer_randomness(struct timer_rand_state *state, unsigned num) | 624 | static void add_timer_randomness(struct timer_rand_state *state, unsigned num) |
625 | { | 625 | { |
626 | struct { | 626 | struct { |
627 | cycles_t cycles; | ||
628 | long jiffies; | 627 | long jiffies; |
628 | unsigned cycles; | ||
629 | unsigned num; | 629 | unsigned num; |
630 | } sample; | 630 | } sample; |
631 | long delta, delta2, delta3; | 631 | long delta, delta2, delta3; |
@@ -637,7 +637,11 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) | |||
637 | goto out; | 637 | goto out; |
638 | 638 | ||
639 | sample.jiffies = jiffies; | 639 | sample.jiffies = jiffies; |
640 | sample.cycles = get_cycles(); | 640 | |
641 | /* Use arch random value, fall back to cycles */ | ||
642 | if (!arch_get_random_int(&sample.cycles)) | ||
643 | sample.cycles = get_cycles(); | ||
644 | |||
641 | sample.num = num; | 645 | sample.num = num; |
642 | mix_pool_bytes(&input_pool, &sample, sizeof(sample)); | 646 | mix_pool_bytes(&input_pool, &sample, sizeof(sample)); |
643 | 647 | ||