console.c (f0cd91a68acdc9b49d7f6738b514a426da627649) console.c (c10746dbb39d41e5fc27badfebe61448210c426d)
1/*
2 * USB Serial Console driver
3 *
4 * Copyright (C) 2001 - 2002 Greg Kroah-Hartman (greg@kroah.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.

--- 199 unchanged lines hidden (view full) ---

208
209 if (count == 0)
210 return;
211
212 dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
213
214 if (!port->open_count) {
215 dbg ("%s - port not opened", __FUNCTION__);
1/*
2 * USB Serial Console driver
3 *
4 * Copyright (C) 2001 - 2002 Greg Kroah-Hartman (greg@kroah.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.

--- 199 unchanged lines hidden (view full) ---

208
209 if (count == 0)
210 return;
211
212 dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
213
214 if (!port->open_count) {
215 dbg ("%s - port not opened", __FUNCTION__);
216 goto exit;
216 return;
217 }
218
217 }
218
219 /* pass on to the driver specific version of this function if it is available */
220 if (serial->type->write)
221 retval = serial->type->write(port, buf, count);
222 else
223 retval = usb_serial_generic_write(port, buf, count);
224
225exit:
226 dbg("%s - return value (if we had one): %d", __FUNCTION__, retval);
219 while (count) {
220 unsigned int i;
221 unsigned int lf;
222 /* search for LF so we can insert CR if necessary */
223 for (i=0, lf=0 ; i < count ; i++) {
224 if (*(buf + i) == 10) {
225 lf = 1;
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}
228
229static struct console usbcons = {
230 .name = "ttyUSB",
231 .write = usb_console_write,
232 .setup = usb_console_setup,
233 .flags = CON_PRINTBUFFER,
234 .index = -1,

--- 30 unchanged lines hidden ---
248}
249
250static struct console usbcons = {
251 .name = "ttyUSB",
252 .write = usb_console_write,
253 .setup = usb_console_setup,
254 .flags = CON_PRINTBUFFER,
255 .index = -1,

--- 30 unchanged lines hidden ---