fix two bugs in usb serial console
Subsystems (2)
cover fix two bugs in usb serial console
Hi all,
1. we should init the kref of tty which used as a fake tty in usb serial console setup function.
2. Fix can't open /dev/console bug when the console is a usb serial device.
With these two patches we can boot and login successfully on an Eee PC with a pl2303 usb serial as console.
Thanks,
Kevin
PATCH 1/2 init tty kref in usb serial console setup
We alloc a fake tty in usb serial console setup function. we should init the tty's kref otherwise we will face WARN_ON after following invoke of tty_port_tty_set --> tty_kref_get.
--- drivers/usb/serial/console.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/usb/serial/console.c +1 -0
@@ -135,6 +135,7 @@ static int usb_console_setup(struct console *co, char *options)err ("no more memory" ); goto reset_open_count; } +kref_init (&tty->kref); termios =kzalloc (sizeof (*termios),GFP_KERNEL );if (!termios) { retval = -ENOMEM ;
Signature · 1 line
1.6.0.3.640.g6331a
PATCH 2/2 add device function for usb serial console
Add device funtion for usb serial console, so we can open /dev/console when we use a usb serial device as console.
--- drivers/usb/serial/console.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/usb/serial/console.c +13 -0
@@ -241,12 +241,25 @@ static void usb_console_write(struct console *co, } } +static struct tty_driver *usb_console_device (struct console *co,int *index) +{ +struct tty_driver **p = (struct tty_driver **)co->data; + +if (!*p) +return NULL ; + + *index = co->index; +return (struct tty_driver *)(*p); +} +static struct console usbcons = { .name ="ttyUSB" , .write = usb_console_write, + .device = usb_console_device, .setup = usb_console_setup, .flags =CON_PRINTBUFFER , .index =-1 , + .data = &usb_serial_tty_driver, };void usb_serial_console_disconnect (struct usb_serial *serial)
Signature · 1 line
1.6.0.3.640.g6331a
Re: [PATCH 2/2] add device function for usb serial console
Hello.
Quoted 12 lines · Kevin Hao
Add device funtion for usb serial console, so we can open
/dev/consolewhen we use a usb serial device as console.Signed-off-by Kevin Hao <[email protected]>drivers/usb/serial/console.c +0
-0@@ -241,12 +241,25 @@ static void usb_console_write(struct console *co, } }
drivers/usb/serial/console.c static void usb_console_write(struct console *co, · line 252
Quoted 10 lines
drivers/usb/serial/console.c +9
-0+static struct tty_driver *usb_console_device (struct console *co,int *index) +{ +struct tty_driver **p = (struct tty_driver **)co->data; + +if (!*p) +return NULL ; + + *index = co->index; +return (struct tty_driver *)(*p);
Type cast not needed here.
WBR, Sergei
PATCH v2 1/1 add device function for usb serial console
Add device funtion for usb serial console, so we can open /dev/console when we use a usb serial device as console.
--- drivers/usb/serial/console.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/usb/serial/console.c +13 -0
@@ -241,12 +241,25 @@ static void usb_console_write(struct console *co, } } +static struct tty_driver *usb_console_device (struct console *co,int *index) +{ +struct tty_driver **p = (struct tty_driver **)co->data; + +if (!*p) +return NULL ; + + *index = co->index; +return *p; +} +static struct console usbcons = { .name ="ttyUSB" , .write = usb_console_write, + .device = usb_console_device, .setup = usb_console_setup, .flags =CON_PRINTBUFFER , .index =-1 , + .data = &usb_serial_tty_driver, };void usb_serial_console_disconnect (struct usb_serial *serial)
Signature · 1 line
1.6.0.3.640.g6331a
Re: [PATCH 2/2] add device function for usb serial console
In reply to Kevin HaoQuoted 13 lines · On Thu, 13 Nov 2008 09:53:37 +0800 Kevin Hao <[email protected]> wrote:
Add device funtion for usb serial console, so we can open
/dev/consolewhen we use a usb serial device as console.Signed-off-by Kevin Hao <[email protected]>--- drivers/usb/serial/console.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)drivers/usb/serial/console.c +0
-0
drivers/usb/serial/console.c static void usb_console_write(struct console *co, · line 246
Quoted 6 lines
drivers/usb/serial/console.c +3
-0@@ -241,12 +241,25 @@ static void usb_console_write(struct console *co, } } +static struct tty_driver *usb_console_device (struct console *co,int *index) +{ +struct tty_driver **p = (struct tty_driver **)co->data;
co->data is already void*, hence this cast is unneeded. It is also undesirable because it defeats typechecking.
drivers/usb/serial/console.c static void usb_console_write(struct console *co, · line 252
Quoted 6 lines
drivers/usb/serial/console.c +6
-0+ +if (!*p) +return NULL ; + + *index = co->index; +return (struct tty_driver *)(*p);
And *p already has type `struct tty_driver *'.
drivers/usb/serial/console.c static void usb_console_write(struct console *co, · line 264
Quoted 12 lines
drivers/usb/serial/console.c +4
-0+} +static struct console usbcons = { .name ="ttyUSB" , .write = usb_console_write, + .device = usb_console_device, .setup = usb_console_setup, .flags =CON_PRINTBUFFER , .index =-1 , + .data = &usb_serial_tty_driver, };
drivers/usb/serial/console.c renamed from drivers/usb/serial/console.c~usb-serial-console-add-device-function-fix +2 -2
@@ -243,13 +243,13 @@ static void usb_console_write(struct constatic struct tty_driver *usb_console_device (struct console *co,int *index) { -struct tty_driver **p = (struct tty_driver **)co->data; +struct tty_driver **p = co->data;if (!*p)return NULL ; *index = co->index; -return (struct tty_driver *)(*p); +return *p; }static struct console usbcons = {
_