public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Wessel <jason.wessel@windriver.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	gregkh@suse.de, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] usb console,usb-serial: pass initial console baud on to first tty open
Date: Thu, 17 Sep 2009 07:16:18 -0500	[thread overview]
Message-ID: <4AB22892.8000308@windriver.com> (raw)
In-Reply-To: <20090917101441.478b3e9b@lxorguk.ukuu.org.uk>

Alan Cox wrote:
>> It looked like the API for the tty subsystem was gradually changing such
>> that the ldisc structure could ultimately get shared for use with the
>> console, but this work is not complete, so we are somewhere in between.
> 
> The mechanics of this are already there. A tty drive can manage its own
> termios structs, and the termios structs are pointers in the tty structure
> 
>> The question is what is an acceptable solution?
> 
> Take a look at usb_serial.c:serial_install. You can do the console state
> preservation there and cleanly.
> 


Thanks for the pointer Alan.  That solves the termios initialization
piece nicely.

In the usb git tree the serial_install() got removed, but I can see
the init_termios structure that gets setup in usb_serial_init().


The patch will look something like the code below, but we have to sort
out the patch tree with Alan Stern's changes to usb/serial/console.c.

Thanks,
Jason.


Signed-off-by: Jason Wessel <jason.wessel@windriver.com>

---
 drivers/usb/serial/console.c |   24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -65,7 +65,7 @@ static int usb_console_setup(struct cons
 	struct usb_serial_port *port;
 	int retval = 0;
 	struct tty_struct *tty = NULL;
-	struct ktermios *termios = NULL, dummy;
+	struct ktermios dummy;
 
 	dbg("%s", __func__);
 
@@ -136,14 +136,7 @@ static int usb_console_setup(struct cons
 				goto reset_open_count;
 			}
 			kref_init(&tty->kref);
-			termios = kzalloc(sizeof(*termios), GFP_KERNEL);
-			if (!termios) {
-				retval = -ENOMEM;
-				err("no more memory");
-				goto free_tty;
-			}
-			memset(&dummy, 0, sizeof(struct ktermios));
-			tty->termios = termios;
+			tty->termios = &usb_serial_tty_driver->init_termios;
 			tty_port_tty_set(&port->port, tty);
 		}
 
@@ -156,16 +149,15 @@ static int usb_console_setup(struct cons
 
 		if (retval) {
 			err("could not open USB console port");
-			goto free_termios;
+			goto clear_port_tty_set;
 		}
 
 		if (serial->type->set_termios) {
-			termios->c_cflag = cflag;
-			tty_termios_encode_baud_rate(termios, baud, baud);
+			tty->termios->c_cflag = cflag;
+			tty_termios_encode_baud_rate(tty->termios, baud, baud);
 			serial->type->set_termios(tty, port, &dummy);
 
 			tty_port_tty_set(&port->port, NULL);
-			kfree(termios);
 			kfree(tty);
 		}
 	}
@@ -180,13 +172,11 @@ static int usb_console_setup(struct cons
 
 out:
 	return retval;
-free_termios:
-	kfree(termios);
+clear_port_tty_set:
 	tty_port_tty_set(&port->port, NULL);
-free_tty:
 	kfree(tty);
 reset_open_count:
-	port->port.count = 0;
+	--port->port.count;
 	goto out;
 }
 

  reply	other threads:[~2009-09-17 12:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-17  3:08 [PATCH 0/3] usb console: 2.6.32 regression fixes Jason Wessel
2009-09-17  3:08 ` [PATCH 1/3] usb console: fix mutex lock regression Jason Wessel
2009-09-17  3:08   ` [PATCH 2/3] usb console,usb-serial: fix regression use of serial->console Jason Wessel
2009-09-17  3:08     ` [PATCH 3/3] usb console,usb-serial: pass initial console baud on to first tty open Jason Wessel
2009-09-17  3:32       ` Alan Stern
2009-09-17  3:40         ` Jason Wessel
2009-09-17  3:46           ` Alan Stern
2009-09-17  4:17             ` Jason Wessel
2009-09-17  9:14               ` Alan Cox
2009-09-17 12:16                 ` Jason Wessel [this message]
2009-09-17 13:08                   ` Alan Cox
2009-09-17 13:19                     ` Alan Cox
2009-09-17 14:17                       ` Jason Wessel
2009-09-17 16:02                         ` Alan Cox
2009-09-22 20:54                           ` Jason Wessel
2009-09-29 17:24                             ` How to handle console devices Alan Stern
2009-09-29 22:47                               ` Alan Cox
2009-09-17  3:30     ` [PATCH 2/3] usb console,usb-serial: fix regression use of serial->console Alan Stern
2009-09-17  3:32       ` Jason Wessel
2009-09-17  3:25   ` [PATCH 1/3] usb console: fix mutex lock regression Alan Stern
2009-09-17  3:32     ` Jason Wessel
2009-09-18 17:16     ` Greg KH

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=4AB22892.8000308@windriver.com \
    --to=jason.wessel@windriver.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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