
From: Matt Mackall <mpm@selenic.com>

Original code checked in output pool for missed wakeup avoidance, while waker
(batch_entropy_process) checked input pool which could result in a missed
wakeup.

- Move to wait_event_interruptible style

- Delete superfluous waitqueue

Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/char/random.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff -puN drivers/char/random.c~random-pt2-cleanup-waitqueue-logic-fix-missed-wakeup drivers/char/random.c
--- 25/drivers/char/random.c~random-pt2-cleanup-waitqueue-logic-fix-missed-wakeup	2005-03-07 20:41:46.000000000 -0800
+++ 25-akpm/drivers/char/random.c	2005-03-07 21:14:22.000000000 -0800
@@ -1587,7 +1587,6 @@ void rand_initialize_disk(struct gendisk
 static ssize_t
 random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
 {
-	DECLARE_WAITQUEUE(wait, current);
 	ssize_t n, retval = 0, count = 0;
 
 	if (nbytes == 0)
@@ -1613,20 +1612,20 @@ random_read(struct file * file, char __u
 				retval = -EAGAIN;
 				break;
 			}
+
+			DEBUG_ENT("sleeping?\n");
+
+			wait_event_interruptible(random_read_wait,
+				random_state->entropy_count >=
+						 random_read_wakeup_thresh);
+
+			DEBUG_ENT("awake\n");
+
 			if (signal_pending(current)) {
 				retval = -ERESTARTSYS;
 				break;
 			}
 
-			set_current_state(TASK_INTERRUPTIBLE);
-			add_wait_queue(&random_read_wait, &wait);
-
-			if (sec_random_state->entropy_count / 8 == 0)
-				schedule();
-
-			set_current_state(TASK_RUNNING);
-			remove_wait_queue(&random_read_wait, &wait);
-
 			continue;
 		}
 
_
