Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116960
b: refs/heads/master
c: 3feebbb
h: refs/heads/master
v: v3
  • Loading branch information
Hendrik Brueckner authored and Benjamin Herrenschmidt committed Oct 21, 2008
1 parent c71ae24 commit af78524
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 56ce9e2b2463b3b257098aa966586701d9967f1e
refs/heads/master: 3feebbb5492e9e463467cefb633e23a3dfcec132
20 changes: 11 additions & 9 deletions trunk/drivers/char/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void hvc_console_print(struct console *co, const char *b,
}
} else {
r = cons_ops[index]->put_chars(vtermnos[index], c, i);
if (r < 0) {
if (r <= 0) {
/* throw away chars on error */
i = 0;
} else if (r > 0) {
Expand Down Expand Up @@ -431,15 +431,15 @@ static void hvc_hangup(struct tty_struct *tty)
* Push buffered characters whether they were just recently buffered or waiting
* on a blocked hypervisor. Call this function with hp->lock held.
*/
static void hvc_push(struct hvc_struct *hp)
static int hvc_push(struct hvc_struct *hp)
{
int n;

n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
if (n <= 0) {
if (n == 0) {
hp->do_wakeup = 1;
return;
return 0;
}
/* throw away output on error; this happens when
there is no session connected to the vterm. */
Expand All @@ -450,6 +450,8 @@ static void hvc_push(struct hvc_struct *hp)
memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf);
else
hp->do_wakeup = 1;

return n;
}

static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
Expand Down Expand Up @@ -538,16 +540,20 @@ int hvc_poll(struct hvc_struct *hp)
char buf[N_INBUF] __ALIGNED__;
unsigned long flags;
int read_total = 0;
int written_total = 0;

spin_lock_irqsave(&hp->lock, flags);

/* Push pending writes */
if (hp->n_outbuf > 0)
hvc_push(hp);
written_total = hvc_push(hp);

/* Reschedule us if still some write pending */
if (hp->n_outbuf > 0)
if (hp->n_outbuf > 0) {
poll_mask |= HVC_POLL_WRITE;
/* If hvc_push() was not able to write, sleep a few msecs */
timeout = (written_total) ? 0 : MIN_TIMEOUT;
}

/* No tty attached, just skip */
tty = hp->tty;
Expand Down Expand Up @@ -659,10 +665,6 @@ static int khvcd(void *unused)
poll_mask |= HVC_POLL_READ;
if (hvc_kicked)
continue;
if (poll_mask & HVC_POLL_WRITE) {
yield();
continue;
}
set_current_state(TASK_INTERRUPTIBLE);
if (!hvc_kicked) {
if (poll_mask == 0)
Expand Down

0 comments on commit af78524

Please sign in to comment.