mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 17:11:46 +00:00
[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>
This commit is contained in:
parent
01cced2507
commit
c10746dbb3
1 changed files with 30 additions and 9 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
/* pass on to the driver specific version of this function if it is available */
|
||||||
if (serial->type->write)
|
if (serial->type->write)
|
||||||
retval = serial->type->write(port, buf, count);
|
retval = serial->type->write(port, buf, i);
|
||||||
else
|
else
|
||||||
retval = usb_serial_generic_write(port, buf, count);
|
retval = usb_serial_generic_write(port, buf, i);
|
||||||
|
dbg("%s - return value : %d", __FUNCTION__, retval);
|
||||||
exit:
|
if (lf) {
|
||||||
dbg("%s - return value (if we had one): %d", __FUNCTION__, retval);
|
/* 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 = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue