Commit c10746db authored by Paul Fulghum's avatar Paul Fulghum Committed by Greg Kroah-Hartman

[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: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 01cced25
...@@ -213,17 +213,38 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun ...@@ -213,17 +213,38 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
if (!port->open_count) { if (!port->open_count) {
dbg ("%s - port not opened", __FUNCTION__); dbg ("%s - port not opened", __FUNCTION__);
goto exit; return;
} }
/* pass on to the driver specific version of this function if it is available */ while (count) {
if (serial->type->write) unsigned int i;
retval = serial->type->write(port, buf, count); unsigned int lf;
else /* search for LF so we can insert CR if necessary */
retval = usb_serial_generic_write(port, buf, count); for (i=0, lf=0 ; i < count ; i++) {
if (*(buf + i) == 10) {
exit: lf = 1;
dbg("%s - return value (if we had one): %d", __FUNCTION__, retval); 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 = { static struct console usbcons = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment