diff options
| author | imoseyon <imoseyon@gmail.com> | 2013-01-03 15:18:26 -0800 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2016-09-10 12:06:10 +0200 |
| commit | ea6f74faafa617a0530ca44fe8db213dc6a2d885 (patch) | |
| tree | f6065018d8ff9d2849c6c1b19ed168496a2af1b1 | |
| parent | 2a3fdd1064c83a11232f4a130e287d9c6259de85 (diff) | |
random: entropy tweaks are all the rage nowadays
use non-blocking pool for all
http://lwn.net/Articles/489734/
Conflicts:
drivers/char/random.c
Conflicts:
drivers/char/random.c
| -rw-r--r-- | drivers/char/random.c | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index aee3464a5..ce354816a 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1157,58 +1157,7 @@ void rand_initialize_disk(struct gendisk *disk) static ssize_t random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { - ssize_t n, retval = 0, count = 0; - - if (nbytes == 0) - return 0; - - while (nbytes > 0) { - n = nbytes; - if (n > SEC_XFER_SIZE) - n = SEC_XFER_SIZE; - - DEBUG_ENT("reading %zu bits\n", n*8); - - n = extract_entropy_user(&blocking_pool, buf, n); - - if (n < 0) { - retval = n; - break; - } - - DEBUG_ENT("read got %zd bits (%zd still needed)\n", - n*8, (nbytes-n)*8); - - if (n == 0) { - if (file->f_flags & O_NONBLOCK) { - retval = -EAGAIN; - break; - } - - DEBUG_ENT("sleeping?\n"); - - wait_event_interruptible(random_read_wait, - input_pool.entropy_count >= - random_read_wakeup_thresh); - - DEBUG_ENT("awake\n"); - - if (signal_pending(current)) { - retval = -ERESTARTSYS; - break; - } - - continue; - } - - count += n; - buf += n; - nbytes -= n; - break; /* This break makes the device work */ - /* like a named pipe */ - } - - return (count ? count : retval); + return extract_entropy_user(&nonblocking_pool, buf, nbytes); } static ssize_t |
