aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/console.c
diff options
context:
space:
mode:
authorPaul Fulghum <paulkf@microgate.com>2006-04-13 16:26:35 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-21 18:04:09 -0400
commitc10746dbb39d41e5fc27badfebe61448210c426d (patch)
tree8e1b47bb64433e8f7f282bdcebc38f0368323775 /drivers/usb/serial/console.c
parent01cced250722d22d99c2342979490f93ca886521 (diff)
[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.c39
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
213 213
214 if (!port->open_count) { 214 if (!port->open_count) {
215 dbg ("%s - port not opened", __FUNCTION__); 215 dbg ("%s - port not opened", __FUNCTION__);
216 goto exit; 216 return;
217 } 217 }
218 218
219 /* pass on to the driver specific version of this function if it is available */ 219 while (count) {
220 if (serial->type->write) 220 unsigned int i;
221 retval = serial->type->write(port, buf, count); 221 unsigned int lf;
222 else 222 /* search for LF so we can insert CR if necessary */
223 retval = usb_serial_generic_write(port, buf, count); 223 for (i=0, lf=0 ; i < count ; i++) {
224 224 if (*(buf + i) == 10) {
225exit: 225 lf = 1;
226 dbg("%s - return value (if we had one): %d", __FUNCTION__, retval); 226 i++;
227 break;
228 }
229 }
230 /* pass on to the driver specific version of this function if it is available */
231 if (serial->type->write)
232 retval = serial->type->write(port, buf, i);
233 else
234 retval = usb_serial_generic_write(port, buf, i);
235 dbg("%s - return value : %d", __FUNCTION__, retval);
236 if (lf) {
237 /* append CR after LF */
238 unsigned char cr = 13;
239 if (serial->type->write)
240 retval = serial->type->write(port, &cr, 1);
241 else
242 retval = usb_serial_generic_write(port, &cr, 1);
243 dbg("%s - return value : %d", __FUNCTION__, retval);
244 }
245 buf += i;
246 count -= i;
247 }
227} 248}
228 249
229static struct console usbcons = { 250static struct console usbcons = {