diff options
-rw-r--r-- | drivers/char/random.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index cd888d4ee605..a8fb0020ba5c 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -402,8 +402,7 @@ static struct poolinfo { | |||
402 | /* | 402 | /* |
403 | * Static global variables | 403 | * Static global variables |
404 | */ | 404 | */ |
405 | static DECLARE_WAIT_QUEUE_HEAD(random_read_wait); | 405 | static DECLARE_WAIT_QUEUE_HEAD(random_wait); |
406 | static DECLARE_WAIT_QUEUE_HEAD(random_write_wait); | ||
407 | static struct fasync_struct *fasync; | 406 | static struct fasync_struct *fasync; |
408 | 407 | ||
409 | static DEFINE_SPINLOCK(random_ready_list_lock); | 408 | static DEFINE_SPINLOCK(random_ready_list_lock); |
@@ -722,8 +721,8 @@ retry: | |||
722 | 721 | ||
723 | /* should we wake readers? */ | 722 | /* should we wake readers? */ |
724 | if (entropy_bits >= random_read_wakeup_bits && | 723 | if (entropy_bits >= random_read_wakeup_bits && |
725 | wq_has_sleeper(&random_read_wait)) { | 724 | wq_has_sleeper(&random_wait)) { |
726 | wake_up_interruptible(&random_read_wait); | 725 | wake_up_interruptible_poll(&random_wait, POLLIN); |
727 | kill_fasync(&fasync, SIGIO, POLL_IN); | 726 | kill_fasync(&fasync, SIGIO, POLL_IN); |
728 | } | 727 | } |
729 | /* If the input pool is getting full, send some | 728 | /* If the input pool is getting full, send some |
@@ -1397,7 +1396,7 @@ retry: | |||
1397 | trace_debit_entropy(r->name, 8 * ibytes); | 1396 | trace_debit_entropy(r->name, 8 * ibytes); |
1398 | if (ibytes && | 1397 | if (ibytes && |
1399 | (r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) { | 1398 | (r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) { |
1400 | wake_up_interruptible(&random_write_wait); | 1399 | wake_up_interruptible_poll(&random_wait, POLLOUT); |
1401 | kill_fasync(&fasync, SIGIO, POLL_OUT); | 1400 | kill_fasync(&fasync, SIGIO, POLL_OUT); |
1402 | } | 1401 | } |
1403 | 1402 | ||
@@ -1839,7 +1838,7 @@ _random_read(int nonblock, char __user *buf, size_t nbytes) | |||
1839 | if (nonblock) | 1838 | if (nonblock) |
1840 | return -EAGAIN; | 1839 | return -EAGAIN; |
1841 | 1840 | ||
1842 | wait_event_interruptible(random_read_wait, | 1841 | wait_event_interruptible(random_wait, |
1843 | ENTROPY_BITS(&input_pool) >= | 1842 | ENTROPY_BITS(&input_pool) >= |
1844 | random_read_wakeup_bits); | 1843 | random_read_wakeup_bits); |
1845 | if (signal_pending(current)) | 1844 | if (signal_pending(current)) |
@@ -1876,14 +1875,17 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | |||
1876 | return ret; | 1875 | return ret; |
1877 | } | 1876 | } |
1878 | 1877 | ||
1878 | static struct wait_queue_head * | ||
1879 | random_get_poll_head(struct file *file, __poll_t events) | ||
1880 | { | ||
1881 | return &random_wait; | ||
1882 | } | ||
1883 | |||
1879 | static __poll_t | 1884 | static __poll_t |
1880 | random_poll(struct file *file, poll_table * wait) | 1885 | random_poll_mask(struct file *file, __poll_t events) |
1881 | { | 1886 | { |
1882 | __poll_t mask; | 1887 | __poll_t mask = 0; |
1883 | 1888 | ||
1884 | poll_wait(file, &random_read_wait, wait); | ||
1885 | poll_wait(file, &random_write_wait, wait); | ||
1886 | mask = 0; | ||
1887 | if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits) | 1889 | if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits) |
1888 | mask |= EPOLLIN | EPOLLRDNORM; | 1890 | mask |= EPOLLIN | EPOLLRDNORM; |
1889 | if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits) | 1891 | if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits) |
@@ -1990,7 +1992,8 @@ static int random_fasync(int fd, struct file *filp, int on) | |||
1990 | const struct file_operations random_fops = { | 1992 | const struct file_operations random_fops = { |
1991 | .read = random_read, | 1993 | .read = random_read, |
1992 | .write = random_write, | 1994 | .write = random_write, |
1993 | .poll = random_poll, | 1995 | .get_poll_head = random_get_poll_head, |
1996 | .poll_mask = random_poll_mask, | ||
1994 | .unlocked_ioctl = random_ioctl, | 1997 | .unlocked_ioctl = random_ioctl, |
1995 | .fasync = random_fasync, | 1998 | .fasync = random_fasync, |
1996 | .llseek = noop_llseek, | 1999 | .llseek = noop_llseek, |
@@ -2323,7 +2326,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, | |||
2323 | * We'll be woken up again once below random_write_wakeup_thresh, | 2326 | * We'll be woken up again once below random_write_wakeup_thresh, |
2324 | * or when the calling thread is about to terminate. | 2327 | * or when the calling thread is about to terminate. |
2325 | */ | 2328 | */ |
2326 | wait_event_interruptible(random_write_wait, kthread_should_stop() || | 2329 | wait_event_interruptible(random_wait, kthread_should_stop() || |
2327 | ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits); | 2330 | ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits); |
2328 | mix_pool_bytes(poolp, buffer, count); | 2331 | mix_pool_bytes(poolp, buffer, count); |
2329 | credit_entropy_bits(poolp, entropy); | 2332 | credit_entropy_bits(poolp, entropy); |