From: Jiri Slaby <jirislaby@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: <a.zummo@towertech.it>
Subject: [PATCH 6/8] Char: rtc, use wait_event_interruptible
Date: Mon, 28 May 2007 15:29:50 +0200 (CEST) [thread overview]
Message-ID: <1365159682097121268@wsc.cz> (raw)
In-Reply-To: <12191294601255228079@wsc.cz>
rtc, use wait_event_interruptible
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 62bd843054a7b2b2a3e3003a6b57b6359f199837
tree 7c6912d4ed42581ca46d384ab2467bfb9d9d9dbe
parent 2b7813d0f34703e0a4b18593a3186bdc7e719c06
author Jiri Slaby <jirislaby@gmail.com> Sat, 26 May 2007 21:58:54 +0200
committer Jiri Slaby <jirislaby@gmail.com> Sat, 26 May 2007 21:58:54 +0200
drivers/char/rtc.c | 40 +++++++++++++++-------------------------
1 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 20380a2..787b520 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -353,33 +353,26 @@ static ssize_t rtc_read(struct file *file, char __user *buf,
if (count != sizeof(unsigned int) && count != sizeof(unsigned long))
return -EINVAL;
- add_wait_queue(&rtc_wait, &wait);
-
- do {
- /* First make it right. Then make it fast. Putting this whole
- * block within the parentheses of a while would be too
- * confusing. And no, xchg() is not the answer. */
-
- __set_current_state(TASK_INTERRUPTIBLE);
-
- spin_lock_irq (&rtc_lock);
- data = rtc_irq_data;
- rtc_irq_data = 0;
- spin_unlock_irq (&rtc_lock);
-
- if (data != 0)
- break;
+ spin_lock_irq (&rtc_lock);
+ data = rtc_irq_data;
+ rtc_irq_data = 0;
+ spin_unlock_irq (&rtc_lock);
+ if (data == 0) {
if (file->f_flags & O_NONBLOCK) {
retval = -EAGAIN;
goto out;
}
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
+ retval = wait_event_interruptible(rtc_wait, ({
+ spin_lock_irq (&rtc_lock);
+ data = rtc_irq_data;
+ rtc_irq_data = 0;
+ spin_unlock_irq (&rtc_lock);
+ data;
+ }));
+ if (retval)
goto out;
- }
- schedule();
- } while (1);
+ }
if (count == sizeof(unsigned int))
retval = put_user(data, (unsigned int __user *)buf) ?: sizeof(int);
@@ -387,10 +380,7 @@ static ssize_t rtc_read(struct file *file, char __user *buf,
retval = put_user(data, (unsigned long __user *)buf) ?: sizeof(long);
if (!retval)
retval = count;
- out:
- __set_current_state(TASK_RUNNING);
- remove_wait_queue(&rtc_wait, &wait);
-
+out:
return retval;
#endif
}
next prev parent reply other threads:[~2007-05-28 13:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-28 13:26 [PATCH 1/8] Char: mxser_new, fix sparse warning Jiri Slaby
2007-05-28 13:27 ` [PATCH 2/8] Char: tty_ioctl, use wait_event_interruptible_timeout Jiri Slaby
2007-05-28 13:27 ` [PATCH 3/8] Char: tty_ioctl, little whitespace cleanup Jiri Slaby
2007-05-28 13:28 ` [PATCH 4/8] Char: genrtc, use wait_event_interruptible Jiri Slaby
2007-05-28 13:29 ` [PATCH 5/8] Char: n_r3964, " Jiri Slaby
2007-05-28 13:29 ` Jiri Slaby [this message]
2007-05-30 0:02 ` [PATCH 6/8] Char: rtc, " Andrew Morton
2007-05-28 13:30 ` [PATCH 7/8] Char: ip2, use msleep for sleeping Jiri Slaby
2007-05-28 13:31 ` [PATCH 8/8] Char: vt_ioctl, use wait_event_interruptible Jiri Slaby
2007-05-30 0:08 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365159682097121268@wsc.cz \
--to=jirislaby@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome