diff options
Diffstat (limited to 'drivers/usb/serial/console.c')
| -rw-r--r-- | drivers/usb/serial/console.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 1ee6b2ab0f8..8d7fc48b1f3 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -11,8 +11,9 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/kernel.h> -#include <linux/init.h> #include <linux/slab.h> #include <linux/tty.h> #include <linux/console.h> @@ -20,8 +21,6 @@ #include <linux/usb.h> #include <linux/usb/serial.h> -static int debug; - struct usbcons_info { int magic; int break_flag; @@ -68,8 +67,6 @@ static int usb_console_setup(struct console *co, char *options) struct tty_struct *tty = NULL; struct ktermios dummy; - dbg("%s", __func__); - if (options) { baud = simple_strtoul(options, NULL, 10); s = options; @@ -110,18 +107,18 @@ static int usb_console_setup(struct console *co, char *options) * no need to check the index here: if the index is wrong, console * code won't call us */ - serial = usb_serial_get_by_index(co->index); - if (serial == NULL) { + port = usb_serial_port_get_by_minor(co->index); + if (port == NULL) { /* no device is connected yet, sorry :( */ - err("No USB device connected to ttyUSB%i", co->index); + pr_err("No USB device connected to ttyUSB%i\n", co->index); return -ENODEV; } + serial = port->serial; retval = usb_autopm_get_interface(serial->interface); if (retval) goto error_get_interface; - port = serial->port[co->index - serial->minor]; tty_port_tty_set(&port->port, NULL); info->port = port; @@ -137,7 +134,6 @@ static int usb_console_setup(struct console *co, char *options) tty = kzalloc(sizeof(*tty), GFP_KERNEL); if (!tty) { retval = -ENOMEM; - err("no more memory"); goto reset_open_count; } kref_init(&tty->kref); @@ -146,26 +142,21 @@ static int usb_console_setup(struct console *co, char *options) tty->index = co->index; if (tty_init_termios(tty)) { retval = -ENOMEM; - err("no more memory"); goto free_tty; } } /* only call the device specific open if this * is the first time the port is opened */ - if (serial->type->open) - retval = serial->type->open(NULL, port); - else - retval = usb_serial_generic_open(NULL, port); - + retval = serial->type->open(NULL, port); if (retval) { - err("could not open USB console port"); + dev_err(&port->dev, "could not open USB console port\n"); goto fail; } if (serial->type->set_termios) { - tty->termios->c_cflag = cflag; - tty_termios_encode_baud_rate(tty->termios, baud, baud); + tty->termios.c_cflag = cflag; + tty_termios_encode_baud_rate(&tty->termios, baud, baud); memset(&dummy, 0, sizeof(struct ktermios)); serial->type->set_termios(tty, port, &dummy); @@ -212,10 +203,10 @@ static void usb_console_write(struct console *co, if (count == 0) return; - dbg("%s - port %d, %d byte(s)", __func__, port->number, count); + dev_dbg(&port->dev, "%s - %d byte(s)\n", __func__, count); if (!port->port.console) { - dbg("%s - port not opened", __func__); + dev_dbg(&port->dev, "%s - port not opened\n", __func__); return; } @@ -232,21 +223,14 @@ static void usb_console_write(struct console *co, } /* pass on to the driver specific version of this function if it is available */ - if (serial->type->write) - retval = serial->type->write(NULL, port, buf, i); - else - retval = usb_serial_generic_write(NULL, port, buf, i); - dbg("%s - return value : %d", __func__, retval); + retval = serial->type->write(NULL, port, buf, i); + dev_dbg(&port->dev, "%s - write: %d\n", __func__, retval); if (lf) { /* append CR after LF */ unsigned char cr = 13; - if (serial->type->write) - retval = serial->type->write(NULL, - port, &cr, 1); - else - retval = usb_serial_generic_write(NULL, - port, &cr, 1); - dbg("%s - return value : %d", __func__, retval); + retval = serial->type->write(NULL, port, &cr, 1); + dev_dbg(&port->dev, "%s - write cr: %d\n", + __func__, retval); } buf += i; count -= i; @@ -283,10 +267,8 @@ void usb_serial_console_disconnect(struct usb_serial *serial) } } -void usb_serial_console_init(int serial_debug, int minor) +void usb_serial_console_init(int minor) { - debug = serial_debug; - if (minor == 0) { /* * Call register_console() if this is the first device plugged @@ -301,7 +283,7 @@ void usb_serial_console_init(int serial_debug, int minor) * register_console). console_write() is called immediately * from register_console iff CON_PRINTBUFFER is set in flags. */ - dbg("registering the USB serial console."); + pr_debug("registering the USB serial console.\n"); register_console(&usbcons); } } |
