diff options
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 | |||
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) { | |
225 | exit: | 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 | ||
229 | static struct console usbcons = { | 250 | static struct console usbcons = { |