Skip to content

Commit

Permalink
Char: genrtc, use wait_event_interruptible
Browse files Browse the repository at this point in the history
genrtc, use wait_event_interruptible

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Cc: Roman Zippel <[email protected]>
Cc: David Brownell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jirislaby authored and Linus Torvalds committed Jul 16, 2007
1 parent 6804396 commit e0955e1
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions drivers/char/genrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ static void gen_rtc_interrupt(unsigned long arg)
static ssize_t gen_rtc_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
DECLARE_WAITQUEUE(wait, current);
unsigned long data;
ssize_t retval;

Expand All @@ -183,18 +182,10 @@ static ssize_t gen_rtc_read(struct file *file, char __user *buf,
if (file->f_flags & O_NONBLOCK && !gen_rtc_irq_data)
return -EAGAIN;

add_wait_queue(&gen_rtc_wait, &wait);
retval = -ERESTARTSYS;

while (1) {
set_current_state(TASK_INTERRUPTIBLE);
data = xchg(&gen_rtc_irq_data, 0);
if (data)
break;
if (signal_pending(current))
goto out;
schedule();
}
retval = wait_event_interruptible(gen_rtc_wait,
(data = xchg(&gen_rtc_irq_data, 0)));
if (retval)
goto out;

/* first test allows optimizer to nuke this case for 32-bit machines */
if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) {
Expand All @@ -206,10 +197,7 @@ static ssize_t gen_rtc_read(struct file *file, char __user *buf,
retval = put_user(data, (unsigned long __user *)buf) ?:
sizeof(unsigned long);
}
out:
__set_current_state(TASK_RUNNING);
remove_wait_queue(&gen_rtc_wait, &wait);

out:
return retval;
}

Expand Down

0 comments on commit e0955e1

Please sign in to comment.