diff options
author | Matt Mackall <mpm@selenic.com> | 2008-04-29 04:02:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:24 -0400 |
commit | 88c730da8c8b20fa732221725347bd9460842bac (patch) | |
tree | f792b1a388eb4b5c74bfcda340ea207701efa5aa /drivers/char/random.c | |
parent | 90b75ee54666fe615ebcacfc8d8540b80afdedd5 (diff) |
random: consolidate wakeup logic
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>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r-- | drivers/char/random.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 32118598a71b..46944088cf94 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -540,6 +540,10 @@ static void credit_entropy_store(struct entropy_store *r, int nbits) | |||
540 | nbits, r->name); | 540 | nbits, r->name); |
541 | } | 541 | } |
542 | 542 | ||
543 | /* should we wake readers? */ | ||
544 | if (r == &input_pool && r->entropy_count >= random_read_wakeup_thresh) | ||
545 | wake_up_interruptible(&random_read_wait); | ||
546 | |||
543 | spin_unlock_irqrestore(&r->lock, flags); | 547 | spin_unlock_irqrestore(&r->lock, flags); |
544 | } | 548 | } |
545 | 549 | ||
@@ -624,10 +628,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) | |||
624 | credit_entropy_store(&input_pool, | 628 | credit_entropy_store(&input_pool, |
625 | min_t(int, fls(delta>>1), 11)); | 629 | min_t(int, fls(delta>>1), 11)); |
626 | } | 630 | } |
627 | |||
628 | if (input_pool.entropy_count >= random_read_wakeup_thresh) | ||
629 | wake_up_interruptible(&random_read_wait); | ||
630 | |||
631 | out: | 631 | out: |
632 | preempt_enable(); | 632 | preempt_enable(); |
633 | } | 633 | } |
@@ -1081,12 +1081,6 @@ static int random_ioctl(struct inode *inode, struct file *file, | |||
1081 | if (get_user(ent_count, p)) | 1081 | if (get_user(ent_count, p)) |
1082 | return -EFAULT; | 1082 | return -EFAULT; |
1083 | credit_entropy_store(&input_pool, ent_count); | 1083 | credit_entropy_store(&input_pool, ent_count); |
1084 | /* | ||
1085 | * Wake up waiting processes if we have enough | ||
1086 | * entropy. | ||
1087 | */ | ||
1088 | if (input_pool.entropy_count >= random_read_wakeup_thresh) | ||
1089 | wake_up_interruptible(&random_read_wait); | ||
1090 | return 0; | 1084 | return 0; |
1091 | case RNDADDENTROPY: | 1085 | case RNDADDENTROPY: |
1092 | if (!capable(CAP_SYS_ADMIN)) | 1086 | if (!capable(CAP_SYS_ADMIN)) |
@@ -1102,12 +1096,6 @@ static int random_ioctl(struct inode *inode, struct file *file, | |||
1102 | if (retval < 0) | 1096 | if (retval < 0) |
1103 | return retval; | 1097 | return retval; |
1104 | credit_entropy_store(&input_pool, ent_count); | 1098 | credit_entropy_store(&input_pool, ent_count); |
1105 | /* | ||
1106 | * Wake up waiting processes if we have enough | ||
1107 | * entropy. | ||
1108 | */ | ||
1109 | if (input_pool.entropy_count >= random_read_wakeup_thresh) | ||
1110 | wake_up_interruptible(&random_read_wait); | ||
1111 | return 0; | 1099 | return 0; |
1112 | case RNDZAPENTCNT: | 1100 | case RNDZAPENTCNT: |
1113 | case RNDCLEARPOOL: | 1101 | case RNDCLEARPOOL: |