mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: <rz@linux-m68k.org>
Subject: [PATCH 4/8] Char: genrtc, use wait_event_interruptible
Date: Mon, 28 May 2007 15:28:26 +0200 (CEST)	[thread overview]
Message-ID: <24123155773117716452@wsc.cz> (raw)
In-Reply-To: <12191294601255228079@wsc.cz>

genrtc, use wait_event_interruptible

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit d45ae897fff813cf27d5d6ddfd92d19806831965
tree 8c985cb371c7d22c4ae939b27fe56705274452dc
parent 68362b19a0b8b05ce81b8d17743f2d0fceedb81b
author Jiri Slaby <jirislaby@gmail.com> Sat, 26 May 2007 21:26:32 +0200
committer Jiri Slaby <jirislaby@gmail.com> Sat, 26 May 2007 21:26:32 +0200

 drivers/char/genrtc.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 9e1fc02..69f0a29 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -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;
 
@@ -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)) {
@@ -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;
 }
 

  parent reply	other threads:[~2007-05-28 13:28 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 ` Jiri Slaby [this message]
2007-05-28 13:29 ` [PATCH 5/8] Char: n_r3964, use wait_event_interruptible Jiri Slaby
2007-05-28 13:29 ` [PATCH 6/8] Char: rtc, " Jiri Slaby
2007-05-30  0:02   ` 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=24123155773117716452@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