Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Char: genrtc, use wait_event_interruptible

genrtc, use wait_event_interruptible

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jiri Slaby and committed by
Linus Torvalds
e0955e14 6804396f

+5 -17
+5 -17
drivers/char/genrtc.c
··· 173 173 static ssize_t gen_rtc_read(struct file *file, char __user *buf, 174 174 size_t count, loff_t *ppos) 175 175 { 176 - DECLARE_WAITQUEUE(wait, current); 177 176 unsigned long data; 178 177 ssize_t retval; 179 178 ··· 182 183 if (file->f_flags & O_NONBLOCK && !gen_rtc_irq_data) 183 184 return -EAGAIN; 184 185 185 - add_wait_queue(&gen_rtc_wait, &wait); 186 - retval = -ERESTARTSYS; 187 - 188 - while (1) { 189 - set_current_state(TASK_INTERRUPTIBLE); 190 - data = xchg(&gen_rtc_irq_data, 0); 191 - if (data) 192 - break; 193 - if (signal_pending(current)) 194 - goto out; 195 - schedule(); 196 - } 186 + retval = wait_event_interruptible(gen_rtc_wait, 187 + (data = xchg(&gen_rtc_irq_data, 0))); 188 + if (retval) 189 + goto out; 197 190 198 191 /* first test allows optimizer to nuke this case for 32-bit machines */ 199 192 if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { ··· 197 206 retval = put_user(data, (unsigned long __user *)buf) ?: 198 207 sizeof(unsigned long); 199 208 } 200 - out: 201 - __set_current_state(TASK_RUNNING); 202 - remove_wait_queue(&gen_rtc_wait, &wait); 203 - 209 + out: 204 210 return retval; 205 211 } 206 212