From: Paul Fulghum <[EMAIL PROTECTED]>

Append Carriage-Returns after Line-Feeds, analogous to the serial driver.

From: Paul Fulghum <[EMAIL PROTECTED]>
Signed-off-by: Guennadi Liakhovetski <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 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 8023bb7..fc4a0f7 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -213,17 +213,38 @@ static void usb_console_write(struct con
 
        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 = {
-- 
1.4.0


All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to