From: Johan Hovold <johan@kernel.org> To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Johan Hovold <johan@kernel.org> Subject: [1/9] USB: serial: fix initial-termios handling Date: Sun, 21 Apr 2019 14:21:46 +0200 [thread overview] Message-ID: <20190421122154.26465-2-johan@kernel.org> (raw) 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 fe1ae7fdd2ee ("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: 7e29bb4b779f ("usb-serial: fix termios initialization logic") Signed-off-by: Johan Hovold <johan@kernel.org> --- drivers/usb/serial/usb-serial.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 7e89efbf2c28..676c296103a2 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -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;
WARNING: multiple messages have this Message-ID (diff)
From: Johan Hovold <johan@kernel.org> To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Johan Hovold <johan@kernel.org> Subject: [PATCH 1/9] USB: serial: fix initial-termios handling Date: Sun, 21 Apr 2019 14:21:46 +0200 [thread overview] Message-ID: <20190421122154.26465-2-johan@kernel.org> (raw) Message-ID: <20190421122146.IbR8WvRaGumrGLTTOjdbQtWgONJhIxwtjfWaluStMEA@z> (raw) In-Reply-To: <20190421122154.26465-1-johan@kernel.org> 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 fe1ae7fdd2ee ("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: 7e29bb4b779f ("usb-serial: fix termios initialization logic") Signed-off-by: Johan Hovold <johan@kernel.org> --- drivers/usb/serial/usb-serial.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 7e89efbf2c28..676c296103a2 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -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; -- 2.21.0
next reply other threads:[~2019-04-21 12:21 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-21 12:21 Johan Hovold [this message] 2019-04-21 12:21 ` [PATCH 1/9] USB: serial: fix initial-termios handling Johan Hovold -- strict thread matches above, loose matches on Subject: below -- 2019-04-21 12:21 [9/9] USB: serial: spcp8x5: simplify init_termios Johan Hovold 2019-04-21 12:21 ` [PATCH 9/9] " Johan Hovold 2019-04-21 12:21 [8/9] USB: serial: oti6858: " Johan Hovold 2019-04-21 12:21 ` [PATCH 8/9] " Johan Hovold 2019-04-21 12:21 [7/9] USB: serial: iuu_phoenix: " Johan Hovold 2019-04-21 12:21 ` [PATCH 7/9] " Johan Hovold 2019-04-21 12:21 [6/9] USB: serial: iuu_phoenix: drop bogus initial cflag Johan Hovold 2019-04-21 12:21 ` [PATCH 6/9] " Johan Hovold 2019-04-21 12:21 [5/9] USB: serial: cypress_m8: clean up initial-termios handling Johan Hovold 2019-04-21 12:21 ` [PATCH 5/9] " Johan Hovold 2019-04-21 12:21 [4/9] USB: serial: cypress_m8: drop unused termios Johan Hovold 2019-04-21 12:21 ` [PATCH 4/9] " Johan Hovold 2019-04-21 12:21 [3/9] USB: serial: cypress_m8: drop unused driver data flag Johan Hovold 2019-04-21 12:21 ` [PATCH 3/9] " Johan Hovold 2019-04-21 12:21 [2/9] USB: serial: ark3116: drop redundant init_termios Johan Hovold 2019-04-21 12:21 ` [PATCH 2/9] " Johan Hovold 2019-04-21 12:21 [PATCH 0/9] USB: serial: fix initial-termios handling Johan Hovold 2019-04-26 6:40 ` Johan Hovold
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=20190421122154.26465-2-johan@kernel.org \ --to=johan@kernel.org \ --cc=gregkh@linuxfoundation.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.