public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Kevin Hao <kexin.hao@windriver.com>
Cc: linux-kernel@vger.kernel.org, gregkh@suse.de, alan@redhat.com,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 2/2] add device function for usb serial console
Date: Fri, 14 Nov 2008 14:36:43 -0800	[thread overview]
Message-ID: <20081114143643.c79cfc0c.akpm@linux-foundation.org> (raw)
In-Reply-To: <2fdffab7c5a36049b81ec63f2ee1fbdd4dd25a8a.1226366228.git.kexin.hao@windriver.com>

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 = {
_


      parent reply	other threads:[~2008-11-14 22:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081114143643.c79cfc0c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alan@redhat.com \
    --cc=gregkh@suse.de \
    --cc=kexin.hao@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox