Skip to content

Commit

Permalink
Merge branch 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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
  • Loading branch information
torvalds committed Jan 6, 2012
2 parents 2c364fa + cf833d0 commit 7a22215
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ static struct timer_rand_state input_timer_state;
static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
{
struct {
cycles_t cycles;
long jiffies;
unsigned cycles;
unsigned num;
} sample;
long delta, delta2, delta3;
Expand All @@ -637,7 +637,11 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
goto out;

sample.jiffies = jiffies;
sample.cycles = get_cycles();

/* Use arch random value, fall back to cycles */
if (!arch_get_random_int(&sample.cycles))
sample.cycles = get_cycles();

sample.num = num;
mix_pool_bytes(&input_pool, &sample, sizeof(sample));

Expand Down

0 comments on commit 7a22215

Please sign in to comment.