[PATCH 2/22] /dev/random: Cleanup sleep logic

From: Matt Mackall
Date: Thu Mar 25 2004 - 19:00:55 EST



Cleanup /dev/random sleep logic

Original code checked in output pool rather than input pool for wakeup
Move to wait_event_interruptible style
Delete superfluous waitqueue


tiny-mpm/drivers/char/random.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)

diff -puN drivers/char/random.c~fix-random-wait drivers/char/random.c
--- tiny/drivers/char/random.c~fix-random-wait 2004-03-20 13:35:06.000000000 -0600
+++ tiny-mpm/drivers/char/random.c 2004-03-20 13:35:06.000000000 -0600
@@ -1556,9 +1556,8 @@ void rand_initialize_disk(struct gendisk
static ssize_t
random_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
{
- DECLARE_WAITQUEUE(wait, current);
- ssize_t n, retval = 0, count = 0;
-
+ ssize_t n, retval = 0, count = 0;
+
if (nbytes == 0)
return 0;

@@ -1582,20 +1581,20 @@ random_read(struct file * file, char * b
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;
}


_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/