From patchwork Wed May 19 09:20:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12266713 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.4 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 8C05DC43462 for ; Wed, 19 May 2021 09:20:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69A4F611BF for ; Wed, 19 May 2021 09:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345046AbhESJVw (ORCPT ); Wed, 19 May 2021 05:21:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:44142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344889AbhESJVs (ORCPT ); Wed, 19 May 2021 05:21:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D56A611AE; Wed, 19 May 2021 09:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621416029; bh=YhJbvkmwFzzsKfnc6qJ0TLdbhKOJRSXI6iLzQvK4J0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7nUutTTvfMMpOmIEU5FExVB8NKW2Rce/nOr3EE9EFnkcuKHduCtCbTtg0+0TLG1A B3VPOHTmdQQHXGsupYjmXI1zvYmlSIi8u1BtYnj8jR7Ziexe3ao8UZr2XtKmD6IF5X bO3ub73jtwNSGbddYeWcD8cJv+Q9Yef6Db6DDVnuL3sCJKsR5XNZfY7Zi151sNJs9L MuL24iHKEUU+KQ1MtIYbGn4quSDiuaGToe0b1No9sznwPFHOCaIW1utS5ij2YzWlYO gaBJjXqdtpWvVj3PPQPdin41kPprLUN99uW1nlPL2i7W9JaCpHPY/1JKhO/nCERfDP C2PBI5fwSTXdA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ljINQ-0002YY-I1; Wed, 19 May 2021 11:20:28 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , Jiri Slaby , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] USB: serial: digi_acceleport: reduce chars_in_buffer over-reporting Date: Wed, 19 May 2021 11:20:01 +0200 Message-Id: <20210519092006.9775-2-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210519092006.9775-1-johan@kernel.org> References: <20210519092006.9775-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Due to an ancient quirk in n_tty poll implementation, the digi_acceleport driver has been reporting that its queue contains 256 (WAKEUP_CHARS) characters whenever its write URB is in use. This has not been necessary since 2003 when the line-discipline started taking the write room into account so let's return the maximum transfer size again in order to over-report a little less and incidentally fix the related debug statement. Signed-off-by: Johan Hovold --- drivers/usb/serial/digi_acceleport.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 19ee8191647c..a4194b70a6fe 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -1048,8 +1048,7 @@ static unsigned int digi_chars_in_buffer(struct tty_struct *tty) if (priv->dp_write_urb_in_use) { dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n", priv->dp_port_num, port->bulk_out_size - 2); - /* return(port->bulk_out_size - 2); */ - return 256; + return port->bulk_out_size - 2; } else { dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n", priv->dp_port_num, priv->dp_out_buf_len); From patchwork Wed May 19 09:20: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: 12266705 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.4 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 9615EC43460 for ; Wed, 19 May 2021 09:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7933360FE4 for ; Wed, 19 May 2021 09:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344981AbhESJVt (ORCPT ); Wed, 19 May 2021 05:21:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344956AbhESJVs (ORCPT ); Wed, 19 May 2021 05:21:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35B3E611BF; Wed, 19 May 2021 09:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621416029; bh=H0hq/IYa/hEylOqWgyYg83ERvIBrUcwhFOkmavOFN1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2xpx8cMuc9O3WQhiKxHvz/qItJ6r1cshhpIuAXk8weCb4groFbkvnH2EcUGtOBYK QtiI/St2FJKAvlQuO8CENai7PGJUiqrYUtsa6Ojl9FZcCCxAc8yp0H0lJQhZFo8Kls 9A6Gce7+0QatcUZkoJwss8A/vrSqf3XSCSNp0AlsGVfSONcIuOG0Xnxi1NVRImZwgl t3h9JAB3BV07B2Zk0X7SFXXs0Ag14jaDjaPFDkemqONfLi6Ph2Tot1aFfEhhk+ySiv rZzV+9qQBTe7k0TiHrAcqYf9YlZWXlr45YXL2DpLM7U4sqCK46qwQC5W6rfIxkxXYu 6jbFsRB5zJzAQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ljINQ-0002Ya-KB; Wed, 19 May 2021 11:20:28 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , Jiri Slaby , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] USB: serial: digi_acceleport: add chars_in_buffer locking Date: Wed, 19 May 2021 11:20:02 +0200 Message-Id: <20210519092006.9775-3-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210519092006.9775-1-johan@kernel.org> References: <20210519092006.9775-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Both the dp_write_urb_in_use flag and dp_out_buf_len counter should be accessed while holding the driver port lock. Add the missing locking to chars_in_buffer and clean up the implementation somewhat by using a common exit path. Signed-off-by: Johan Hovold --- drivers/usb/serial/digi_acceleport.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index a4194b70a6fe..754c66ff0fc1 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -1044,17 +1044,19 @@ static unsigned int digi_chars_in_buffer(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); + unsigned long flags; + unsigned int chars; - if (priv->dp_write_urb_in_use) { - dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n", - priv->dp_port_num, port->bulk_out_size - 2); - return port->bulk_out_size - 2; - } else { - dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n", - priv->dp_port_num, priv->dp_out_buf_len); - return priv->dp_out_buf_len; - } + spin_lock_irqsave(&priv->dp_port_lock, flags); + if (priv->dp_write_urb_in_use) + chars = port->bulk_out_size - 2; + else + chars = priv->dp_out_buf_len; + spin_unlock_irqrestore(&priv->dp_port_lock, flags); + dev_dbg(&port->dev, "%s: port=%d, chars=%d\n", __func__, + priv->dp_port_num, chars); + return chars; } static void digi_dtr_rts(struct usb_serial_port *port, int on) From patchwork Wed May 19 09:20: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: 12266707 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.4 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 A0A76C433B4 for ; Wed, 19 May 2021 09:20:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FDAB60FE4 for ; Wed, 19 May 2021 09:20:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345001AbhESJVu (ORCPT ); Wed, 19 May 2021 05:21:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:44166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344959AbhESJVs (ORCPT ); Wed, 19 May 2021 05:21:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 37EB1610E9; Wed, 19 May 2021 09:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621416029; bh=q0Dh0cBtH9BLd36ldaoGyBeuh4K7+V/VNafNnRQ28L8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uvPR7HMufU1No/FkWpSf+tDV6eM8bItTdyWIroES8lYku/QLcW8U60U+V0TZUFoZY wFUgM8HkVil8anqT4aU3aiLSoCRZz6XGU61OOPohuQabpc+aIER8+7m28whv4/cFnI Z7ZRL7WcXddiO1Njdb8OJW8SVczctb9Kdy2vTXtgs3wIqteplHTJ27gQRrGJ8WLQjN w1uIa9mhqP5EAjICg/GRxJqXeq5TkjQNy89r4h60pqeIG2lmosujcnlMKXOTxW0oZ6 fVMeIvlSG2alkQdSFpf73rtNtcLWYlp2QbdCh/Q++aTFlyu7/1UpQ9Q9XFllyDbd3P VXzHxphc4RdTg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ljINQ-0002Yd-Mn; Wed, 19 May 2021 11:20:28 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , Jiri Slaby , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] USB: serial: io_edgeport: drop buffer-callback sanity checks Date: Wed, 19 May 2021 11:20:03 +0200 Message-Id: <20210519092006.9775-4-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210519092006.9775-1-johan@kernel.org> References: <20210519092006.9775-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The driver write_room and chars_in_buffer callbacks used to incorrectly return a negative errno in case they were called while or after the port had been closed. The return value was later changed to zero by commit d76f2f4462bb ("io_edgeport: Fix various bogus returns to the tty layer") but the bogus sanity checks were left in place as were the outdated function-header comments. These callbacks will never be called for an uninitialised port so drop the unnecessary sanity checks and the outdated comments. Signed-off-by: Johan Hovold --- drivers/usb/serial/io_edgeport.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 1f8dff4390c7..ea4edf5eed27 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1351,9 +1351,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, /***************************************************************************** * edge_write_room * this function is called by the tty driver when it wants to know how - * many bytes of data we can accept for a specific port. If successful, - * we return the amount of room that we have for this port (the txCredits) - * otherwise we return a negative error number. + * many bytes of data we can accept for a specific port. *****************************************************************************/ static unsigned int edge_write_room(struct tty_struct *tty) { @@ -1362,16 +1360,6 @@ static unsigned int edge_write_room(struct tty_struct *tty) unsigned int room; unsigned long flags; - if (edge_port == NULL) - return 0; - if (edge_port->closePending) - return 0; - - if (!edge_port->open) { - dev_dbg(&port->dev, "%s - port not opened\n", __func__); - return 0; - } - /* total of both buffers is still txCredit */ spin_lock_irqsave(&edge_port->ep_lock, flags); room = edge_port->txCredits - edge_port->txfifo.count; @@ -1387,9 +1375,6 @@ static unsigned int edge_write_room(struct tty_struct *tty) * this function is called by the tty driver when it wants to know how * many bytes of data we currently have outstanding in the port (data that * has been written, but hasn't made it out the port yet) - * If successful, we return the number of bytes left to be written in the - * system, - * Otherwise we return a negative error number. *****************************************************************************/ static unsigned int edge_chars_in_buffer(struct tty_struct *tty) { @@ -1398,16 +1383,6 @@ static unsigned int edge_chars_in_buffer(struct tty_struct *tty) unsigned int num_chars; unsigned long flags; - if (edge_port == NULL) - return 0; - if (edge_port->closePending) - return 0; - - if (!edge_port->open) { - dev_dbg(&port->dev, "%s - port not opened\n", __func__); - return 0; - } - spin_lock_irqsave(&edge_port->ep_lock, flags); num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count; From patchwork Wed May 19 09:20: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: 12266709 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.4 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 8F430C43460 for ; Wed, 19 May 2021 09:20:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71691611BF for ; Wed, 19 May 2021 09:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345018AbhESJVv (ORCPT ); Wed, 19 May 2021 05:21:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344940AbhESJVs (ORCPT ); Wed, 19 May 2021 05:21:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 329186135F; Wed, 19 May 2021 09:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621416029; bh=in4Ts4+KP0t8HEnjNhpwCgfKTJQ6jDj/qQsiRcQqM3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOQ5k3SIEWWilVBVYDjYbxy5fXG2iezkXvfebeIxIdF8UzsILfiXCtfcloNlEt1Cp iOLJMUJASiUywRmVzSRF/H7pPoYGRSbU6dKVfCCo2FOMS44T6dhIKcfPKbpalc5qW6 1z4lKJMt0yZE0XHlaLbJwLXA1EE/0q0bngpXEJts+RR1W/vbFz654jFlMLah7NTJs/ 20p7v8m5nUDkDJRwc6sJtDBF0Uivzp+uUz8gml3jjCGSn68b29l+E30IefBKjW0TIo fYxQkfVY1sCP8p37Mhy9goQdFHXD+T/tgwKOxsRNSrSrb8FmyLBs3vVNraf3vHoazT dIJTg2nr8WA1g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ljINQ-0002Yg-Q1; Wed, 19 May 2021 11:20:28 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , Jiri Slaby , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] USB: serial: mos7720: drop buffer-callback sanity checks Date: Wed, 19 May 2021 11:20:04 +0200 Message-Id: <20210519092006.9775-5-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210519092006.9775-1-johan@kernel.org> References: <20210519092006.9775-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The driver write_room and chars_in_buffer callbacks used to incorrectly return a negative errno in case they were ever called with a NULL port driver-data pointer. The return value was later changed to zero by commit 23198fda7182 ("tty: fix chars_in_buffers") but the bogus sanity checks were left in place as were the outdated function-header comments. The port driver data isn't cleared until after the port has been deregistered and all open ttys have been hung up so drop the unnecessary sanity checks and the outdated comments. Signed-off-by: Johan Hovold --- drivers/usb/serial/mos7720.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index ce41009756f3..227f43d2bd56 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -945,20 +945,13 @@ static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) * this function is called by the tty driver when it wants to know how many * bytes of data we currently have outstanding in the port (data that has * been written, but hasn't made it out the port yet) - * If successful, we return the number of bytes left to be written in the - * system, - * Otherwise we return a negative error number. */ static unsigned int mos7720_chars_in_buffer(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; + struct moschip_port *mos7720_port = usb_get_serial_port_data(port); int i; unsigned int chars = 0; - struct moschip_port *mos7720_port; - - mos7720_port = usb_get_serial_port_data(port); - if (mos7720_port == NULL) - return 0; for (i = 0; i < NUM_URBS; ++i) { if (mos7720_port->write_urb_pool[i] && @@ -1030,20 +1023,14 @@ static void mos7720_break(struct tty_struct *tty, int break_state) * mos7720_write_room * this function is called by the tty driver when it wants to know how many * bytes of data we can accept for a specific port. - * If successful, we return the amount of room that we have for this port - * Otherwise we return a negative error number. */ static unsigned int mos7720_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; - struct moschip_port *mos7720_port; + struct moschip_port *mos7720_port = usb_get_serial_port_data(port); unsigned int room = 0; int i; - mos7720_port = usb_get_serial_port_data(port); - if (mos7720_port == NULL) - return 0; - /* FIXME: Locking */ for (i = 0; i < NUM_URBS; ++i) { if (mos7720_port->write_urb_pool[i] && From patchwork Wed May 19 09:20: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: 12266711 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.4 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 72E84C433B4 for ; Wed, 19 May 2021 09:20:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5161560FE4 for ; Wed, 19 May 2021 09:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345023AbhESJVv (ORCPT ); Wed, 19 May 2021 05:21:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344923AbhESJVs (ORCPT ); Wed, 19 May 2021 05:21:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 302DC60FE4; Wed, 19 May 2021 09:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621416029; bh=/hEn/ktVhek3gXcDSTDRdiw8v0mvpRq4JJ0XqdB9C7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IyZ/j7Uus5AVy/kFKS7h+/+STy0D7dFxtDtx0r+oyKxbiNkFHC02Vf4YFDqlj3pKf ci9+Hsf+Cp31z8ysSsh1nVcrskKvGx0VTGKKGsrVriYBLQZi7wY/zPMnWlCVvdFy/+ UCdAxNVLqy95Y5urMUDLp6L/vsQTxLvMDuBUdRqVzqhqJ9/h497cgaNt6r+S1UXMfE jWOP9BE5vHvyafzbWfTQqj6OnyEoPEpzZfAoqTcFgn2KX/JPEJdEqMqa7V7DFHN4MU baWMFBJrd2GBOSAXTHyYqgYJoJdMIIqAlGRQ5y7h7NEZFPr0jSuiSAkpOFsemFdLEu B796JLELGzZRg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ljINQ-0002Yj-Sy; Wed, 19 May 2021 11:20:28 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , Jiri Slaby , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] USB: serial: mos7840: drop buffer-callback return-value comments Date: Wed, 19 May 2021 11:20:05 +0200 Message-Id: <20210519092006.9775-6-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210519092006.9775-1-johan@kernel.org> References: <20210519092006.9775-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The driver write_room and chars_in_buffer callbacks used to incorrectly return a negative errno in case they were called with a NULL port driver-data pointer or if some other always-true sanity checks failed. The bogus sanity checks were later removed by commit ce039bd4b21f ("USB: serial: mos7840: drop paranoid port checks") and 7b2faede671a ("USB: serial: mos7840: drop port driver data accessors") but the function-header comments were never updated to match. Drop the outdated return-value comments. Signed-off-by: Johan Hovold --- drivers/usb/serial/mos7840.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index b22ccbd98998..d7fe33ca73e4 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -730,9 +730,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) * this function is called by the tty driver when it wants to know how many * bytes of data we currently have outstanding in the port (data that has * been written, but hasn't made it out the port yet) - * If successful, we return the number of bytes left to be written in the - * system, - * Otherwise we return zero. *****************************************************************************/ static unsigned int mos7840_chars_in_buffer(struct tty_struct *tty) @@ -814,8 +811,6 @@ static void mos7840_break(struct tty_struct *tty, int break_state) * mos7840_write_room * this function is called by the tty driver when it wants to know how many * bytes of data we can accept for a specific port. - * If successful, we return the amount of room that we have for this port - * Otherwise we return a negative error number. *****************************************************************************/ static unsigned int mos7840_write_room(struct tty_struct *tty) From patchwork Wed May 19 09:20: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: 12266715 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.4 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 9530DC43461 for ; Wed, 19 May 2021 09:20:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A7D26135F for ; Wed, 19 May 2021 09:20:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345140AbhESJVy (ORCPT ); Wed, 19 May 2021 05:21:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:44186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344951AbhESJVt (ORCPT ); Wed, 19 May 2021 05:21:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3CAF461363; Wed, 19 May 2021 09:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621416029; bh=RLQFovnxGyeCq9RZvMxT7WIIXWK0rhVwwaRKTMU2wq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=my/MOYNSNUbXGQHUBcDBlygvsNmZf6u/6/Vo0R4NjN3KVvSBC9epNWaxhjlZvKgco S5aqG4Ve6L2cwy/rDGLVHQ3ZijkW8yU/lyio4gjvHFjXeqluG5F3cIwrdxRV07hATy lZVL5x8oQyXyBDBApYzf262fZhg2BS6Fvx5bfxF3OrhD3IJuISmHdSu2gFGRyYxiNy Q42/4/vHfuaQHEa9JiUfhvbker5vgez1tA0qloK/EZFt7kBL2h6rKUbXkKtSkxGmAA Sq0U0JA0hT4x8NhsMm2i1oQWfSYR5kA+klxsCeTmk+6ivp5jsWwQAjnz4q99gQbndw oqcn863zLRPwg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ljINQ-0002Yn-Vp; Wed, 19 May 2021 11:20:29 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , Jiri Slaby , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] USB: serial: drop irq-flags initialisations Date: Wed, 19 May 2021 11:20:06 +0200 Message-Id: <20210519092006.9775-7-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210519092006.9775-1-johan@kernel.org> References: <20210519092006.9775-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There's no need to initialise irq-flags variables before saving the interrupt state. Drop the redundant initialisations from the three drivers that got this wrong. Signed-off-by: Johan Hovold --- drivers/usb/serial/digi_acceleport.c | 13 ++++++------- drivers/usb/serial/metro-usb.c | 12 ++++++------ drivers/usb/serial/quatech2.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 754c66ff0fc1..af65eb863d70 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -372,7 +372,7 @@ static int digi_write_oob_command(struct usb_serial_port *port, int len; struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); - unsigned long flags = 0; + unsigned long flags; dev_dbg(&port->dev, "digi_write_oob_command: TOP: port=%d, count=%d\n", @@ -430,7 +430,7 @@ static int digi_write_inb_command(struct usb_serial_port *port, int len; struct digi_port *priv = usb_get_serial_port_data(port); unsigned char *data = port->write_urb->transfer_buffer; - unsigned long flags = 0; + unsigned long flags; dev_dbg(&port->dev, "digi_write_inb_command: TOP: port=%d, count=%d\n", priv->dp_port_num, count); @@ -511,8 +511,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port, struct usb_serial_port *oob_port = (struct usb_serial_port *) ((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); unsigned char *data = oob_port->write_urb->transfer_buffer; - unsigned long flags = 0; - + unsigned long flags; dev_dbg(&port->dev, "digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x\n", @@ -577,7 +576,7 @@ static int digi_transmit_idle(struct usb_serial_port *port, int ret; unsigned char buf[2]; struct digi_port *priv = usb_get_serial_port_data(port); - unsigned long flags = 0; + unsigned long flags; spin_lock_irqsave(&priv->dp_port_lock, flags); priv->dp_transmit_idle = 0; @@ -887,7 +886,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, int ret, data_len, new_len; struct digi_port *priv = usb_get_serial_port_data(port); unsigned char *data = port->write_urb->transfer_buffer; - unsigned long flags = 0; + unsigned long flags; dev_dbg(&port->dev, "digi_write: TOP: port=%d, count=%d\n", priv->dp_port_num, count); @@ -1024,8 +1023,8 @@ static unsigned int digi_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); + unsigned long flags; unsigned int room; - unsigned long flags = 0; spin_lock_irqsave(&priv->dp_port_lock, flags); diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index f9ce9e7b9b80..30ab565e0738 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c @@ -109,9 +109,9 @@ static void metrousb_read_int_callback(struct urb *urb) struct usb_serial_port *port = urb->context; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; + unsigned long flags; int throttled = 0; int result = 0; - unsigned long flags = 0; dev_dbg(&port->dev, "%s\n", __func__); @@ -171,7 +171,7 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); - unsigned long flags = 0; + unsigned long flags; int result = 0; /* Set the private data information for the port. */ @@ -268,7 +268,7 @@ static void metrousb_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); - unsigned long flags = 0; + unsigned long flags; /* Set the private information for the port to stop reading data. */ spin_lock_irqsave(&metro_priv->lock, flags); @@ -281,7 +281,7 @@ static int metrousb_tiocmget(struct tty_struct *tty) unsigned long control_state = 0; struct usb_serial_port *port = tty->driver_data; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); - unsigned long flags = 0; + unsigned long flags; spin_lock_irqsave(&metro_priv->lock, flags); control_state = metro_priv->control_state; @@ -296,7 +296,7 @@ static int metrousb_tiocmset(struct tty_struct *tty, struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); - unsigned long flags = 0; + unsigned long flags; unsigned long control_state = 0; dev_dbg(&port->dev, "%s - set=%d, clear=%d\n", __func__, set, clear); @@ -323,7 +323,7 @@ static void metrousb_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct metrousb_private *metro_priv = usb_get_serial_port_data(port); - unsigned long flags = 0; + unsigned long flags; int result = 0; /* Set the private information for the port to resume reading data. */ diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 3b5f2032ecdb..d3377f3b5a23 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -874,7 +874,7 @@ static unsigned int qt2_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct qt2_port_private *port_priv; - unsigned long flags = 0; + unsigned long flags; unsigned int r; port_priv = usb_get_serial_port_data(port);