tty-usb-console: tidy the USB console code

Code tidy

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox 2008-07-22 11:09:57 +01:00 committed by Linus Torvalds
parent c97611c16d
commit 4dbd5a0961

View file

@ -67,7 +67,7 @@ static int usb_console_setup(struct console *co, char *options)
struct tty_struct *tty = NULL;
struct ktermios *termios = NULL, dummy;
dbg ("%s", __func__);
dbg("%s", __func__);
if (options) {
baud = simple_strtoul(options, NULL, 10);
@ -140,7 +140,7 @@ static int usb_console_setup(struct console *co, char *options)
serial = usb_serial_get_by_index(co->index);
if (serial == NULL) {
/* no device is connected yet, sorry :( */
err ("No USB device connected to ttyUSB%i", co->index);
err("No USB device connected to ttyUSB%i", co->index);
return -ENODEV;
}
@ -211,7 +211,8 @@ reset_open_count:
goto out;
}
static void usb_console_write(struct console *co, const char *buf, unsigned count)
static void usb_console_write(struct console *co,
const char *buf, unsigned count)
{
static struct usbcons_info *info = &usbcons_info;
struct usb_serial_port *port = info->port;
@ -228,7 +229,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
if (!port->port.count) {
dbg ("%s - port not opened", __func__);
dbg("%s - port not opened", __func__);
return;
}
@ -236,14 +237,15 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
unsigned int i;
unsigned int lf;
/* search for LF so we can insert CR if necessary */
for (i=0, lf=0 ; i < count ; i++) {
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 */
/* 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
@ -253,9 +255,11 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
/* append CR after LF */
unsigned char cr = 13;
if (serial->type->write)
retval = serial->type->write(NULL, port, &cr, 1);
retval = serial->type->write(NULL,
port, &cr, 1);
else
retval = usb_serial_generic_write(NULL, port, &cr, 1);
retval = usb_serial_generic_write(NULL,
port, &cr, 1);
dbg("%s - return value : %d", __func__, retval);
}
buf += i;
@ -273,13 +277,14 @@ static struct console usbcons = {
void usb_serial_console_disconnect(struct usb_serial *serial)
{
if (serial && serial->port && serial->port[0] && serial->port[0] == usbcons_info.port) {
if (serial && serial->port && serial->port[0]
&& serial->port[0] == usbcons_info.port) {
usb_serial_console_exit();
usb_serial_put(serial);
}
}
void usb_serial_console_init (int serial_debug, int minor)
void usb_serial_console_init(int serial_debug, int minor)
{
debug = serial_debug;
@ -293,16 +298,16 @@ void usb_serial_console_init (int serial_debug, int minor)
/*
* Register console.
* NOTES:
* console_setup() is called (back) immediately (from register_console).
* console_write() is called immediately from register_console iff
* CON_PRINTBUFFER is set in flags.
* console_setup() is called (back) immediately (from
* register_console). console_write() is called immediately
* from register_console iff CON_PRINTBUFFER is set in flags.
*/
dbg ("registering the USB serial console.");
dbg("registering the USB serial console.");
register_console(&usbcons);
}
}
void usb_serial_console_exit (void)
void usb_serial_console_exit(void)
{
if (usbcons_info.port) {
unregister_console(&usbcons);