From patchwork Thu Jan 21 10:29: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: 368411 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.2 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 B0127C433DB for ; Thu, 21 Jan 2021 13:03:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5593D239FD for ; Thu, 21 Jan 2021 13:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731598AbhAUNDd (ORCPT ); Thu, 21 Jan 2021 08:03:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:60218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729287AbhAUKbU (ORCPT ); Thu, 21 Jan 2021 05:31:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 951CD238D7; Thu, 21 Jan 2021 10:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611224969; bh=cAZ+bdotNq2+OepIgVZlBcVcWLCXIE8JG8JDOtK1y0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNu4QWe29ncRnTTRRqNLAhTO3N5Pxq22g4ct+MhNDnCmZL0JMowzE1UQcYcThdyie GZBlcZY1XFDsUd5YDCDtmFM3eaH/grtyX/yRfa3F8x6WMwxJ5b4TG8NV0Zi3ydqIve HjnLi4Tc9yxwa7adRgPq9/CyJ0rhLGI99X8Baj8LdX7LsIaRW3g7Lpl3XcjCrLxLcx D8LupIjWZqqfTgCYCiYh4NQX12fchVCFyJg9lCyomjUA9lnJZ+WDs1sNpDDhyIERSZ cHM64ncsUdOcnNhjW+mzqLwOzVqI3SqadhcixmtGgDxcTnMh21HzV/s6uxxEF1Rl1r NT92oIqElj2QA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l2XDc-0004YR-R0; Thu, 21 Jan 2021 11:29:36 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 04/10] USB: serial: xr: use termios flag helpers Date: Thu, 21 Jan 2021 11:29:16 +0100 Message-Id: <20210121102922.17439-6-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121102922.17439-1-johan@kernel.org> References: <20210121102922.17439-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the termios flag helpers consistently, including for CRTSCTS. Signed-off-by: Johan Hovold --- drivers/usb/serial/xr_serial.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index 8f81f866d681..52909dccb4dc 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -401,7 +401,6 @@ static int xr_set_baudrate(struct tty_struct *tty, static void xr_set_flow_mode(struct tty_struct *tty, struct usb_serial_port *port) { - unsigned int cflag = tty->termios.c_cflag; u8 flow, gpio_mode; int ret; @@ -409,7 +408,7 @@ static void xr_set_flow_mode(struct tty_struct *tty, if (ret) return; - if (cflag & CRTSCTS) { + if (C_CRTSCTS(tty)) { dev_dbg(&port->dev, "Enabling hardware flow ctrl\n"); /* From patchwork Thu Jan 21 10:29: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: 368409 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.2 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 47E79C433DB for ; Thu, 21 Jan 2021 13:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D737123A00 for ; Thu, 21 Jan 2021 13:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730954AbhAUND7 (ORCPT ); Thu, 21 Jan 2021 08:03:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:59658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729441AbhAUKaK (ORCPT ); Thu, 21 Jan 2021 05:30:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B4E62343E; Thu, 21 Jan 2021 10:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611224969; bh=yZsEYFxHhExQyS17apsnmD2VNyi2e+mhEdvR9PE0M50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PEKOd7okSE0hOqSVsTuk9LeSDjr7FBeAV5S+INLLYQ7R8bdpwPuUhUyGjSou9t12X Crr4MGyXGaq7AMx9fg/v0PuKmdsQEAXAvB34jucYb5iYu/hSKSyZ24L2bd8XDpccEr B4GtBq5lxRvAIkl4/Nx3gDQRD5aID930mP7BVzk/1CoIDWMHTH3F5ZeZ5ncYfTxi7H tHyomuaTXzrg77aJAgEVgYlbbO3DZs68QaNfs8Hu7jbHDoMYu/jWJHAOjAwk44mwMY /vZOLyIcaE3UKyswCUXifiayurVjO7kLb6ibpfR53ehQwRFrelSNDGZWOxDSZjf5p4 JJxltK3lmV9tw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l2XDc-0004YU-UL; Thu, 21 Jan 2021 11:29:36 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 05/10] USB: serial: xr: document vendor-request recipient Date: Thu, 21 Jan 2021 11:29:17 +0100 Message-Id: <20210121102922.17439-7-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121102922.17439-1-johan@kernel.org> References: <20210121102922.17439-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add the missing device-recipient define to the vendor control requests for completeness. Signed-off-by: Johan Hovold --- drivers/usb/serial/xr_serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index 52909dccb4dc..202263211ba9 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -116,8 +116,8 @@ static int xr_set_reg(struct usb_serial_port *port, u8 block, u8 reg, u8 val) ret = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), XR21V141X_SET_REQ, - USB_DIR_OUT | USB_TYPE_VENDOR, val, - reg | (block << 8), NULL, 0, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + val, reg | (block << 8), NULL, 0, USB_CTRL_SET_TIMEOUT); if (ret < 0) { dev_err(&port->dev, "Failed to set reg 0x%02x: %d\n", reg, ret); @@ -140,8 +140,8 @@ static int xr_get_reg(struct usb_serial_port *port, u8 block, u8 reg, u8 *val) ret = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), XR21V141X_GET_REQ, - USB_DIR_IN | USB_TYPE_VENDOR, 0, - reg | (block << 8), dmabuf, 1, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0, reg | (block << 8), dmabuf, 1, USB_CTRL_GET_TIMEOUT); if (ret == 1) { *val = *dmabuf; From patchwork Thu Jan 21 10:29: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: 368414 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.2 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 33416C433DB for ; Thu, 21 Jan 2021 12:58:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9444B239FD for ; Thu, 21 Jan 2021 12:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729266AbhAUKbb (ORCPT ); Thu, 21 Jan 2021 05:31:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:60222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729273AbhAUKbU (ORCPT ); Thu, 21 Jan 2021 05:31:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B89ED238EE; Thu, 21 Jan 2021 10:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611224969; bh=E3rqOhlNjsoj1qD6go+1xdGHgfZsx2+E9ZgBMrIJGPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCHPjIgRidSetEiDc/rT5Ghl1rwpxwhraSA2gf7FL8ZILU3DCyF+dffdL10fZg+Lj n1AV7tutGE05vSTha7KYM3Nivlu/ZC/3oWAl3IhcSrRiDssMlnBtPTXXhbGH/95KL0 Wu2Brx46b3KGRom5yCT7zhEZ9SAiYiNpN75qfMKPmy+A/eq12BPrkbvhd1Hdi+9hkV CzqSnkYeL7N5849hKFLbNzU2CVV78CiDnN9+mqkQRKB3lRWSlKGH5JblMYSZdM+mlJ u+qCtJqxHlz3YWwm4dehjrDmOVZB6xrwv3ipl+F/oPFDrDZMP0D9Uxg87C/YA9k2KB nz2zD5fiwkkoQ== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l2XDd-0004Ya-5B; Thu, 21 Jan 2021 11:29:37 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 07/10] USB: serial: xr: simplify line-speed logic Date: Thu, 21 Jan 2021 11:29:19 +0100 Message-Id: <20210121102922.17439-9-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121102922.17439-1-johan@kernel.org> References: <20210121102922.17439-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Simplify the changed-line-speed conditional expression. Signed-off-by: Johan Hovold --- drivers/usb/serial/xr_serial.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index 2000277bacc1..fc727f4283f2 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -451,8 +451,7 @@ static void xr_set_termios(struct tty_struct *tty, u8 bits = 0; int ret; - if ((old_termios && tty->termios.c_ospeed != old_termios->c_ospeed) || - !old_termios) + if (!old_termios || (tty->termios.c_ospeed != old_termios->c_ospeed)) xr_set_baudrate(tty, port); switch (C_CSIZE(tty)) { From patchwork Thu Jan 21 10:29: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: 368410 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.2 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 C2C57C433DB for ; Thu, 21 Jan 2021 13:03:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EA1E239FD for ; Thu, 21 Jan 2021 13:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731614AbhAUNDj (ORCPT ); Thu, 21 Jan 2021 08:03:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:60230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729297AbhAUKbU (ORCPT ); Thu, 21 Jan 2021 05:31:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6B7C239E7; Thu, 21 Jan 2021 10:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611224970; bh=LB7JmBqWiGACFdERW0/yScBVALQ/zUAt6uErRz6Q0Pc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QbvEIKNKDcVf2nhJ8r5xynsebn/9kNQ84p1/eJlBNBd5yZCJzqHAlYFD9U6BMQ122 EWyQx/nb1IxRdaGrOdEHJ9OK7zBpVNO1aua/YsaD8pfNs00qEv3tyU2oa3NXnaF0n3 To9n6l6JKHAP1REIMo0mZ+/ALfDX0MciawSfbQaPjzhhh/VOMtXrWItU0jr9TXFWrJ MzqhTQP/fbHrRmd/bKG8+3+M9LcY/6nUE4NzeQ73QeQ2xe9yJW08BZ6DZJG/A+lDe4 QU2csgJJEqGYO8jls2EEvQTWYvHAqJkb1m8UAlgcDtqH1NjvhFmt4+BORtrZ+r621D pBR051hjMS98Q== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l2XDd-0004Yd-8U; Thu, 21 Jan 2021 11:29:37 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 08/10] USB: serial: xr: fix gpio-mode handling Date: Thu, 21 Jan 2021 11:29:20 +0100 Message-Id: <20210121102922.17439-10-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121102922.17439-1-johan@kernel.org> References: <20210121102922.17439-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Fix the gpio-mode handling so that all the pins are under driver control (i.e. in gpio mode) when hardware flow control is disabled. This is specifically needed to be able to control RTS. Fixes: a8f54b7bd132 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/xr_serial.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index fc727f4283f2..183731cd2ef7 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -408,14 +408,11 @@ static void xr_set_flow_mode(struct tty_struct *tty, if (ret) return; + /* Set GPIO mode for controlling the pins manually by default. */ + gpio_mode &= ~XR21V141X_UART_MODE_GPIO_MASK; + if (C_CRTSCTS(tty)) { dev_dbg(&port->dev, "Enabling hardware flow ctrl\n"); - - /* - * RTS/CTS is the default flow control mode, so set GPIO mode - * for controlling the pins manually by default. - */ - gpio_mode &= ~XR21V141X_UART_MODE_GPIO_MASK; gpio_mode |= XR21V141X_UART_MODE_RTS_CTS; flow = XR21V141X_UART_FLOW_MODE_HW; } else if (I_IXON(tty)) { From patchwork Thu Jan 21 10:29: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: 368408 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.2 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 899BEC433E0 for ; Thu, 21 Jan 2021 13:17:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A2E023A01 for ; Thu, 21 Jan 2021 13:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731491AbhAUND0 (ORCPT ); Thu, 21 Jan 2021 08:03:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:60228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729294AbhAUKbU (ORCPT ); Thu, 21 Jan 2021 05:31:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E3562239EB; Thu, 21 Jan 2021 10:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611224970; bh=v5TgOwXWj0YY94HrnCt3iZPfS8p5FlPm3RviRv/L0ME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKY1pyJ5iW32eEeBPWbGWV4NQzWsqnbFjXsBeshkGsrUCN1s35y819qTxGvcME6H1 F20FMpcEU8JHAJjwQQXXrFj4HHLcDFTp40F+nr/aW6KNm8AhgESBChwxTKwlgtcnPx athTudEMfwVgz0ygLTzGDk5PDX0SvHjpmTiSSP9rTaHE6a+otvPpZRWWz3+QcV4Kfr frVdJD5r193stCExKb2PXyhSA5N6qwb7HtQdKmVoGUCIROHBxsBr2ARmeY2J46cGMl eUeeoO85RR2s8pPvQ3G22lXcMBRuozk+1mghQOybuSFMELPAzM01Uf7oT6MyFyUXUi AvGHeHZW6TAqw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l2XDd-0004Yj-Fe; Thu, 21 Jan 2021 11:29:37 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 10/10] USB: serial: xr: fix B0 handling Date: Thu, 21 Jan 2021 11:29:22 +0100 Message-Id: <20210121102922.17439-12-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121102922.17439-1-johan@kernel.org> References: <20210121102922.17439-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Fix up B0 handling which should leave the baud rate unchanged and specifically not report back a non-B0 rate when B0 is requested; must temporarily disable hardware flow control so that RTS can be deasserted; and should reassert DTR/RTS when moving from B0. Fixes: a8f54b7bd132 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/xr_serial.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index f67e7dba9509..483d07dee19d 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -341,8 +341,11 @@ static int xr_set_baudrate(struct tty_struct *tty, u16 tx_mask, rx_mask; int ret; - baud = clamp(tty->termios.c_ospeed, XR21V141X_MIN_SPEED, - XR21V141X_MAX_SPEED); + baud = tty->termios.c_ospeed; + if (!baud) + return 0; + + baud = clamp(baud, XR21V141X_MIN_SPEED, XR21V141X_MAX_SPEED); divisor = XR_INT_OSC_HZ / baud; idx = ((32 * XR_INT_OSC_HZ) / baud) & 0x1f; tx_mask = xr21v141x_txrx_clk_masks[idx].tx; @@ -399,7 +402,8 @@ static int xr_set_baudrate(struct tty_struct *tty, } static void xr_set_flow_mode(struct tty_struct *tty, - struct usb_serial_port *port) + struct usb_serial_port *port, + struct ktermios *old_termios) { u8 flow, gpio_mode; int ret; @@ -411,7 +415,7 @@ static void xr_set_flow_mode(struct tty_struct *tty, /* Set GPIO mode for controlling the pins manually by default. */ gpio_mode &= ~XR21V141X_UART_MODE_GPIO_MASK; - if (C_CRTSCTS(tty)) { + if (C_CRTSCTS(tty) && C_BAUD(tty) != B0) { dev_dbg(&port->dev, "Enabling hardware flow ctrl\n"); gpio_mode |= XR21V141X_UART_MODE_RTS_CTS; flow = XR21V141X_UART_FLOW_MODE_HW; @@ -438,6 +442,11 @@ static void xr_set_flow_mode(struct tty_struct *tty, xr_uart_enable(port); xr_set_reg_uart(port, XR21V141X_REG_GPIO_MODE, gpio_mode); + + if (C_BAUD(tty) == B0) + xr_dtr_rts(port, 0); + else if (old_termios && (old_termios->c_cflag & CBAUD) == B0) + xr_dtr_rts(port, 1); } static void xr_set_termios(struct tty_struct *tty, @@ -493,11 +502,7 @@ static void xr_set_termios(struct tty_struct *tty, if (ret) return; - /* If baud rate is B0, clear DTR and RTS */ - if (C_BAUD(tty) == B0) - xr_dtr_rts(port, 0); - - xr_set_flow_mode(tty, port); + xr_set_flow_mode(tty, port, old_termios); } static int xr_open(struct tty_struct *tty, struct usb_serial_port *port)