From patchwork Sun Apr 21 12:21:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10910491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC4B1161F for ; Sun, 21 Apr 2019 12:22:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D7FF284E8 for ; Sun, 21 Apr 2019 12:22:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91D9B2866C; Sun, 21 Apr 2019 12:22:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4727E284E8 for ; Sun, 21 Apr 2019 12:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727385AbfDUMV7 (ORCPT ); Sun, 21 Apr 2019 08:21:59 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34370 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbfDUMV6 (ORCPT ); Sun, 21 Apr 2019 08:21:58 -0400 Received: by mail-lj1-f193.google.com with SMTP id j89so8212080ljb.1 for ; Sun, 21 Apr 2019 05:21:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YCHlwVEU1pAZwr42+V6C5g/JtxQTErLwhv+ymt5pxTk=; b=QFsGDSKYGfRXhAwDFAdIjvG/gkH3LG/bxyUE9WLsjRcATS3oUvPhVbhaE8swszwIrq DL6X+VqDYkBDfqYUhvvEmAeS1SRlR74tCocmpU5Vy8nQUpW32/uKMjRtH6l09lvec9I3 R4na4da8EQyubW0ORO02r+r4OgJBMIaLSHlVEum5rBQ7AsBUS45CiJCbNRuxFpuqTK+j 81d/YV6joppXl6s2d6E159e7WUjXKUaYFz4XOenIy4N+xWwgm/31riTGTYN1NiXH+Y8J Rau3Oj3KH2qZLGt3JGcqa82QeCZZAocTYkyrABZbd2riyetNCQRpulcDz5xXbcIM/16P xwLg== X-Gm-Message-State: APjAAAWpVMrLnABZombTTyRB5clef4OCSdeDP4ZUZ7hrJcKsyrT2DtGh ydwLMbypVQ/ul0BoAzJp+++rV76W X-Google-Smtp-Source: APXvYqyhsOINS1Waexhrz6q+rJZhtQkowycTJcUp93rvz8hdSrCLE6EL22N8FlhuBc8ZyMwToaC+1Q== X-Received: by 2002:a2e:974d:: with SMTP id f13mr7445591ljj.140.1555849316325; Sun, 21 Apr 2019 05:21:56 -0700 (PDT) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id r2sm2235210ljd.16.2019.04.21.05.21.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Apr 2019 05:21:55 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1hIBTs-0006tk-7A; Sun, 21 Apr 2019 14:22:00 +0200 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Johan Hovold Subject: [PATCH 1/9] USB: serial: fix initial-termios handling Date: Sun, 21 Apr 2019 14:21:46 +0200 Message-Id: <20190421122154.26465-2-johan@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190421122154.26465-1-johan@kernel.org> References: <20190421122154.26465-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;