[PATCH 2.6] PPC64: janitorial HVSI use wait_event_timeout()
Linas Vepstas
linas at austin.ibm.com
Tue May 10 04:24:45 EST 2005
Hi,
I seem to be dragging around the following janitorial patch, it was
submitted upstream to LKML on March 6 2005, but seems not to have made
it in. Hollis, please review; I've been running with it for months.
--linas
Use wait_event_timeout() in place of custom wait-queue code. The
code is not changed in any way (I don't think), but is cleaned up quite a bit
(will get expanded to almost identical code).
Acked-by: Linas Vepstas <linas at austin.ibm.com>
Signed-off-by: Nishanth Aravamudan <nacc at us.ibm.com>
Signed-off-by: Domen Puncer <domen at coderock.org>
--- linux-2.6.11.8/drivers/char/hvsi.c.linas-orig 2005-04-29 20:29:25.000000000 -0500
+++ linux-2.6.11.8/drivers/char/hvsi.c 2005-05-06 12:28:43.000000000 -0500
@@ -44,6 +44,7 @@
#include <linux/sysrq.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
+#include <linux/wait.h>
#include <asm/hvcall.h>
#include <asm/hvconsole.h>
#include <asm/prom.h>
@@ -631,27 +632,9 @@ static int __init poll_for_state(struct
/* wait for irq handler to change our state */
static int wait_for_state(struct hvsi_struct *hp, int state)
{
- unsigned long end_jiffies = jiffies + HVSI_TIMEOUT;
- unsigned long timeout;
- int ret = 0;
-
- DECLARE_WAITQUEUE(myself, current);
- set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue(&hp->stateq, &myself);
-
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (hp->state == state)
- break;
- timeout = end_jiffies - jiffies;
- if (time_after(jiffies, end_jiffies)) {
- ret = -EIO;
- break;
- }
- schedule_timeout(timeout);
- }
- remove_wait_queue(&hp->stateq, &myself);
- set_current_state(TASK_RUNNING);
+ int ret=0;
+ if(!wait_event_timeout(hp->stateq, (hp->state == state), jiffies +
+ HVSI_TIMEOUT)) ret = -EIO;
return ret;
}
@@ -868,24 +851,8 @@ static int hvsi_open(struct tty_struct *
/* wait for hvsi_write_worker to empty hp->outbuf */
static void hvsi_flush_output(struct hvsi_struct *hp)
{
- unsigned long end_jiffies = jiffies + HVSI_TIMEOUT;
- unsigned long timeout;
-
- DECLARE_WAITQUEUE(myself, current);
- set_current_state(TASK_UNINTERRUPTIBLE);
- add_wait_queue(&hp->emptyq, &myself);
-
- for (;;) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- if (hp->n_outbuf <= 0)
- break;
- timeout = end_jiffies - jiffies;
- if (time_after(jiffies, end_jiffies))
- break;
- schedule_timeout(timeout);
- }
- remove_wait_queue(&hp->emptyq, &myself);
- set_current_state(TASK_RUNNING);
+ wait_event_timeout(hp->emptyq, (hp->n_outbuf <= 0), jiffies +
+ HVSI_TIMEOUT);
/* 'writer' could still be pending if it didn't see n_outbuf = 0 yet */
cancel_delayed_work(&hp->writer);
More information about the Linuxppc64-dev
mailing list