From c59dbcadd5d125ba40595612dc91ab18924164d3 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Tue, 16 Oct 2007 01:26:42 -0700 Subject: uml: fix console writing bugs The previous console cleanup patch switched generic_read and generic_write from calling os_{read,write}_file to calling read and write directly. Because the calling convention is different, they now need to get any error from errno rather than the return value. I did this for generic_read, but forgot about generic_write. While chasing some output corruption, I noticed that line_write was unnecessarily calling flush_buffer, and deleted it. I don't understand why, but the corruption disappeared. This is unneeded because there already is a perfectly good mechanism for finding out when the host output device has some room to write data - there is an interrupt that comes in when writes can happen again. line_write calling flush_buffer seemed to just be an attempt to opportunistically get some data out to the host. I also made write_chan short-circuit calling into the host-level code for zero-length writes. Calling libc write with a length of zero conflated write not being able to write anything with asking it not to write anything. Better to just cut it off as soon as possible. Signed-off-by: Jeff Dike Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'arch/um/drivers/line.c') diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 3e0b68e297f2..b4538dfb4820 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -216,18 +216,15 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len) { struct line *line = tty->driver_data; unsigned long flags; - int n, err, ret = 0; + int n, ret = 0; if(tty->stopped) return 0; spin_lock_irqsave(&line->lock, flags); - if (line->head != line->tail) { + if (line->head != line->tail) ret = buffer_data(line, buf, len); - err = flush_buffer(line); - if (err <= 0 && (err != -EAGAIN || !ret)) - ret = err; - } else { + else { n = write_chan(&line->chan_list, buf, len, line->driver->write_irq); if (n < 0) { -- cgit v1.2.3-59-g8ed1b