From patchwork Wed Apr 7 10:39:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAFAFC43461 for ; Wed, 7 Apr 2021 10:39:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75A39613A7 for ; Wed, 7 Apr 2021 10:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351179AbhDGKkD (ORCPT ); Wed, 7 Apr 2021 06:40:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:48962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234463AbhDGKj7 (ORCPT ); Wed, 7 Apr 2021 06:39:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A72E613A3; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=zecdlwn06S6EnBdUVHmnGszqZfSeUN4/Do04x9qNU+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CiIf4b+AgPcExylUWFTxmKsZyg1nnFIAGQmiU8iXM6NMBZZXF48pHaVDCf66N7khE TuVPaK5eoKMhSi1+GKCOPBaCdjgTBUh9SFC7YggDT1PMu2cgRfqYSjmBBkIdTjn/pX A4/kvfxQU8IJkWjxOGwuLZw01Evfau6LdrlHtyceAQmmPnBiOcDQG8ntOHT+KUFj8A uIBs16ykqGxoX8/JJAGmbBEtFbWtfRedgpgrLq5TjJV2jKMg90CEMFfql/4wtTn9Bn qWId9s0OPzfjLAydKQp6LkDcAE6l8Ohc4n00uUWj7ysWstRA/DHy/aBvfv5zqo7UXa yfpfzZKtE3fyA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000EZ-9j; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/24] USB: serial: ark3116: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:02 +0200 Message-Id: <20210407103925.829-2-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The baud_base parameter could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds. The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: 2f430b4bbae7 ("USB: ark3116: Add TIOCGSERIAL and TIOCSSERIAL ioctl calls.") Signed-off-by: Johan Hovold --- drivers/usb/serial/ark3116.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index b9bedfe9bd09..957cdd694b1f 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -392,8 +392,9 @@ static int ark3116_get_serial_info(struct tty_struct *tty, ss->type = PORT_16654; ss->line = port->minor; - ss->port = port->port_number; - ss->baud_base = 460800; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 822ABC433B4 for ; Wed, 7 Apr 2021 10:39:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F8AE61242 for ; Wed, 7 Apr 2021 10:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351175AbhDGKkB (ORCPT ); Wed, 7 Apr 2021 06:40:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:48968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234506AbhDGKj7 (ORCPT ); Wed, 7 Apr 2021 06:39:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F282613A9; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=jtUsuzlU0E4vfBqSt1CNWV6/2Th2tlLbmiKV+LWNhRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4sb8gNFsAhnaUV+Aaca120tvHHCaofGjSvlzn/oZIxHlkPo/eBfBKqW1JO+538Pr iTr6ijmvjF8x4MvHqc22LKHdK6yaCRo2ziSYVVrmfMan9FovCP1GzI+76kvM3dvTVv Xj7OwsS7XbXBJl+Hy0YDVM0ryUUPxEIjxRHT3olE3WQmBwW8GGBZ9Yl0DTQnX7VCBk myWE+GtjkJDrjIfcetpjvybs/mjKH7AyM9ihuH33KovQdxyEpvCq+7mJrIw2C5u3cx SEwzwGMptwoxQVffJSkeBWGRT1LLXN27lTcpNyd6Zu9WzOG5nquFv6z/IAW2LFtwk7 aRss/1F8gYfsg== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000Eb-Cf; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/24] USB: serial: f81232: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:03 +0200 Message-Id: <20210407103925.829-3-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds. The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: aac1fc386fa1 ("USB: serial: add Fintek F81232 usb to serial driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/f81232.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 6a8f39147d8e..af0fe2a82eb2 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -828,8 +828,10 @@ static int f81232_get_serial_info(struct tty_struct *tty, ss->type = PORT_16550A; ss->line = port->minor; - ss->port = port->port_number; ss->baud_base = priv->baud_base; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C7D5C433ED for ; Wed, 7 Apr 2021 10:40:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36BE361359 for ; Wed, 7 Apr 2021 10:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351221AbhDGKkM (ORCPT ); Wed, 7 Apr 2021 06:40:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:49074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234911AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 173A5613B3; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=TbudOCCDwTXxK2l251NN3FOx6Ha1jj6poWzJiRM5aXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TY/cnwfmxRHbcNaxnNM0SlyEHRSO6QvfiAcb59d9HDhoYfSbr9m6DgNUduJpJ3RTC ZyHSKlPfVEO6DD8DljM09idLVO2azzN76IoFgjvEWhbOu80umeWafOss983hNwlNr7 j7hBHLuY+NAurpDw9UactflhrKz1qd0VmJnJdHVf92RAiPTzKkUsfyd7Ml3eq1ctFw 1xN2y/M1D0nBClR6y5c9hGOYvxzOj5VZxKuuOFggZZCbSPe/p5pGtx3nBYlnuADGsT IbkScjgEmZJqd9P10cCr9jejrgp+HsM3mjhvIc0srz2cDX7Q9a8qvwRMlaLXGQX4OJ +iJyq/T5msZlA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000Ef-Fq; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/24] USB: serial: f81534: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:04 +0200 Message-Id: <20210407103925.829-4-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds. The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: aac1fc386fa1 ("USB: serial: add Fintek F81232 usb to serial driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/f81534.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index a763b362f081..c9f90d437e3a 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -1149,9 +1149,11 @@ static int f81534_get_serial_info(struct tty_struct *tty, port_priv = usb_get_serial_port_data(port); ss->type = PORT_16550A; - ss->port = port->port_number; ss->line = port->minor; ss->baud_base = port_priv->baud_base; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FB22C433B4 for ; Wed, 7 Apr 2021 10:40:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4353161359 for ; Wed, 7 Apr 2021 10:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351227AbhDGKkN (ORCPT ); Wed, 7 Apr 2021 06:40:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234796AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CE17613A7; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=qRySowkWF1fElisa29iZUwlmVS6RoK37fkbnaScIWAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A48JKwTOiGeqSEIrCHamPBiNqNByhN4MfidV4sHB0ShbdXIvUihX9AM7alUujPz3r 93BQZtNJLobHGWm8GEj4gAO5AoUwrKJ5fkrisxO9i99MLI25id8zjkZorVzRRU7C/r 6bnfm8dAFOVNYEp9lYFKrQoISmMFjHOEODgmywrHlmPyR8S7S1LlDbM2QLkQvamV+F fR8L5ZsmX9MS9H/MfUAhX/xv4UvqPoGoYQ5ZmT4l4oqEpal1OPET0fmLRWfI2GLLjP twe+enoRkFOcPvlzL7ZsX1m8g8uFJtuuz8qC+5QtgWjzZe6dUtPSF8EiyEG95fiwNA bi9DKRIJyDAZg== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000Eh-Ij; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/24] USB: serial: ftdi_sio: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:05 +0200 Message-Id: <20210407103925.829-5-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The FTDI driver is the only USB serial driver supporting the deprecated ASYNC_SPD flags, which are reported back as they should by TIOCGSERIAL, but the returned parameters did not include the line number. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds. The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index c867592477c9..f8a0911f90ea 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1483,9 +1483,13 @@ static int get_serial_info(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); + ss->line = port->minor; ss->flags = priv->flags; ss->baud_base = priv->baud_base; ss->custom_divisor = priv->custom_divisor; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAEF8C433ED for ; Wed, 7 Apr 2021 10:40:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A25F2613A0 for ; Wed, 7 Apr 2021 10:40:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351198AbhDGKkG (ORCPT ); Wed, 7 Apr 2021 06:40:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:49062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234779AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1495761359; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=xCoq7juioz9fE0ikJojkoRQFW9mcS+euv3bhPnAlqvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0LMVTSdkZxpyLFq7GlTFkKcBcu9h++dOF5uCYP7vlAvhc8q+Qaf3x/0RvVhg0qgk WBh6FyF0hvk1l/PNg1iYNlWO6ZC4BJlE/q/+dXUg0TkkGcrjFxnOMT7qNAhznHkWSX 08TLIrlSvBEnHBRv3ikVemUUggoQ/AODXu/6oXwcObsKJzPWvgQFeau09uY+88Rt3P 9r/OJwkeQsdvUyt3/F7jgVXZfV/VuyLonNXVvaeVEE4v9HL4gytxRnvZR/Dk7pN3sb 9CNRgXPSoERFDvxAztB9D36hZ0q3QBrCHOQBy5IwBE0b/+GMzseIBs5+od4e9iUXgF wXBn982VZB0mA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000El-Lc; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/24] USB: serial: io_edgeport: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:06 +0200 Message-Id: <20210407103925.829-6-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the uart base clock when it could not be detected, but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Signed-off-by: Johan Hovold --- drivers/usb/serial/io_edgeport.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 68401adcffde..471a1a04c9c3 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1641,16 +1641,12 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - struct edgeport_port *edge_port = usb_get_serial_port_data(port); ss->type = PORT_16550A; - ss->line = edge_port->port->minor; - ss->port = edge_port->port->port_number; - ss->irq = 0; - ss->xmit_fifo_size = edge_port->maxTxCredits; - ss->baud_base = 9600; - ss->close_delay = 5*HZ; - ss->closing_wait = 30*HZ; + ss->line = port->minor; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FD06C43460 for ; Wed, 7 Apr 2021 10:39:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46C6461359 for ; Wed, 7 Apr 2021 10:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351187AbhDGKkF (ORCPT ); Wed, 7 Apr 2021 06:40:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234626AbhDGKj7 (ORCPT ); Wed, 7 Apr 2021 06:39:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11C1C613AF; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=1gxuIGHqLZXdadEccAwc22dsHq4OxU9DCMYgb+3Pl3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gn+y7Z2sPLklkZrEUNqZCeoTkjJQP96hJaZ3qMQD8YYpwp/tfWOqDpdOubW2145ke VUMALoVSq+YAHanvCA0ix+WlzctePmGjIqglVpWNo6wL9VmTL+F27YYuU5h/F2vQfX cV2jLoTOascxBxYN2lS6gYVUwKHIqkybEDMmxiYZcoVZ2ozSXGpw7cTB0ICfN4eeHQ NuoXU7uOKBgOqy8wy5c4Y4ufdoG2PPkwhBwN5t4vdz3RsA8S6z06tB3u/E93pNpZwM cB1drGqzX3z0K78uFdJl6uOe7rSoQtQAvnn16b/92zg+smTi+7r7BxxCfwEBCsZ3X2 +6AnQ8FuDow8g== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000Eo-OV; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/24] USB: serial: io_ti: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:07 +0200 Message-Id: <20210407103925.829-7-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing close_delay, but let's report back the default value actually used (0.5 seconds). Signed-off-by: Johan Hovold --- drivers/usb/serial/io_ti.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index e800547be9e0..f5aab570fd05 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2437,21 +2437,17 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned cwait; - cwait = edge_port->port->port.closing_wait; + cwait = port->port.closing_wait; if (cwait != ASYNC_CLOSING_WAIT_NONE) cwait = jiffies_to_msecs(cwait) / 10; ss->type = PORT_16550A; - ss->line = edge_port->port->minor; - ss->port = edge_port->port->port_number; - ss->irq = 0; - ss->xmit_fifo_size = edge_port->port->bulk_out_size; - ss->baud_base = 9600; - ss->close_delay = 5*HZ; + ss->line = port->minor; + ss->close_delay = 50; ss->closing_wait = cwait; + return 0; } From patchwork Wed Apr 7 10:39:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58386C433B4 for ; Wed, 7 Apr 2021 10:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0348B6139C for ; Wed, 7 Apr 2021 10:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351162AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:48950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhDGKj7 (ORCPT ); Wed, 7 Apr 2021 06:39:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0462661242; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=1MWTcJ7GSrGtFR7oJCzfn88dggfYZcm5Bf6LCNJXE4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFAeEG2wre1Nolpshbfv0/87oy2+GENBZ+BBXpXS2Ka74WvnnXZ2KQB/6dhPCEfTR KM4NbRPRxSVfGpyWkAvXy2geMWJH7yDlWy1szztpll+TQwZYW7hp6Z3rV7Cm3FvFx+ hiRF+s3vspcTvsw86PmAHdulcgY8dQzIkJyqaNCDMiONldo9+W9LPGfeLQ8zeGgM1C /uTUM+wsZvEmXhm3sJRHqUTD49jb8pPX+gZ/x90DBKEW4fiaBApjK07HNWMXpUs8iQ ki2hysvRcbsD2ACDB0ZoUDx23Caruu8LtyZqr5Y2exTDldL0lVwQz8WKopL46UWVlg kt8G/B6zJj/Fg== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000Er-RO; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/24] USB: serial: mos7720: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:08 +0200 Message-Id: <20210407103925.829-8-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: 0f64478cbc7a ("USB: add USB serial mos7720 driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/mos7720.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index bb3d39307d93..db90ce560d42 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -1638,16 +1638,12 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - struct moschip_port *mos7720_port = usb_get_serial_port_data(port); ss->type = PORT_16550A; - ss->line = mos7720_port->port->minor; - ss->port = mos7720_port->port->port_number; - ss->irq = 0; - ss->xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; - ss->baud_base = 9600; - ss->close_delay = 5*HZ; - ss->closing_wait = 30*HZ; + ss->line = port->minor; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2984DC433B4 for ; Wed, 7 Apr 2021 10:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D335F6105A for ; Wed, 7 Apr 2021 10:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351232AbhDGKkQ (ORCPT ); Wed, 7 Apr 2021 06:40:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:49066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234868AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19B2C613B8; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=nEsXEXQJxRf/84Q7AHuwDjFlmGoeWC6cQeEgYeaswuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EWyfL2CwR8MCQShWHCS0Ls+RpVAAlwlJyuaU/OHihgmErttfSEZfZ+V3XW+xX2Jyl Cuha0b1oMt4+/UM7Kn0LflyUNrcWjuK9rCoVEJ9xnKSq74glJ7rdSReV51P52gFxfN srlKvvrzi8yanO/uWope0K5YSFLt67FkcBcsfjktXrew2cdtpnLoqGV8Jcmlar8Moq iIDLTxGhJ+DRNDlavUDzpV09bT67P1iwt6Vk2KBi700ILYEZBO4ybE0aKDvS5MlXk9 Gm0auu8c+NtoWsn2lsyaK+JapC/pe3n5P51Qf3uk7LwxMX3zp2mCV95ap338ntLwxx gF+xBibWyLmsQ== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b4-0000Eu-Te; Wed, 07 Apr 2021 12:39:42 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/24] USB: serial: mos7840: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:09 +0200 Message-Id: <20210407103925.829-9-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/mos7840.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 1bf0d066f55a..77cbe18a1629 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -1392,16 +1392,12 @@ static int mos7840_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - struct moschip_port *mos7840_port = usb_get_serial_port_data(port); ss->type = PORT_16550A; - ss->line = mos7840_port->port->minor; - ss->port = mos7840_port->port->port_number; - ss->irq = 0; - ss->xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; - ss->baud_base = 9600; - ss->close_delay = 5 * HZ; - ss->closing_wait = 30 * HZ; + ss->line = port->minor; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEFD6C433ED for ; Wed, 7 Apr 2021 10:40:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDFD261242 for ; Wed, 7 Apr 2021 10:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351207AbhDGKkP (ORCPT ); Wed, 7 Apr 2021 06:40:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:49076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234888AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2785F613C6; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=LIcRc7NYbE0x58pDWh179Yiiu/bA6nM3mAum4rSZ6K8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NScENpAnjzvxauWoRJWyrjJrKvw+wYzXWqDX3f5vtQq7qd65bLoRtY27PEmgyAX1+ kJWSr0WKJzMc8Hpe7zqRxdsKiekwqQIYihWSuIeUm3LiXABFjFcEMHufg3ANwuxqc+ fTJhCAZJ4Y28D9Zm45aaTnm82/7zcnK0WQYOBa6hhboVXUWCfjmKVm2EAyrE+4kqGO gz3HYdzOCuiel2LUGdefsYX4tQTTV66Qzs+y3BFHOnx4MYQFGBN4hFd1WzlKeKsV0R 5EPMQJTZV4HtVWoiYAkY+wrxaeo/tR9A5YWmjmNA3Qgo/rI8OKeY5avFEfqJoNw8NB MPe2wjoMTKHhw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000Ex-0b; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/24] USB: serial: opticon: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:10 +0200 Message-Id: <20210407103925.829-10-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: faac64ad9c7b ("USB: serial: opticon: add serial line ioctls") Signed-off-by: Johan Hovold --- drivers/usb/serial/opticon.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index eecb72aef83e..1c7e5dc2c272 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -360,12 +360,9 @@ static int get_serial_info(struct tty_struct *tty, /* fake emulate a 16550 uart to make userspace code happy */ ss->type = PORT_16550A; ss->line = port->minor; - ss->port = 0; - ss->irq = 0; - ss->xmit_fifo_size = 1024; - ss->baud_base = 9600; - ss->close_delay = 5*HZ; - ss->closing_wait = 30*HZ; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E135C4360C for ; Wed, 7 Apr 2021 10:40:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09E50613CF for ; Wed, 7 Apr 2021 10:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351210AbhDGKkJ (ORCPT ); Wed, 7 Apr 2021 06:40:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:49080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 434C6613CD; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=hu1SUyANoCuT1Q13sYyBfBeEv1ilJfqrVkL1hySgzds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZQtfXD4kQGfJhgRishsh9vCk27Htx0VcaykWOTYh5wxpZtEyDhxHn3lzK4GzZ+kO BCiVXCbYzO/BGntozEt0iym3pyamy8vXIBxRzcePzgqwDV0QwjXCXIFq4URyeKhtoD C00wOnyQ3UWizDUIpazmnILrCeF3IeFNwhzYwoHxIUt6Sdvnfok+hG0lLjvgZwXuPi q8xqbhB4Q03C4x8VML9UCHsriafsRZBHBz5IzTiYGRuUM8w6lLGzU4cSwu0zb1IoNS skLaNmYEKfNyl5LCkaPAyuVtmErRfrSUlcrufOkv1229FVtOK3ahVlT+jm+/S0BW7d 2oNhHKN/lu4uw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000F0-3U; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/24] USB: serial: pl2303: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:11 +0200 Message-Id: <20210407103925.829-11-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The baud_base parameter could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds. The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Signed-off-by: Johan Hovold --- drivers/usb/serial/pl2303.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index eed9acd1ae08..0455add8593a 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -946,8 +946,9 @@ static int pl2303_get_serial(struct tty_struct *tty, ss->type = PORT_16654; ss->line = port->minor; - ss->port = port->port_number; - ss->baud_base = 460800; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D302C43460 for ; Wed, 7 Apr 2021 10:40:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D242613B3 for ; Wed, 7 Apr 2021 10:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351268AbhDGKkY (ORCPT ); Wed, 7 Apr 2021 06:40:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:49098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234986AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5ACE46139C; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=Ff1Ti9CXje+qOhhjNTI7wIhBjGyNTvDcual0tNsok7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUFKP2pTnqkHFd2xD78eejka9SkrgatNp0DyJU0JU1elMmJ1HMRbyKr0M9tP67pQO chAKookY7QMtKvIb+66Tk5gTJjR3HFJSiSfC6HYsJoAUl7HGY5IEwgenC8irE2iPRz Nl55Xt3T4QOYvFU6jr+BuAJLHi93K4e9Yn3uASS+z6L1K2JLh+PU3J98UTqN2ICF6S qmEP0cHBrrjSygESnRLIyapo5IzExTFc7AoGBA3eZQ5TIKirK0XuQydN1W0kGLtafq qLxSz6bg6EIkaB7XMCVsP+PtmflmzLlVg9raMm4XNksPiIZPTp2ZZ/zeTPydyLtvvJ jU/JnUfxyKmUQ== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000F3-6N; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/24] USB: serial: quatech2: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:12 +0200 Message-Id: <20210407103925.829-12-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/quatech2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 599dcb2e374d..0d23e565e0d2 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -459,12 +459,9 @@ static int get_serial_info(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; ss->line = port->minor; - ss->port = 0; - ss->irq = 0; - ss->xmit_fifo_size = port->bulk_out_size; - ss->baud_base = 9600; - ss->close_delay = 5*HZ; - ss->closing_wait = 30*HZ; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE0EDC433ED for ; Wed, 7 Apr 2021 10:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F01E6105A for ; Wed, 7 Apr 2021 10:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351243AbhDGKkU (ORCPT ); Wed, 7 Apr 2021 06:40:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:49096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244114AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B4CF613DF; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=sNeOBPVqsjxF0gDECWn/9gulNwkDtwDce1h8BbPrewQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLjk8w3xPIhjVmdzQnyX6yScGs+rVR1KZLTEHn50yX1kvuz6FaRX+5RnC1LuvOike LSFjowa3IEvzOwlM1nHFIjkd99fqN8cmqBfXlMagHLdnUwBJVDPcSUW2KTkprG6Ydz KnPHOpPgdIZOjYapg1qwVq13nqXoAYCqn/UqR1ND/eCDwk5I1ZNYu2AZ7n9+6pR9V0 8Rw/W85lg+BCwVgBhLxy3Uc/m9Y0iLS4O59qe8y4HnzV2GMjBqoHaLQcmvaUUvYzt9 rJP++xO8XYYiTDXnQ37K40clFpCYkXuFawEpDOCuO5h7zS3QpZM2hKE7CvS/ERLuim YCECRaosz2WGA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000F6-9z; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/24] USB: serial: ssu100: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:13 +0200 Message-Id: <20210407103925.829-13-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. Similarly, baud_base could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Fixes: 52af95459939 ("USB: add USB serial ssu100 driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/ssu100.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 89fdc5c19285..c4616c37f33f 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -337,12 +337,9 @@ static int get_serial_info(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; ss->line = port->minor; - ss->port = 0; - ss->irq = 0; - ss->xmit_fifo_size = port->bulk_out_size; - ss->baud_base = 9600; - ss->close_delay = 5*HZ; - ss->closing_wait = 30*HZ; + ss->close_delay = 50; + ss->closing_wait = 3000; + return 0; } From patchwork Wed Apr 7 10:39:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EAD4C433B4 for ; Wed, 7 Apr 2021 10:40:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27C75613A0 for ; Wed, 7 Apr 2021 10:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351239AbhDGKkR (ORCPT ); Wed, 7 Apr 2021 06:40:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351092AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7E5D4613E1; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=J7A9LOi+J2merRNWLKmFzr4cbMWHH3iYqNceVJSnJbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cy3jl1yNwqSfbBcwnF2F6zTzde5lBZ+TFvnHo73GkTrPVwlqvJGVfmNZug0gDqROG cAhkH35c/6AzOMz0i8O4493vCDLrDho0gUS08Su3b2+JKrvaEyBMFKRJvJD5pA6irB AqD3v71C5KPoBmmhALTaFx2nvwssg9uYAlZBVSFul75T1eDwT4LUbtUeW5536e/QYr 2QIpurNE6JhyrDkm7axabUx85qlPII99QTrjbnWSXXytJoMYr8+0uKVZzWS/T/5yKs JbgNHc8MNXdbaELGd2hU2zhN+QoOs/SOCxb/oYpFug036KZTtx/Rrni7xRC5VO6Xw2 3xUqKFftWnT1A== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000F9-Cr; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/24] USB: serial: ti_usb_3410_5052: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:14 +0200 Message-Id: <20210407103925.829-14-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds. The driver does not yet support changing close_delay, but let's report back the default value actually used (0.5 seconds). Signed-off-by: Johan Hovold --- drivers/usb/serial/ti_usb_3410_5052.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 7252b0ce75a6..4b497c1e850b 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -1406,10 +1406,10 @@ static int ti_get_serial_info(struct tty_struct *tty, ss->type = PORT_16550A; ss->line = port->minor; - ss->port = port->port_number; - ss->xmit_fifo_size = kfifo_size(&port->write_fifo); ss->baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; + ss->close_delay = 50; ss->closing_wait = cwait; + return 0; } From patchwork Wed Apr 7 10:39:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B208C43460 for ; Wed, 7 Apr 2021 10:40:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31A1A613A3 for ; Wed, 7 Apr 2021 10:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351241AbhDGKkU (ORCPT ); Wed, 7 Apr 2021 06:40:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:49108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351153AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A57D613E2; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=aSQemZUT4zjOWvpySanyr/JtoPh/9pFqMpRYNW1g5ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KrOgWjQyeCtVl7RHFlhbV+iUBd+DaORmBnFQQbyOuxLqcj41aZ0pMz2a66+P3BYNM HATpjH8Gz0B3koUr6QN6Hl1c8co67YQg3IrRw2hX9EvdNILy40U8Xb6etYaiQqQQLG VY8aLFkCCB0v681wV0Z4IRDTC0FvNnJwrHGLZv/9U8LX5Cs4AS749iBtJy7A4KE2BW MpsQ1itSXQruJGnk+i612zRXb8hq+N8bFcGMml98soJ6J7yTYjkEqptT93ZK/JaIed EiAj4pQwD5r8bynaL5qc4zwY+evrr8Hxp6nai07IY8kQc+OkYfyZTKypKl9XxcDuNQ PI07T2VRzy0/g== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000FC-Fk; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 14/24] USB: serial: ti_usb_3410_5052: fix TIOCSSERIAL permission check Date: Wed, 7 Apr 2021 12:39:15 +0200 Message-Id: <20210407103925.829-15-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Changing the port closing-wait parameter is a privileged operation so make sure to return -EPERM if a regular user tries to change it. Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold --- drivers/usb/serial/ti_usb_3410_5052.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 4b497c1e850b..bb50098a0ce6 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -1418,14 +1418,19 @@ static int ti_set_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; - struct ti_port *tport = usb_get_serial_port_data(port); + struct tty_port *tport = &port->port; unsigned cwait; cwait = ss->closing_wait; if (cwait != ASYNC_CLOSING_WAIT_NONE) cwait = msecs_to_jiffies(10 * ss->closing_wait); - tport->tp_port->port.closing_wait = cwait; + if (!capable(CAP_SYS_ADMIN)) { + if (cwait != tport->closing_wait) + return -EPERM; + } + + tport->closing_wait = cwait; return 0; } From patchwork Wed Apr 7 10:39:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA46C43461 for ; Wed, 7 Apr 2021 10:40:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1ED50613DF for ; Wed, 7 Apr 2021 10:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351246AbhDGKkX (ORCPT ); Wed, 7 Apr 2021 06:40:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351160AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B8188613CC; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=/LsrTsDvaxEKnXy0LT20rdMUD9DDD2wpF9Goo5KPCRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FZtUsTpWeUtqPSVHR7nUoi2rOaSAVz6lOVZ9e5A2SmpwX2Nbkf3HM/tjsfPzkgKDk n5HnZ7gw+l/GqcZHJ0PT/0OjNOWvoM3It155Yzc1tYnE0EEz0mvxW7TMu4xlL1m3BJ ZO+ZM4fIsTdI3yk4zDu13HWwEMz9iwYDG5jiUlMH47YVncMuqTcnowpjB7nRe3ggOt Hjfnxf6OERqLCVdUw7i6x767UGCQ8mY5xfZy88ghrjguEFIZ1txpLS0t+FUc/NHXgU bh7qaqG5O4wjPPoh2o5vFct+xNxDBehsCq+zJHvEwjotCis4xTNAaSl7ZVYNX5FYdI s9PpkkMb+KK6A== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000FF-Ig; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 15/24] USB: serial: usb_wwan: fix TIOCSSERIAL jiffies conversions Date: Wed, 7 Apr 2021 12:39:16 +0200 Message-Id: <20210407103925.829-16-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The port close_delay and closing_wait parameters set by TIOCSSERIAL are specified in jiffies and not milliseconds. Add the missing conversions so that the TIOCSSERIAL works as expected also when HZ is not 1000. Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)") Cc: stable@vger.kernel.org # 2.6.38 Signed-off-by: Johan Hovold --- drivers/usb/serial/usb_wwan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 46d46a4f99c9..4e9c994a972a 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -140,10 +140,10 @@ int usb_wwan_get_serial_info(struct tty_struct *tty, ss->line = port->minor; ss->port = port->port_number; ss->baud_base = tty_get_baud_rate(port->port.tty); - ss->close_delay = port->port.close_delay / 10; + ss->close_delay = jiffies_to_msecs(port->port.close_delay) / 10; ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? ASYNC_CLOSING_WAIT_NONE : - port->port.closing_wait / 10; + jiffies_to_msecs(port->port.closing_wait) / 10; return 0; } EXPORT_SYMBOL(usb_wwan_get_serial_info); @@ -155,9 +155,10 @@ int usb_wwan_set_serial_info(struct tty_struct *tty, unsigned int closing_wait, close_delay; int retval = 0; - close_delay = ss->close_delay * 10; + close_delay = msecs_to_jiffies(ss->close_delay * 10); closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ? - ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10; + ASYNC_CLOSING_WAIT_NONE : + msecs_to_jiffies(ss->closing_wait * 10); mutex_lock(&port->port.mutex); From patchwork Wed Apr 7 10:39:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EDA4C433B4 for ; Wed, 7 Apr 2021 10:40:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47FE7613CC for ; Wed, 7 Apr 2021 10:40:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351223AbhDGKkV (ORCPT ); Wed, 7 Apr 2021 06:40:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351163AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6F8C613D0; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791990; bh=+FJZzX7snDQr2UxDp4rzmX4e+ZejfTdRGS0xesd6+yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLwCl/8WspoWZ9zZaou48rpF2O3b1CuB86Bn+aWBLnQtoWdhy3abnmQRaWGcThw+X LW8zKsQdAk55OtDldo/tJS306GJbNCICbZriYjfOWCAC48CJkZC+2CDcKTGfRIAUtC CN8zOrm2Sn9ymPKZ8IeF2xtNNnKreltuNYIBQdLPMp2s0IfN98o2ESUB4sgtFCP37M ZHi71EKyiZ/fbrgy5F1VfAneYshcl8mslZYJvtouscZKBIzPcDZyeAkdclUY7rmDwp 0JM1820TDBQ07dboMDXYd5I9AvtH4IoOG6HceFa2cplRnEvfTgLWYaQQxXnEOPuT7x lMpuCEL7esNgw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000FI-LV; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/24] USB: serial: usb_wwan: fix unprivileged TIOCCSERIAL Date: Wed, 7 Apr 2021 12:39:17 +0200 Message-Id: <20210407103925.829-17-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. A non-privileged user has only ever been able to set the since long deprecated ASYNC_SPD flags and trying to change any other *supported* feature should result in -EPERM being returned. Setting the current values for any supported features should return success. Fix the usb_wwan implementation which instead indicated that the TIOCSSERIAL ioctl was not even implemented when a non-privileged user set the current values. Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)") Signed-off-by: Johan Hovold --- drivers/usb/serial/usb_wwan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 4e9c994a972a..e71c828682f5 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -166,8 +166,6 @@ int usb_wwan_set_serial_info(struct tty_struct *tty, if ((close_delay != port->port.close_delay) || (closing_wait != port->port.closing_wait)) retval = -EPERM; - else - retval = -EOPNOTSUPP; } else { port->port.close_delay = close_delay; port->port.closing_wait = closing_wait; From patchwork Wed Apr 7 10:39:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A30D2C43462 for ; Wed, 7 Apr 2021 10:40:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 817AC613A0 for ; Wed, 7 Apr 2021 10:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351256AbhDGKkX (ORCPT ); Wed, 7 Apr 2021 06:40:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351164AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA63D613A0; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=klW909RSaBy28McI30W9mgK1Oz5co4ynjfnGwGK8d0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uLsKYBfwz4vuRlSxiTKJDYhx8adfX+hij9cNteg3eozCB0Kb7g8ac7ucsjacyACdf kYLjxFrH6j9ss+nYA9ZCUODapfKyfnHyAr1OyRhA3hydRoTOBwZa5cn6PqN5VNRTmK AFw6nM8huz6IBO5v0km7Um8Kh42slNtZArk8jkMhVZNaESVw84UAJ8I2Azq0DN2KLF 5UADB2ag+vgWGpAe2QF3hFn5AXZ9TcenW5DFC5DvpJ6g1f+KvpcqqI/+9y19HuJ1kS GVS+EMDNGm57tvS4zx5gp08/4bwXDWSdCrBp5Zc913mUsw2VSv6TNKzb4Kn2lKOhmh 2SZiQyW7SIG7g== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000FL-OS; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/24] USB: serial: usb_wwan: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:18 +0200 Message-Id: <20210407103925.829-18-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The baud_base parameter could be used to set the UART base clock when it could not be detected but might as well be left unset when it is not known. Fix the usb_wwan TIOCGSERIAL implementation by dropping its custom interpretation of the unused port and baud_base fields, which were set to the port index and current line speed, respectively. Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)") Signed-off-by: Johan Hovold --- drivers/usb/serial/usb_wwan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index e71c828682f5..4ea315e5e69b 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -138,8 +138,6 @@ int usb_wwan_get_serial_info(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; ss->line = port->minor; - ss->port = port->port_number; - ss->baud_base = tty_get_baud_rate(port->port.tty); ss->close_delay = jiffies_to_msecs(port->port.close_delay) / 10; ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? ASYNC_CLOSING_WAIT_NONE : From patchwork Wed Apr 7 10:39:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C86ABC433ED for ; Wed, 7 Apr 2021 10:40:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 975EB613B3 for ; Wed, 7 Apr 2021 10:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351262AbhDGKkY (ORCPT ); Wed, 7 Apr 2021 06:40:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:49064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351165AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE78D613A9; Wed, 7 Apr 2021 10:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=lX3F9lxiWnA0PUBwgaH8gncJVnX0qeQaXfJ4Wsy4tIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ooIJ4wp+Eg08Jal4oFXiv6Vm8gWIi6pICfx+QOs4Wqci35HW50fIbG+hrfEscLEpt 8mTYAK+z3WzqlPVkRvQ3gjthaf/sgeJupSCuQYAIQVNPlUVFRjz9+wxsY5RtvpQ6lF WxyWctykOjqo5CHc4eg68UuCM9X04EoyKLcooXxJnfTcHQw/qoYfvlA1WKtjj6kkop 3mZPeA0fRvi/hwtzRMIADAuUumOkYT8iUIE0HivfeWuJ6/ZPIkMWreozzgPB+wUj4L J+S/NsCY1+kVLQkB4+zvflAkVwVXaWKH8J4tVxfuKyiW8BDu/x9aqapKT0doce24lx 3Yf4wrrQhD8Mw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000FO-RH; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/24] USB: serial: whiteheat: fix TIOCGSERIAL implementation Date: Wed, 7 Apr 2021 12:39:19 +0200 Message-Id: <20210407103925.829-19-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The port parameter is used to set the I/O port and does not make any sense to use for USB serial devices. The xmit_fifo_size parameter could be used to set the hardware transmit fifo size of a legacy UART when it could not be detected, but the interface is limited to eight bits and should be left unset when not used. The close_delay and closing_wait parameters returned by TIOCGSERIAL are specified in centiseconds (not jiffies). The driver does not yet support changing these, but let's report back the default values actually used (0.5 and 30 seconds, respectively). Signed-off-by: Johan Hovold --- drivers/usb/serial/whiteheat.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index ccfd5ed652cd..c8b10faa2ff8 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -170,7 +170,6 @@ static int firm_report_tx_done(struct usb_serial_port *port); #define COMMAND_PORT 4 #define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */ #define COMMAND_TIMEOUT_MS 2000 -#define CLOSING_DELAY (30 * HZ) /***************************************************************************** @@ -447,12 +446,9 @@ static int whiteheat_get_serial(struct tty_struct *tty, ss->type = PORT_16654; ss->line = port->minor; - ss->port = port->port_number; - ss->xmit_fifo_size = kfifo_size(&port->write_fifo); - ss->custom_divisor = 0; ss->baud_base = 460800; - ss->close_delay = CLOSING_DELAY; - ss->closing_wait = CLOSING_DELAY; + ss->close_delay = 50; + ss->closing_wait = 3000; return 0; } From patchwork Wed Apr 7 10:39:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4BD2C43460 for ; Wed, 7 Apr 2021 10:40:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81AD4613A7 for ; Wed, 7 Apr 2021 10:40:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351228AbhDGKkd (ORCPT ); Wed, 7 Apr 2021 06:40:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:49168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351166AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18AEE613AF; Wed, 7 Apr 2021 10:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=SnKb6OzBjTC6SRw+aBNHZE6syiOlb1cZ4KvRGmbCCOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CgJSDBaPERDS+6yVi2LpqPHuZm9lsQuuVbJ5Ajph0ZaZdsz5SDVuYG6uucJhVxg54 OLDdOx0g7zWCGr5IhDwA/Ch+8KEpoGAcgQ7V/PVZ9QfFVDfBB+Udq1KmfU0VRkXzGS Q31O4TXsRLxNKRHp3FE9a93mRSU3GmO7U7/tdux5QYov3z9ULzHxKn7Db5fQQYVpHI irY2rrjIpaGFBFz51twfyBPT+pqGL6d9K6DX2FnzkGNM6NSrNQJkseIvagqL+S440i 4sKfUnRvw/nRrQ2zGSw6MOS5GQdcEsPSJhSxHT3PpvIjQJy2SsIVTYqUIecC6zCb8Z Fx3ECc+LxKEpw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b5-0000FR-UE; Wed, 07 Apr 2021 12:39:43 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/24] USB: serial: fix return value for unsupported ioctls Date: Wed, 7 Apr 2021 12:39:20 +0200 Message-Id: <20210407103925.829-20-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Drivers should return -ENOTTY ("Inappropriate I/O control operation") when an ioctl isn't supported, while -EINVAL is used for invalid arguments. Fix up the TIOCMGET, TIOCMSET and TIOCGICOUNT helpers which returned -EINVAL when a USB serial driver did not implement the corresponding methods. Note that the TIOCMGET and TIOCMSET helpers predate git and do not get a corresponding Fixes tag below. Fixes: d281da7ff6f7 ("tty: Make tiocgicount a handler") Signed-off-by: Johan Hovold --- drivers/usb/serial/usb-serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 27e3bb58c872..c311cc4fabee 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -502,7 +502,7 @@ static int serial_tiocmget(struct tty_struct *tty) if (port->serial->type->tiocmget) return port->serial->type->tiocmget(tty); - return -EINVAL; + return -ENOTTY; } static int serial_tiocmset(struct tty_struct *tty, @@ -514,7 +514,7 @@ static int serial_tiocmset(struct tty_struct *tty, if (port->serial->type->tiocmset) return port->serial->type->tiocmset(tty, set, clear); - return -EINVAL; + return -ENOTTY; } static int serial_get_icount(struct tty_struct *tty, @@ -526,7 +526,7 @@ static int serial_get_icount(struct tty_struct *tty, if (port->serial->type->get_icount) return port->serial->type->get_icount(tty, icount); - return -EINVAL; + return -ENOTTY; } /* From patchwork Wed Apr 7 10:39:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8886AC433B4 for ; Wed, 7 Apr 2021 10:40:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51215613C6 for ; Wed, 7 Apr 2021 10:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351288AbhDGKkb (ORCPT ); Wed, 7 Apr 2021 06:40:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:49074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351168AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B9FE613CF; Wed, 7 Apr 2021 10:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=rko33dhmJE5C8TBzYzW+l/pc/wZvDB0H/7SSHqLc+1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/Mkp++hJHVNqU4RM7LE8HVOOxa5t32jyCf/iC0zfuDaBpqZzYbX4E6lHJebwoS/p Eoz01ihiGtDB+5IOoTin6eNdvobBFuQ/NykgJVJukhL3g6zvAhKC0gSs7rcJdgOYtK 54hzmy5kPnmRxdtfor5p52xxEPWCnmpMIkWzrg3AjoVaiRgIbon5dhpJ9DjIacY/Qp IUh8xe3T8qX/eY5jxjyturTfIYYc6yKATD9JB1LI1NsbT7KJIhEbPxLV7GqJ1KggZX N/Roulth1NOhIAir9g6bGLE9tR8pOoxKJVzX5EZdUcQLMD7PaloLGjBECGXND8vB8X GKxEupQfB22fg== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b6-0000FU-0y; Wed, 07 Apr 2021 12:39:44 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/24] USB: serial: add generic support for TIOCSSERIAL Date: Wed, 7 Apr 2021 12:39:21 +0200 Message-Id: <20210407103925.829-21-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TIOCSSERIAL is a horrid, underspecified, legacy interface which for most serial devices is only useful for setting the close_delay and closing_wait parameters. The closing_wait parameter determines how long to wait for the transfer buffers to drain during close and the default timeout of 30 seconds may not be sufficient at low line speeds. In other cases, when for example flow is stopped, the default timeout may instead be too long. Add generic support for TIOCSSERIAL and TIOCGSERIAL with handling of the three common parameters close_delay, closing_wait and line for the benefit of all USB serial drivers while still allowing drivers to implement further functionality through the existing callbacks. This currently includes a few drivers that report their base baud clock rate even if that is really only of interest when setting custom divisors through the deprecated ASYNC_SPD_CUST interface; an interface which only the FTDI driver actually implements. Some drivers have also been reporting back a fake UART type, something which should no longer be needed and will be dropped by a follow-on patch. Signed-off-by: Johan Hovold --- drivers/usb/serial/ark3116.c | 9 +---- drivers/usb/serial/f81232.c | 12 ++---- drivers/usb/serial/f81534.c | 8 +--- drivers/usb/serial/ftdi_sio.c | 11 +----- drivers/usb/serial/io_edgeport.c | 12 +----- drivers/usb/serial/io_ti.c | 17 +-------- drivers/usb/serial/mos7720.c | 12 +----- drivers/usb/serial/mos7840.c | 10 +---- drivers/usb/serial/opticon.c | 12 +----- drivers/usb/serial/option.c | 2 - drivers/usb/serial/pl2303.c | 10 +---- drivers/usb/serial/quatech2.c | 13 ------- drivers/usb/serial/ssu100.c | 13 ------- drivers/usb/serial/ti_usb_3410_5052.c | 42 +-------------------- drivers/usb/serial/usb-serial.c | 53 ++++++++++++++++++++++++--- drivers/usb/serial/usb-wwan.h | 4 -- drivers/usb/serial/usb_wwan.c | 42 --------------------- drivers/usb/serial/whiteheat.c | 12 +----- include/linux/usb/serial.h | 2 +- 19 files changed, 70 insertions(+), 226 deletions(-) diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 957cdd694b1f..c0cf60e9273d 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -385,17 +385,10 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) return result; } -static int ark3116_get_serial_info(struct tty_struct *tty, +static void ark3116_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - ss->type = PORT_16654; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } static int ark3116_tiocmget(struct tty_struct *tty) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index af0fe2a82eb2..5e34b364d94d 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -820,19 +820,13 @@ static int f81232_carrier_raised(struct usb_serial_port *port) return 0; } -static int f81232_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void f81232_get_serial(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; struct f81232_private *priv = usb_get_serial_port_data(port); ss->type = PORT_16550A; - ss->line = port->minor; ss->baud_base = priv->baud_base; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } static void f81232_interrupt_work(struct work_struct *work) @@ -1023,7 +1017,7 @@ static struct usb_serial_driver f81232_device = { .close = f81232_close, .dtr_rts = f81232_dtr_rts, .carrier_raised = f81232_carrier_raised, - .get_serial = f81232_get_serial_info, + .get_serial = f81232_get_serial, .break_ctl = f81232_break_ctl, .set_termios = f81232_set_termios, .tiocmget = f81232_tiocmget, @@ -1048,7 +1042,7 @@ static struct usb_serial_driver f81534a_device = { .close = f81232_close, .dtr_rts = f81232_dtr_rts, .carrier_raised = f81232_carrier_raised, - .get_serial = f81232_get_serial_info, + .get_serial = f81232_get_serial, .break_ctl = f81232_break_ctl, .set_termios = f81232_set_termios, .tiocmget = f81232_tiocmget, diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index c9f90d437e3a..633de52feaad 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -1140,8 +1140,7 @@ static void f81534_close(struct usb_serial_port *port) mutex_unlock(&serial_priv->urb_mutex); } -static int f81534_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void f81534_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; struct f81534_port_private *port_priv; @@ -1149,12 +1148,7 @@ static int f81534_get_serial_info(struct tty_struct *tty, port_priv = usb_get_serial_port_data(port); ss->type = PORT_16550A; - ss->line = port->minor; ss->baud_base = port_priv->baud_base; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } static void f81534_process_per_serial_block(struct usb_serial_port *port, diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index f8a0911f90ea..16d3e50487e6 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1082,8 +1082,7 @@ static int ftdi_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); static int ftdi_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss); +static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss); static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss); static void ftdi_break_ctl(struct tty_struct *tty, int break_state); @@ -1477,20 +1476,14 @@ static int read_latency_timer(struct usb_serial_port *port) return 0; } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); - ss->line = port->minor; ss->flags = priv->flags; ss->baud_base = priv->baud_base; ss->custom_divisor = priv->custom_divisor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } static int set_serial_info(struct tty_struct *tty, diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 471a1a04c9c3..f669b065dc42 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1637,17 +1637,9 @@ static int edge_tiocmget(struct tty_struct *tty) return result; } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - - ss->type = PORT_16550A; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; + ss->type = PORT_16550A; } diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index f5aab570fd05..dce994c29afe 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2433,22 +2433,9 @@ static int edge_tiocmget(struct tty_struct *tty) return result; } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - unsigned cwait; - - cwait = port->port.closing_wait; - if (cwait != ASYNC_CLOSING_WAIT_NONE) - cwait = jiffies_to_msecs(cwait) / 10; - - ss->type = PORT_16550A; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = cwait; - - return 0; + ss->type = PORT_16550A; } static void edge_break(struct tty_struct *tty, int break_state) diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index db90ce560d42..ccb1291c94a2 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -1634,17 +1634,9 @@ static int mos7720_tiocmset(struct tty_struct *tty, return 0; } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - - ss->type = PORT_16550A; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; + ss->type = PORT_16550A; } static int mos7720_ioctl(struct tty_struct *tty, diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 77cbe18a1629..d20fb0a678dc 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -1388,17 +1388,9 @@ static int mos7840_get_lsr_info(struct tty_struct *tty, * function to get information about serial port *****************************************************************************/ -static int mos7840_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void mos7840_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - ss->type = PORT_16550A; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } /***************************************************************************** diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index 1c7e5dc2c272..db84afcf7f1a 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -352,18 +352,10 @@ static int opticon_tiocmset(struct tty_struct *tty, return 0; } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - /* fake emulate a 16550 uart to make userspace code happy */ - ss->type = PORT_16550A; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; + ss->type = PORT_16550A; } static int opticon_port_probe(struct usb_serial_port *port) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index c6969ca72839..3e79a543d3e7 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -2095,8 +2095,6 @@ static struct usb_serial_driver option_1port_device = { .chars_in_buffer = usb_wwan_chars_in_buffer, .tiocmget = usb_wwan_tiocmget, .tiocmset = usb_wwan_tiocmset, - .get_serial = usb_wwan_get_serial_info, - .set_serial = usb_wwan_set_serial_info, .attach = option_attach, .release = option_release, .port_probe = usb_wwan_port_probe, diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 0455add8593a..67d598b1a0f7 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -939,17 +939,9 @@ static int pl2303_carrier_raised(struct usb_serial_port *port) return 0; } -static int pl2303_get_serial(struct tty_struct *tty, - struct serial_struct *ss) +static void pl2303_get_serial(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - ss->type = PORT_16654; - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } static void pl2303_set_break(struct usb_serial_port *port, bool enable) diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 0d23e565e0d2..5f2e7f668e68 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -453,18 +453,6 @@ static void qt2_disconnect(struct usb_serial *serial) usb_kill_urb(serial_priv->read_urb); } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct usb_serial_port *port = tty->driver_data; - - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; -} - static void qt2_process_status(struct usb_serial_port *port, unsigned char *ch) { switch (*ch) { @@ -975,7 +963,6 @@ static struct usb_serial_driver qt2_device = { .tiocmset = qt2_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, - .get_serial = get_serial_info, .set_termios = qt2_set_termios, }; diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index c4616c37f33f..3baf7c0f5a98 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -331,18 +331,6 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) return usb_serial_generic_open(tty, port); } -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct usb_serial_port *port = tty->driver_data; - - ss->line = port->minor; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; -} - static int ssu100_attach(struct usb_serial *serial) { return ssu100_initdevice(serial->dev); @@ -542,7 +530,6 @@ static struct usb_serial_driver ssu100_device = { .tiocmset = ssu100_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, - .get_serial = get_serial_info, .set_termios = ssu100_set_termios, }; diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index bb50098a0ce6..6df316bdb40f 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -328,10 +328,7 @@ static void ti_recv(struct usb_serial_port *port, unsigned char *data, static void ti_send(struct ti_port *tport); static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); static int ti_get_lsr(struct ti_port *tport, u8 *lsr); -static int ti_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss); -static int ti_set_serial_info(struct tty_struct *tty, - struct serial_struct *ss); +static void ti_get_serial_info(struct tty_struct *tty, struct serial_struct *ss); static void ti_handle_new_msr(struct ti_port *tport, u8 msr); static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty); @@ -435,7 +432,6 @@ static struct usb_serial_driver ti_1port_device = { .throttle = ti_throttle, .unthrottle = ti_unthrottle, .get_serial = ti_get_serial_info, - .set_serial = ti_set_serial_info, .set_termios = ti_set_termios, .tiocmget = ti_tiocmget, .tiocmset = ti_tiocmset, @@ -469,7 +465,6 @@ static struct usb_serial_driver ti_2port_device = { .throttle = ti_throttle, .unthrottle = ti_unthrottle, .get_serial = ti_get_serial_info, - .set_serial = ti_set_serial_info, .set_termios = ti_set_termios, .tiocmget = ti_tiocmget, .tiocmset = ti_tiocmset, @@ -1393,46 +1388,13 @@ static int ti_get_lsr(struct ti_port *tport, u8 *lsr) } -static int ti_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static void ti_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); - unsigned cwait; - - cwait = port->port.closing_wait; - if (cwait != ASYNC_CLOSING_WAIT_NONE) - cwait = jiffies_to_msecs(cwait) / 10; ss->type = PORT_16550A; - ss->line = port->minor; ss->baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; - ss->close_delay = 50; - ss->closing_wait = cwait; - - return 0; -} - - -static int ti_set_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct usb_serial_port *port = tty->driver_data; - struct tty_port *tport = &port->port; - unsigned cwait; - - cwait = ss->closing_wait; - if (cwait != ASYNC_CLOSING_WAIT_NONE) - cwait = msecs_to_jiffies(10 * ss->closing_wait); - - if (!capable(CAP_SYS_ADMIN)) { - if (cwait != tport->closing_wait) - return -EPERM; - } - - tport->closing_wait = cwait; - - return 0; } diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index c311cc4fabee..78396fe409a0 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -399,19 +399,62 @@ static void serial_unthrottle(struct tty_struct *tty) static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; + struct tty_port *tport = &port->port; + unsigned int close_delay, closing_wait; + + mutex_lock(&tport->mutex); + + close_delay = jiffies_to_msecs(tport->close_delay) / 10; + closing_wait = tport->closing_wait; + if (closing_wait != ASYNC_CLOSING_WAIT_NONE) + closing_wait = jiffies_to_msecs(closing_wait) / 10; + + ss->line = port->minor; + ss->close_delay = close_delay; + ss->closing_wait = closing_wait; if (port->serial->type->get_serial) - return port->serial->type->get_serial(tty, ss); - return -ENOTTY; + port->serial->type->get_serial(tty, ss); + + mutex_unlock(&tport->mutex); + + return 0; } static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; + struct tty_port *tport = &port->port; + unsigned int close_delay, closing_wait; + int ret = 0; + + close_delay = msecs_to_jiffies(ss->close_delay * 10); + closing_wait = ss->closing_wait; + if (closing_wait != ASYNC_CLOSING_WAIT_NONE) + closing_wait = msecs_to_jiffies(closing_wait * 10); + + mutex_lock(&tport->mutex); + + if (!capable(CAP_SYS_ADMIN)) { + if (close_delay != tport->close_delay || + closing_wait != tport->closing_wait) { + ret = -EPERM; + goto out_unlock; + } + } - if (port->serial->type->set_serial) - return port->serial->type->set_serial(tty, ss); - return -ENOTTY; + if (port->serial->type->set_serial) { + ret = port->serial->type->set_serial(tty, ss); + if (ret) + goto out_unlock; + } + + tport->close_delay = close_delay; + tport->closing_wait = closing_wait; +out_unlock: + mutex_unlock(&tport->mutex); + + return ret; } static int serial_ioctl(struct tty_struct *tty, diff --git a/drivers/usb/serial/usb-wwan.h b/drivers/usb/serial/usb-wwan.h index 79dafd98e0a1..b5331d03092f 100644 --- a/drivers/usb/serial/usb-wwan.h +++ b/drivers/usb/serial/usb-wwan.h @@ -15,10 +15,6 @@ extern int usb_wwan_write_room(struct tty_struct *tty); extern int usb_wwan_tiocmget(struct tty_struct *tty); extern int usb_wwan_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); -extern int usb_wwan_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss); -extern int usb_wwan_set_serial_info(struct tty_struct *tty, - struct serial_struct *ss); extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); extern int usb_wwan_chars_in_buffer(struct tty_struct *tty); diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 4ea315e5e69b..3eb72c59ede6 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -132,48 +132,6 @@ int usb_wwan_tiocmset(struct tty_struct *tty, } EXPORT_SYMBOL(usb_wwan_tiocmset); -int usb_wwan_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct usb_serial_port *port = tty->driver_data; - - ss->line = port->minor; - ss->close_delay = jiffies_to_msecs(port->port.close_delay) / 10; - ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? - ASYNC_CLOSING_WAIT_NONE : - jiffies_to_msecs(port->port.closing_wait) / 10; - return 0; -} -EXPORT_SYMBOL(usb_wwan_get_serial_info); - -int usb_wwan_set_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct usb_serial_port *port = tty->driver_data; - unsigned int closing_wait, close_delay; - int retval = 0; - - close_delay = msecs_to_jiffies(ss->close_delay * 10); - closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ? - ASYNC_CLOSING_WAIT_NONE : - msecs_to_jiffies(ss->closing_wait * 10); - - mutex_lock(&port->port.mutex); - - if (!capable(CAP_SYS_ADMIN)) { - if ((close_delay != port->port.close_delay) || - (closing_wait != port->port.closing_wait)) - retval = -EPERM; - } else { - port->port.close_delay = close_delay; - port->port.closing_wait = closing_wait; - } - - mutex_unlock(&port->port.mutex); - return retval; -} -EXPORT_SYMBOL(usb_wwan_set_serial_info); - int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index c8b10faa2ff8..6a95c5a0056f 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -83,7 +83,7 @@ static void whiteheat_port_remove(struct usb_serial_port *port); static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port); static void whiteheat_close(struct usb_serial_port *port); -static int whiteheat_get_serial(struct tty_struct *tty, +static void whiteheat_get_serial(struct tty_struct *tty, struct serial_struct *ss); static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old); @@ -439,18 +439,10 @@ static int whiteheat_tiocmset(struct tty_struct *tty, } -static int whiteheat_get_serial(struct tty_struct *tty, - struct serial_struct *ss) +static void whiteheat_get_serial(struct tty_struct *tty, struct serial_struct *ss) { - struct usb_serial_port *port = tty->driver_data; - ss->type = PORT_16654; - ss->line = port->minor; ss->baud_base = 460800; - ss->close_delay = 50; - ss->closing_wait = 3000; - - return 0; } diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 952272002e48..6a6ac06fe1e6 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -276,7 +276,7 @@ struct usb_serial_driver { int (*write_room)(struct tty_struct *tty); int (*ioctl)(struct tty_struct *tty, unsigned int cmd, unsigned long arg); - int (*get_serial)(struct tty_struct *tty, struct serial_struct *ss); + void (*get_serial)(struct tty_struct *tty, struct serial_struct *ss); int (*set_serial)(struct tty_struct *tty, struct serial_struct *ss); void (*set_termios)(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old); From patchwork Wed Apr 7 10:39:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A83BAC43461 for ; Wed, 7 Apr 2021 10:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6906F613A0 for ; Wed, 7 Apr 2021 10:40:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351297AbhDGKkc (ORCPT ); Wed, 7 Apr 2021 06:40:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351167AbhDGKkA (ORCPT ); Wed, 7 Apr 2021 06:40:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C55C613D8; Wed, 7 Apr 2021 10:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=hIEWDIMXdN7Zepr7RP2ktRujbppp4xhaYUonwGsO2XE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8xogpQKkiZodtBZ/0y7Orz+lxHUjx1BamnrIN8W77I0BpdHtn7gpxk4PwdHKso5w 6OOWyhUzGSS62appx8H40ZnHjQPJudsUlfr3uGdIeeqR6w0nekpVCvcwPCsS2HIV5w Kp4+WX7sqRojJt/vQMHd+PWP/AhzBjdfI5qDBlHT6vTovH/a35QlLQrz3cl2JyXJ0i SMMpkhechC3DKPSGvUvoon/rfhnq/CRnXhIadlNcJmukwUh5xZpvzxvByEmQQ2CCiZ QyBgjlfoer6q0LeTtRV1UL64B00fx/ejdObPYg2jwbtn+sWrFhpa7+kELuhO5nYkDA f/YBc/O/eAsgg== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b6-0000FX-4V; Wed, 07 Apr 2021 12:39:44 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/24] USB: serial: stop reporting legacy UART types Date: Wed, 7 Apr 2021 12:39:22 +0200 Message-Id: <20210407103925.829-22-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The TIOCGSERIAL ioctl can be used to set and retrieve the UART type for legacy UARTs, but some USB serial drivers have been reporting back random types in order to "make user-space happy". Some applications have historically expected TIOCGSERIAL to be implemented, but judging from the Debian sources, the port type not being PORT_UNKNOWN is only used to check for the existence of legacy serial ports (ttySn). Drivers like ftdi_sio have been using PORT_UNKNOWN for twenty years (and option for 10 years) without anyone complaining so let's stop reporting back anything else. In the unlikely event that this do cause problems, this should be fixed tree-wide anyway (e.g. for all USB serial drivers and also CDC-ACM). Signed-off-by: Johan Hovold --- drivers/usb/serial/ark3116.c | 7 ------- drivers/usb/serial/f81232.c | 1 - drivers/usb/serial/f81534.c | 1 - drivers/usb/serial/io_edgeport.c | 10 ---------- drivers/usb/serial/io_ti.c | 7 ------- drivers/usb/serial/mos7720.c | 6 ------ drivers/usb/serial/mos7840.c | 11 ----------- drivers/usb/serial/opticon.c | 7 ------- drivers/usb/serial/pl2303.c | 6 ------ drivers/usb/serial/ti_usb_3410_5052.c | 1 - drivers/usb/serial/whiteheat.c | 1 - 11 files changed, 58 deletions(-) diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index c0cf60e9273d..5dd710e9fe7d 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -385,12 +385,6 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) return result; } -static void ark3116_get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - ss->type = PORT_16654; -} - static int ark3116_tiocmget(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; @@ -627,7 +621,6 @@ static struct usb_serial_driver ark3116_device = { .port_probe = ark3116_port_probe, .port_remove = ark3116_port_remove, .set_termios = ark3116_set_termios, - .get_serial = ark3116_get_serial_info, .tiocmget = ark3116_tiocmget, .tiocmset = ark3116_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 5e34b364d94d..b4b847dce4bc 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -825,7 +825,6 @@ static void f81232_get_serial(struct tty_struct *tty, struct serial_struct *ss) struct usb_serial_port *port = tty->driver_data; struct f81232_private *priv = usb_get_serial_port_data(port); - ss->type = PORT_16550A; ss->baud_base = priv->baud_base; } diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 633de52feaad..c0bca52ef92a 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -1147,7 +1147,6 @@ static void f81534_get_serial_info(struct tty_struct *tty, struct serial_struct port_priv = usb_get_serial_port_data(port); - ss->type = PORT_16550A; ss->baud_base = port_priv->baud_base; } diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index f669b065dc42..4f9fb1d96380 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1637,12 +1637,6 @@ static int edge_tiocmget(struct tty_struct *tty) return result; } -static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) -{ - ss->type = PORT_16550A; -} - - /***************************************************************************** * SerialIoctl * this function handles any ioctl calls to the driver @@ -3104,7 +3098,6 @@ static struct usb_serial_driver edgeport_2port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, - .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, @@ -3140,7 +3133,6 @@ static struct usb_serial_driver edgeport_4port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, - .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, @@ -3176,7 +3168,6 @@ static struct usb_serial_driver edgeport_8port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, - .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, @@ -3212,7 +3203,6 @@ static struct usb_serial_driver epic_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, - .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write, diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index dce994c29afe..f548cdbf0a51 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2433,11 +2433,6 @@ static int edge_tiocmget(struct tty_struct *tty) return result; } -static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) -{ - ss->type = PORT_16550A; -} - static void edge_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; @@ -2696,7 +2691,6 @@ static struct usb_serial_driver edgeport_1port_device = { .release = edge_release, .port_probe = edge_port_probe, .port_remove = edge_port_remove, - .get_serial = get_serial_info, .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, @@ -2735,7 +2729,6 @@ static struct usb_serial_driver edgeport_2port_device = { .release = edge_release, .port_probe = edge_port_probe, .port_remove = edge_port_remove, - .get_serial = get_serial_info, .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index ccb1291c94a2..6ee83886e2c9 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -1634,11 +1634,6 @@ static int mos7720_tiocmset(struct tty_struct *tty, return 0; } -static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) -{ - ss->type = PORT_16550A; -} - static int mos7720_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { @@ -1778,7 +1773,6 @@ static struct usb_serial_driver moschip7720_2port_driver = { .ioctl = mos7720_ioctl, .tiocmget = mos7720_tiocmget, .tiocmset = mos7720_tiocmset, - .get_serial = get_serial_info, .set_termios = mos7720_set_termios, .write = mos7720_write, .write_room = mos7720_write_room, diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index d20fb0a678dc..28e4093794e0 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -1383,16 +1383,6 @@ static int mos7840_get_lsr_info(struct tty_struct *tty, return 0; } -/***************************************************************************** - * mos7840_get_serial_info - * function to get information about serial port - *****************************************************************************/ - -static void mos7840_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) -{ - ss->type = PORT_16550A; -} - /***************************************************************************** * SerialIoctl * this function handles any ioctl calls to the driver @@ -1771,7 +1761,6 @@ static struct usb_serial_driver moschip7840_4port_device = { .probe = mos7840_probe, .attach = mos7840_attach, .ioctl = mos7840_ioctl, - .get_serial = mos7840_get_serial_info, .set_termios = mos7840_set_termios, .break_ctl = mos7840_break, .tiocmget = mos7840_tiocmget, diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index db84afcf7f1a..40c713fae0c3 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -352,12 +352,6 @@ static int opticon_tiocmset(struct tty_struct *tty, return 0; } -static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) -{ - /* fake emulate a 16550 uart to make userspace code happy */ - ss->type = PORT_16550A; -} - static int opticon_port_probe(struct usb_serial_port *port) { struct opticon_private *priv; @@ -399,7 +393,6 @@ static struct usb_serial_driver opticon_device = { .chars_in_buffer = opticon_chars_in_buffer, .throttle = usb_serial_generic_throttle, .unthrottle = usb_serial_generic_unthrottle, - .get_serial = get_serial_info, .tiocmget = opticon_tiocmget, .tiocmset = opticon_tiocmset, .process_read_urb = opticon_process_read_urb, diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 67d598b1a0f7..10f92a60f5fb 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -939,11 +939,6 @@ static int pl2303_carrier_raised(struct usb_serial_port *port) return 0; } -static void pl2303_get_serial(struct tty_struct *tty, struct serial_struct *ss) -{ - ss->type = PORT_16654; -} - static void pl2303_set_break(struct usb_serial_port *port, bool enable) { struct usb_serial *serial = port->serial; @@ -1127,7 +1122,6 @@ static struct usb_serial_driver pl2303_device = { .close = pl2303_close, .dtr_rts = pl2303_dtr_rts, .carrier_raised = pl2303_carrier_raised, - .get_serial = pl2303_get_serial, .break_ctl = pl2303_break_ctl, .set_termios = pl2303_set_termios, .tiocmget = pl2303_tiocmget, diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 6df316bdb40f..c312d0cce5fb 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -1393,7 +1393,6 @@ static void ti_get_serial_info(struct tty_struct *tty, struct serial_struct *ss) struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); - ss->type = PORT_16550A; ss->baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; } diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 6a95c5a0056f..5116ed9db3eb 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -441,7 +441,6 @@ static int whiteheat_tiocmset(struct tty_struct *tty, static void whiteheat_get_serial(struct tty_struct *tty, struct serial_struct *ss) { - ss->type = PORT_16654; ss->baud_base = 460800; } From patchwork Wed Apr 7 10:39:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 374DDC433B4 for ; Wed, 7 Apr 2021 10:40:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7F39613A7 for ; Wed, 7 Apr 2021 10:40:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346850AbhDGKk1 (ORCPT ); Wed, 7 Apr 2021 06:40:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351173AbhDGKkB (ORCPT ); Wed, 7 Apr 2021 06:40:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F44461359; Wed, 7 Apr 2021 10:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791992; bh=LI3EAIik89YYWfrjfBlEy8Rou74U6p2uSQKDwYIr75A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cx/yiBlKc6DgKFv66iHzwMJzlblD6+OdfoT3qCbxzSFvIwQ/23P+pm6gEsQLViU5l 3gPmpMHEYcKNQxFuVyphdR9d0MgLB9bxc76xhV5JMye5ivGet9a8s80Sc5mwOL26hH KntF4OF6jHmbv+u5QNo3ZBMtY9wTq/ZVl26Yc3nC3CMtkX9p6O4t3wgJdfJvU+0UaF fK1bp5xAFrJw39QsnuEHofLg0PfSRvOIhgRIfNEdbAwXayBzhdrHNpQni9hgZit04E hohiMSgRuoJqMtfComTLQMQS8ebOv63SmJgrCSoEHGUdJgCzYU40D8XQHvwJaYeqDA aB5hueNjHAxTw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b6-0000Fa-7f; Wed, 07 Apr 2021 12:39:44 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/24] USB: serial: ftdi_sio: ignore baud_base changes Date: Wed, 7 Apr 2021 12:39:23 +0200 Message-Id: <20210407103925.829-23-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The TIOCSSERIAL error handling is inconsistent at best, but drivers tend to ignore requests to change parameters which cannot be changed rather than return an error. The FTDI driver ignores change requests for all immutable parameters but baud_base so return success also in this case for consistency. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 16d3e50487e6..3fd7875200b9 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1509,10 +1509,6 @@ static int set_serial_info(struct tty_struct *tty, goto check_and_exit; } - if (ss->baud_base != priv->baud_base) { - mutex_unlock(&priv->cfg_lock); - return -EINVAL; - } /* Make the changes - these are privileged changes! */ From patchwork Wed Apr 7 10:39:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61DDFC433ED for ; Wed, 7 Apr 2021 10:40:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25848613A0 for ; Wed, 7 Apr 2021 10:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346481AbhDGKk3 (ORCPT ); Wed, 7 Apr 2021 06:40:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351169AbhDGKkB (ORCPT ); Wed, 7 Apr 2021 06:40:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E778613CE; Wed, 7 Apr 2021 10:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=4kdGQLKD5QZqI2txCJcBEXqco33DJCxonvayaCmjC6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mASRszcHLAyyk953aYUbU3G/d7Is9mt2HWNycR4fUaYHei5+AXyabnSYOtvQOkb/Y A/rfEY1Rjk1DMzbNElWkvUVM6v772d5Y/qujzzfqY+E7s6bL4iR4nrlEjZKnWbB7wx qmdmWbOJO8IXK8GO/Cj1H6quVlbuYTjj7YLqI0kdZKE5BbDOVZwl66NbEbaSpH6gqb PMyuHo3qrlrYwE+YgukEzfmfOboMFt8suzeKD06FnhUZmM9+Tbvun0eLe6TLFeLWMo nPpI9wbQ6MMKJaVZeLtYGzQzC0HVCUzM7zPW+qSPc0O8xxRlCgx23PiRTyt0Fk51Ta 00mvJSyVyt86Q== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b6-0000Fd-AX; Wed, 07 Apr 2021 12:39:44 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/24] USB: serial: ftdi_sio: simplify TIOCGSERIAL permission check Date: Wed, 7 Apr 2021 12:39:24 +0200 Message-Id: <20210407103925.829-24-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Changing the deprecated custom_divisor field is an unprivileged operation so after verifying that flag field does not contain any privileged changes both updates can be carried out by any user. Combine the two branches and drop the erroneous comment. Note that private flags field is only used for ASYNC flags so there's no need to try to retain any other bits when updating the flags. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 3fd7875200b9..9228e56a91c0 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1496,27 +1496,16 @@ static int set_serial_info(struct tty_struct *tty, mutex_lock(&priv->cfg_lock); old_priv = *priv; - /* Do error checking and permission checking */ - if (!capable(CAP_SYS_ADMIN)) { if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) { mutex_unlock(&priv->cfg_lock); return -EPERM; } - priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | - (ss->flags & ASYNC_USR_MASK)); - priv->custom_divisor = ss->custom_divisor; - goto check_and_exit; } - - /* Make the changes - these are privileged changes! */ - - priv->flags = ((priv->flags & ~ASYNC_FLAGS) | - (ss->flags & ASYNC_FLAGS)); + priv->flags = ss->flags & ASYNC_FLAGS; priv->custom_divisor = ss->custom_divisor; -check_and_exit: write_latency_timer(port); if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK || From patchwork Wed Apr 7 10:39:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12187719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C145FC43470 for ; Wed, 7 Apr 2021 10:40:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72DD6613A0 for ; Wed, 7 Apr 2021 10:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351214AbhDGKka (ORCPT ); Wed, 7 Apr 2021 06:40:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:49076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351171AbhDGKkB (ORCPT ); Wed, 7 Apr 2021 06:40:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 813DF613D1; Wed, 7 Apr 2021 10:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617791991; bh=hxIJtit8EJ+Brug2ei0l8Ef85prFYKfb3oZE4LDPzpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LVspfmEPa8er2cjfB+y3xA0dzojAAv5vX/qOnYHKDrAyjbk0RJ5V+u9XHOE9YvpgO 7sYSVssG4GRB9stoIZzsGPT8iEd4PyRPDH8r5iflrm+ibpLvskZrpDEaMsYxHYi+Bz kdxPG4C7NcPTHF9IojRxDUlkpFbhDMSCu1LK+r3EXVTcANA5Ju4b6QGzIgSeFdT/y9 +PwcyPo+s2RfJOFNHYZGMk4FrTRWZMbsRUTb9ftKFmoyfaCp2tSzWbrG+R0uXTZQXw 0W33FDbp4fbwKozrqQ+bnRoFQ3SqJisSI7fsoTDn6NDxo7lrYSOvJV/f6Za4yt49+K uPkjbgG9rLmUA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lU5b6-0000Fg-D7; Wed, 07 Apr 2021 12:39:44 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 24/24] USB: serial: ftdi_sio: clean up TIOCSSERIAL Date: Wed, 7 Apr 2021 12:39:25 +0200 Message-Id: <20210407103925.829-25-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210407103925.829-1-johan@kernel.org> References: <20210407103925.829-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The TIOCSSERIAL implementation needs to compare the old flag and divisor settings with the new to detect ASYNC_SPD changes, but there's no need to copy all driver state to the stack for that. While at it, unbreak the function parameter list. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 9228e56a91c0..6f2659e59b2e 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1486,15 +1486,13 @@ static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss) ss->custom_divisor = priv->custom_divisor; } -static int set_serial_info(struct tty_struct *tty, - struct serial_struct *ss) +static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss) { struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); - struct ftdi_private old_priv; + int old_flags, old_divisor; mutex_lock(&priv->cfg_lock); - old_priv = *priv; if (!capable(CAP_SYS_ADMIN)) { if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) { @@ -1503,14 +1501,17 @@ static int set_serial_info(struct tty_struct *tty, } } + old_flags = priv->flags; + old_divisor = priv->custom_divisor; + priv->flags = ss->flags & ASYNC_FLAGS; priv->custom_divisor = ss->custom_divisor; write_latency_timer(port); - if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK || + if ((priv->flags ^ old_flags) & ASYNC_SPD_MASK || ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && - priv->custom_divisor != old_priv.custom_divisor)) { + priv->custom_divisor != old_divisor)) { /* warn about deprecation unless clearing */ if (priv->flags & ASYNC_SPD_MASK)