Commit 579bebe5 authored by Johan Hovold's avatar Johan Hovold

USB: serial: fix initial-termios handling

The USB-serial driver init_termios callback is used to override the
default initial terminal settings provided by USB-serial core.

After a bug was fixed in the original implementation introduced by
commit fe1ae7fd ("tty: USB serial termios bits"), the init_termios
callback was no longer called just once on first use as intended but
rather on every (first) open.

This specifically meant that the terminal settings saved on (final)
close were ignored when reopening a port for drivers overriding the
initial settings.

Also update the outdated function header referring to the creation of
termios objects.

Fixes: 7e29bb4b ("usb-serial: fix termios initialization logic")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 74d81395
......@@ -164,9 +164,9 @@ void usb_serial_put(struct usb_serial *serial)
* @driver: the driver (USB in our case)
* @tty: the tty being created
*
* Create the termios objects for this tty. We use the default
* Initialise the termios structure for this tty. We use the default
* USB serial settings but permit them to be overridden by
* serial->type->init_termios.
* serial->type->init_termios on first open.
*
* This is the first place a new tty gets used. Hence this is where we
* acquire references to the usb_serial structure and the driver module,
......@@ -178,6 +178,7 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
int idx = tty->index;
struct usb_serial *serial;
struct usb_serial_port *port;
bool init_termios;
int retval = -ENODEV;
port = usb_serial_port_get_by_minor(idx);
......@@ -192,14 +193,16 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
if (retval)
goto error_get_interface;
init_termios = (driver->termios[idx] == NULL);
retval = tty_standard_install(driver, tty);
if (retval)
goto error_init_termios;
mutex_unlock(&serial->disc_mutex);
/* allow the driver to update the settings */
if (serial->type->init_termios)
/* allow the driver to update the initial settings */
if (init_termios && serial->type->init_termios)
serial->type->init_termios(tty);
tty->driver_data = port;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment