14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/kernel.h>
18 #include <linux/slab.h>
19 #include <linux/tty.h>
21 #include <linux/serial.h>
74 while (*s >=
'0' && *s <=
'9')
81 doflow = (*s++ ==
'r');
112 if (serial ==
NULL) {
114 pr_err(
"No USB device connected to ttyUSB%i\n", co->
index);
118 retval = usb_autopm_get_interface(serial->
interface);
120 goto error_get_interface;
129 if (serial->
type->set_termios) {
139 goto reset_open_count;
141 kref_init(&tty->
kref);
154 if (serial->
type->open)
155 retval = serial->
type->open(
NULL, port);
160 dev_err(&port->
dev,
"could not open USB console port\n");
164 if (serial->
type->set_termios) {
165 tty->termios.c_cflag =
cflag;
168 serial->
type->set_termios(tty, port, &
dummy);
180 port->
port.console = 1;
190 port->
port.count = 0;
191 usb_autopm_put_interface(serial->
interface);
198 static void usb_console_write(
struct console *co,
213 pr_debug(
"%s - port %d, %d byte(s)\n", __func__, port->
number, count);
215 if (!port->
port.console) {
216 pr_debug(
"%s - port not opened\n", __func__);
224 for (i = 0, lf = 0 ; i <
count ; i++) {
225 if (*(buf + i) == 10) {
233 if (serial->
type->write)
234 retval = serial->
type->write(
NULL, port, buf, i);
237 pr_debug(
"%s - return value : %d\n", __func__, retval);
240 unsigned char cr = 13;
241 if (serial->
type->write)
247 pr_debug(
"%s - return value : %d\n", __func__, retval);
265 static struct console usbcons = {
267 .write = usb_console_write,
268 .device = usb_console_device,
269 .setup = usb_console_setup,
277 if (serial && serial->
port && serial->
port[0]
300 pr_debug(
"registering the USB serial console.\n");