diff options
author | Paul Fulghum <paulkf@microgate.com> | 2006-04-13 22:26:35 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 15:04:09 -0700 |
commit | c10746dbb39d41e5fc27badfebe61448210c426d (patch) | |
tree | 8e1b47bb64433e8f7f282bdcebc38f0368323775 /drivers/usb/serial/console.c | |
parent | 01cced250722d22d99c2342979490f93ca886521 (diff) | |
download | talos-obmc-linux-c10746dbb39d41e5fc27badfebe61448210c426d.tar.gz talos-obmc-linux-c10746dbb39d41e5fc27badfebe61448210c426d.zip |
[PATCH] USB: console: fix cr/lf issues
Append Carriage-Returns after Line-Feeds, analogous to the serial driver.
From: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/console.c')
-rw-r--r-- | drivers/usb/serial/console.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 8023bb7279b1..fc4a0f731d91 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -213,17 +213,38 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun if (!port->open_count) { dbg ("%s - port not opened", __FUNCTION__); - goto exit; + return; } - /* pass on to the driver specific version of this function if it is available */ - if (serial->type->write) - retval = serial->type->write(port, buf, count); - else - retval = usb_serial_generic_write(port, buf, count); - -exit: - dbg("%s - return value (if we had one): %d", __FUNCTION__, retval); + while (count) { + unsigned int i; + unsigned int lf; + /* search for LF so we can insert CR if necessary */ + for (i=0, lf=0 ; i < count ; i++) { + if (*(buf + i) == 10) { + lf = 1; + i++; + break; + } + } + /* pass on to the driver specific version of this function if it is available */ + if (serial->type->write) + retval = serial->type->write(port, buf, i); + else + retval = usb_serial_generic_write(port, buf, i); + dbg("%s - return value : %d", __FUNCTION__, retval); + if (lf) { + /* append CR after LF */ + unsigned char cr = 13; + if (serial->type->write) + retval = serial->type->write(port, &cr, 1); + else + retval = usb_serial_generic_write(port, &cr, 1); + dbg("%s - return value : %d", __FUNCTION__, retval); + } + buf += i; + count -= i; + } } static struct console usbcons = { |