From ea6f74faafa617a0530ca44fe8db213dc6a2d885 Mon Sep 17 00:00:00 2001 From: imoseyon Date: Thu, 3 Jan 2013 15:18:26 -0800 Subject: 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 --- drivers/char/random.c | 53 +-------------------------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) (limited to 'drivers/char') 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 -- cgit v1.2.3