diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/random.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 2faeef28c209..0cf98bd4f2d2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -370,6 +370,7 @@ static struct poolinfo { | |||
370 | */ | 370 | */ |
371 | static DECLARE_WAIT_QUEUE_HEAD(random_read_wait); | 371 | static DECLARE_WAIT_QUEUE_HEAD(random_read_wait); |
372 | static DECLARE_WAIT_QUEUE_HEAD(random_write_wait); | 372 | static DECLARE_WAIT_QUEUE_HEAD(random_write_wait); |
373 | static struct fasync_struct *fasync; | ||
373 | 374 | ||
374 | #if 0 | 375 | #if 0 |
375 | static int debug; | 376 | static int debug; |
@@ -533,8 +534,11 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) | |||
533 | r->entropy_count = r->poolinfo->POOLBITS; | 534 | r->entropy_count = r->poolinfo->POOLBITS; |
534 | 535 | ||
535 | /* should we wake readers? */ | 536 | /* should we wake readers? */ |
536 | if (r == &input_pool && r->entropy_count >= random_read_wakeup_thresh) | 537 | if (r == &input_pool && |
538 | r->entropy_count >= random_read_wakeup_thresh) { | ||
537 | wake_up_interruptible(&random_read_wait); | 539 | wake_up_interruptible(&random_read_wait); |
540 | kill_fasync(&fasync, SIGIO, POLL_IN); | ||
541 | } | ||
538 | 542 | ||
539 | spin_unlock_irqrestore(&r->lock, flags); | 543 | spin_unlock_irqrestore(&r->lock, flags); |
540 | } | 544 | } |
@@ -742,8 +746,10 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
742 | else | 746 | else |
743 | r->entropy_count = reserved; | 747 | r->entropy_count = reserved; |
744 | 748 | ||
745 | if (r->entropy_count < random_write_wakeup_thresh) | 749 | if (r->entropy_count < random_write_wakeup_thresh) { |
746 | wake_up_interruptible(&random_write_wait); | 750 | wake_up_interruptible(&random_write_wait); |
751 | kill_fasync(&fasync, SIGIO, POLL_OUT); | ||
752 | } | ||
747 | } | 753 | } |
748 | 754 | ||
749 | DEBUG_ENT("debiting %d entropy credits from %s%s\n", | 755 | DEBUG_ENT("debiting %d entropy credits from %s%s\n", |
@@ -1100,17 +1106,31 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | |||
1100 | } | 1106 | } |
1101 | } | 1107 | } |
1102 | 1108 | ||
1109 | static int random_fasync(int fd, struct file *filp, int on) | ||
1110 | { | ||
1111 | return fasync_helper(fd, filp, on, &fasync); | ||
1112 | } | ||
1113 | |||
1114 | static int random_release(struct inode *inode, struct file *filp) | ||
1115 | { | ||
1116 | return fasync_helper(-1, filp, 0, &fasync); | ||
1117 | } | ||
1118 | |||
1103 | const struct file_operations random_fops = { | 1119 | const struct file_operations random_fops = { |
1104 | .read = random_read, | 1120 | .read = random_read, |
1105 | .write = random_write, | 1121 | .write = random_write, |
1106 | .poll = random_poll, | 1122 | .poll = random_poll, |
1107 | .unlocked_ioctl = random_ioctl, | 1123 | .unlocked_ioctl = random_ioctl, |
1124 | .fasync = random_fasync, | ||
1125 | .release = random_release, | ||
1108 | }; | 1126 | }; |
1109 | 1127 | ||
1110 | const struct file_operations urandom_fops = { | 1128 | const struct file_operations urandom_fops = { |
1111 | .read = urandom_read, | 1129 | .read = urandom_read, |
1112 | .write = random_write, | 1130 | .write = random_write, |
1113 | .unlocked_ioctl = random_ioctl, | 1131 | .unlocked_ioctl = random_ioctl, |
1132 | .fasync = random_fasync, | ||
1133 | .release = random_release, | ||
1114 | }; | 1134 | }; |
1115 | 1135 | ||
1116 | /*************************************************************** | 1136 | /*************************************************************** |