X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Fhvsi.c;h=f1f1192ba2b50ce00706f2dbb1ee9c850f338329;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=07d7e212bb18751906efdcf04aa6830ce129b3d2;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475;p=linux-2.6.git diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index 07d7e212b..f1f1192ba 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c @@ -631,27 +631,10 @@ static int __init poll_for_state(struct hvsi_struct *hp, int state) /* 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); + if (!wait_event_timeout(hp->stateq, (hp->state == state), HVSI_TIMEOUT)) + ret = -EIO; return ret; } @@ -868,24 +851,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp) /* 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), HVSI_TIMEOUT); /* 'writer' could still be pending if it didn't see n_outbuf = 0 yet */ cancel_delayed_work(&hp->writer);