From patchwork Mon Jul 5 08:20: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: 470427 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=-20.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=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 5A924C07E99 for ; Mon, 5 Jul 2021 08:20:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 478846162A for ; Mon, 5 Jul 2021 08:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230312AbhGEIXU (ORCPT ); Mon, 5 Jul 2021 04:23:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:40890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbhGEIXR (ORCPT ); Mon, 5 Jul 2021 04:23:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6E14613D1; Mon, 5 Jul 2021 08:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625473240; bh=2qGaB+9dBhwuQSeXnep3Txw8p7mnzuwuscJcjkt04Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5gahN3fE88vqceXluYGEonIG66aX9sCDRemX9rLieY8wkPbyNuflgwi2HJRHOHQ8 h6nDxpj5AYLsvTII33x+1z5QmPf2f1MxSpFYbJzhykDZJ9VmSfGJ2g5a72u8REUwo8 UqeB/B7XUUJP8mvSqgtquwhzv9uUtu0kVfPx5xgcHEjE/MRH1Siv1bjohlU3gti+bv gxbwFkvwn/XBreVEq9SLE2QHf2GrA8F9mCnsmHy4UmKkRnD5elk7kLIPpGDvEfdtaq rPyWOI2gb+5Y5x7uTfEVVLtkDz31fFlrFQj1YZfIYkvVdidgP8BB6LPKKE9jwadHlJ IKw9LqrPx7Wqg== Received: from johan by xi with local (Exim 4.94.2) (envelope-from ) id 1m0JqF-0004lp-46; Mon, 05 Jul 2021 10:20:35 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/6] USB: serial: cp210x: fix control-characters error handling Date: Mon, 5 Jul 2021 10:20:10 +0200 Message-Id: <20210705082015.18286-2-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210705082015.18286-1-johan@kernel.org> References: <20210705082015.18286-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org In the unlikely event that setting the software flow-control characters fails the other flow-control settings should still be updated (just like all other terminal settings). Move out the error message printed by the set_chars() helper to make it more obvious that this is intentional. Fixes: 7748feffcd80 ("USB: serial: cp210x: add support for software flow control") Cc: stable@vger.kernel.org # 5.11 Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 09b845d0da41..fd198031de71 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -1163,10 +1163,8 @@ static int cp210x_set_chars(struct usb_serial_port *port, kfree(dmabuf); - if (result < 0) { - dev_err(&port->dev, "failed to set special chars: %d\n", result); + if (result < 0) return result; - } return 0; } @@ -1218,8 +1216,10 @@ static void cp210x_set_flow_control(struct tty_struct *tty, chars.bXoffChar = STOP_CHAR(tty); ret = cp210x_set_chars(port, &chars); - if (ret) - return; + if (ret) { + dev_err(&port->dev, "failed to set special chars: %d\n", + ret); + } } mutex_lock(&port_priv->mutex); From patchwork Mon Jul 5 08:20: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: 470770 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=-20.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 A5A3EC07E9A for ; Mon, 5 Jul 2021 08:20:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B258613C8 for ; Mon, 5 Jul 2021 08:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbhGEIXV (ORCPT ); Mon, 5 Jul 2021 04:23:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:40884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbhGEIXR (ORCPT ); Mon, 5 Jul 2021 04:23:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D36AA6128B; Mon, 5 Jul 2021 08:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625473240; bh=mCeASRcy2as2LCxAx/EwFqOXzJ0xOLOo4eReNRoA3fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cIXLCtVohk9YXxTcnQ9aS6Rlc0uu/6rejc9Qlyz8UHxM+eHqBuoZwP0KdiIRPTtv9 ocz3Z9ckd16zl2ReRRkH5PZhgB1ZX3i5q8kc4dqAxddY9qdygMAUJW25A3PU+Q7QTa A6WHNBc8DzXBeEZL3MZq88MBfQQs7fRsh/3RJkN1o3sAxMX6TQzcbJxPnejohhjydr NcOYxIQUmz9YGSMIfzKKUymxfWFuEOqW4oAwc7W/WZaaSwgHXuwRyFEYh6vegRQFJZ Odp5DA7bExOOBUrscN4VLu48XmzynfP9SRRLeLDV8qpDjqfMDdkxp8HZ8IFqKAiTAZ 0PrVvJRPVsD+g== Received: from johan by xi with local (Exim 4.94.2) (envelope-from ) id 1m0JqF-0004lr-6z; Mon, 05 Jul 2021 10:20:35 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/6] USB: serial: cp210x: fix flow-control error handling Date: Mon, 5 Jul 2021 10:20:11 +0200 Message-Id: <20210705082015.18286-3-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210705082015.18286-1-johan@kernel.org> References: <20210705082015.18286-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Make sure that the driver crtscts state is not updated in the unlikely event that the flow-control request fails. Not doing so could break RTS control. Fixes: 5951b8508855 ("USB: serial: cp210x: suppress modem-control errors") Cc: stable@vger.kernel.org # 5.11 Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index fd198031de71..fd6bd574e2a5 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -1189,6 +1189,7 @@ static void cp210x_set_flow_control(struct tty_struct *tty, struct cp210x_flow_ctl flow_ctl; u32 flow_repl; u32 ctl_hs; + bool crtscts; int ret; /* @@ -1248,14 +1249,14 @@ static void cp210x_set_flow_control(struct tty_struct *tty, flow_repl |= CP210X_SERIAL_RTS_FLOW_CTL; else flow_repl |= CP210X_SERIAL_RTS_INACTIVE; - port_priv->crtscts = true; + crtscts = true; } else { ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE; if (port_priv->rts) flow_repl |= CP210X_SERIAL_RTS_ACTIVE; else flow_repl |= CP210X_SERIAL_RTS_INACTIVE; - port_priv->crtscts = false; + crtscts = false; } if (I_IXOFF(tty)) { @@ -1278,8 +1279,12 @@ static void cp210x_set_flow_control(struct tty_struct *tty, flow_ctl.ulControlHandshake = cpu_to_le32(ctl_hs); flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl); - cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl, + ret = cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl, sizeof(flow_ctl)); + if (ret) + goto out_unlock; + + port_priv->crtscts = crtscts; out_unlock: mutex_unlock(&port_priv->mutex); }