public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fix two bugs in usb serial console
@ 2008-11-13  1:53 Kevin Hao
  2008-11-13  1:53 ` [PATCH 1/2] init tty kref in usb serial console setup Kevin Hao
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Hao @ 2008-11-13  1:53 UTC (permalink / raw)
  To: LKML; +Cc: gregkh, Alan Cox, linux-usb

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] init tty kref in usb serial console setup
  2008-11-13  1:53 [PATCH 0/2] fix two bugs in usb serial console Kevin Hao
@ 2008-11-13  1:53 ` Kevin Hao
  2008-11-13  1:53   ` [PATCH 2/2] add device function for usb serial console Kevin Hao
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Hao @ 2008-11-13  1:53 UTC (permalink / raw)
  To: LKML; +Cc: gregkh, Alan Cox, linux-usb

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.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
---
 drivers/usb/serial/console.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 5b20de1..5b95009 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -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;
-- 
1.6.0.3.640.g6331a


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] add device function for usb serial console
  2008-11-13  1:53 ` [PATCH 1/2] init tty kref in usb serial console setup Kevin Hao
@ 2008-11-13  1:53   ` Kevin Hao
  2008-11-13 14:59     ` Sergei Shtylyov
  2008-11-14 22:36     ` [PATCH 2/2] " Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Kevin Hao @ 2008-11-13  1:53 UTC (permalink / raw)
  To: LKML; +Cc: gregkh, Alan Cox, linux-usb

Add device funtion for usb serial console, so we can open /dev/console
when we use a usb serial device as console.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
---
 drivers/usb/serial/console.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 5b95009..1dbb203 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -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)
-- 
1.6.0.3.640.g6331a


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] add device function for usb serial console
  2008-11-13  1:53   ` [PATCH 2/2] add device function for usb serial console Kevin Hao
@ 2008-11-13 14:59     ` Sergei Shtylyov
  2008-11-14  1:30       ` [PATCH v2] " Kevin Hao
  2008-11-14 22:36     ` [PATCH 2/2] " Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2008-11-13 14:59 UTC (permalink / raw)
  To: Kevin Hao; +Cc: LKML, gregkh, Alan Cox, linux-usb

Hello.

Kevin Hao wrote:

> Add device funtion for usb serial console, so we can open /dev/console
> when we use a usb serial device as console.

> Signed-off-by: Kevin Hao <kexin.hao@windriver.com>

> diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
> index 5b95009..1dbb203 100644
> --- a/drivers/usb/serial/console.c
> +++ b/drivers/usb/serial/console.c
> @@ -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);

    Type cast not needed here.

WBR, Sergei

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] add device function for usb serial console
  2008-11-13 14:59     ` Sergei Shtylyov
@ 2008-11-14  1:30       ` Kevin Hao
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Hao @ 2008-11-14  1:30 UTC (permalink / raw)
  To: LKML; +Cc: Sergei Shtylyov, gregkh, Alan Cox, linux-usb

Add device funtion for usb serial console, so we can open /dev/console
when we use a usb serial device as console.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
---
 drivers/usb/serial/console.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 5b95009..19e2404 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -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)
-- 
1.6.0.3.640.g6331a


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] add device function for usb serial console
  2008-11-13  1:53   ` [PATCH 2/2] add device function for usb serial console Kevin Hao
  2008-11-13 14:59     ` Sergei Shtylyov
@ 2008-11-14 22:36     ` Andrew Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2008-11-14 22:36 UTC (permalink / raw)
  To: Kevin Hao; +Cc: linux-kernel, gregkh, alan, linux-usb

On Thu, 13 Nov 2008 09:53:37 +0800
Kevin Hao <kexin.hao@windriver.com> wrote:

> Add device funtion for usb serial console, so we can open /dev/console
> when we use a usb serial device as console.
> 
> Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
> ---
>  drivers/usb/serial/console.c |   13 +++++++++++++
>  1 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
> index 5b95009..1dbb203 100644
> --- a/drivers/usb/serial/console.c
> +++ b/drivers/usb/serial/console.c
> @@ -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.

> +
> +	if (!*p)
> +		return NULL;
> +
> +	*index = co->index;
> +	return (struct tty_driver *)(*p);

And *p already has type `struct tty_driver *'.

> +}
> +
>  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,
>  };
>  


--- a/drivers/usb/serial/console.c~usb-serial-console-add-device-function-fix
+++ a/drivers/usb/serial/console.c
@@ -243,13 +243,13 @@ static void usb_console_write(struct con
 
 static 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 = {
_


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-11-14 22:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-13  1:53 [PATCH 0/2] fix two bugs in usb serial console Kevin Hao
2008-11-13  1:53 ` [PATCH 1/2] init tty kref in usb serial console setup Kevin Hao
2008-11-13  1:53   ` [PATCH 2/2] add device function for usb serial console Kevin Hao
2008-11-13 14:59     ` Sergei Shtylyov
2008-11-14  1:30       ` [PATCH v2] " Kevin Hao
2008-11-14 22:36     ` [PATCH 2/2] " Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox