Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp873790rwb; Tue, 29 Nov 2022 06:27:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4xo044rBzqBsVnLwQhtMfp06cHFS5obfHwv9ylQIFhH/YlrpetFafuir00oew8tedl94Re X-Received: by 2002:a17:902:8601:b0:189:7372:144c with SMTP id f1-20020a170902860100b001897372144cmr17877042plo.106.1669732025005; Tue, 29 Nov 2022 06:27:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669732025; cv=none; d=google.com; s=arc-20160816; b=ATP9s6x8WDm6vUomCObDY0LiJ5vggqWvN7hdWZpfzl7iOXVsHTK+NKJmwdA7bcnpFr JrIlvcaHnWXiGk4s/XmlwT0Endw6w8Mkmlx36y5O0jaKgA6M65vqAnFfNa4yz0AkK06b nhVXWQMVGo/f3qkjFiFkeX3TjzIgXGnttZ6KhZFV6nnVcH45RdvsXafP8h//Qr/lgvCG Ao3Z/OHnjhUUU6jmovOMvP4a5PCfb6OyrMWVlejooUp9XG3sRbmMEiYuHdkMpSsKzX1P eyJOR7a6aB8zq+ZH7Y8pxPgSbgVhXThNju8Hn0fgO/ppzpUJI1Jg1QzDzozI3d553c4Z LK/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=L//4mRUPJM4U4ZY3Uhf5UMcB+UA7YoEuVQmzbSFoMDE=; b=e2TugqJ5TP2fXniGTmpUU2R/JrjvlMwekH7j4IzuocHvEyS4yOdIJf32JOTfimjKnq whjaJ2nWWpmCo+xgWi2aCDAWllRdZleBaKmc60RqpsMLOwUPWLGtEIkczi00S41YVE6L wlKAGJXRScGqOWz/qHk3d8ITcgfRlIfN/te5PAGGKUtTywDsv+Hxk0PwG0FzSNf8H35B t4svUzlwf7A0lz1X96yASLdETzgvKabav4/E02PGcEUgTB7D0WZ9yYxGFhwg35XTo8g7 DtV6vL2lcV81lwLnVlmbZn5NpAykoIjH74lzLLCwCj+V5NQ0I8mLp+X765AX+rFspIOy 8cpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dhm8KHFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a170902a71200b0017840d9d42esi10026771plq.582.2022.11.29.06.26.50; Tue, 29 Nov 2022 06:27:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dhm8KHFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbiK2OTq (ORCPT + 85 others); Tue, 29 Nov 2022 09:19:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235228AbiK2OTU (ORCPT ); Tue, 29 Nov 2022 09:19:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B3064A14; Tue, 29 Nov 2022 06:16:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 87DF36175D; Tue, 29 Nov 2022 14:16:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF6D1C433C1; Tue, 29 Nov 2022 14:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669731377; bh=wJYMqQkpPj53vh5G04dC9dsU41D7ACPHJwuQY6nmZ/4=; h=From:To:Cc:Subject:Date:From; b=dhm8KHFCw3QIMflr1nxPDMhvWwb8g2gbM3uVz+oJL4RUgqfTeX7UCL26l+OkNzXpu 5gpemrr98/AVbqThALGRPomnWDNbFOfAXnvDdHHVvBhdLhNfOTtjZiX0hNh3efhGWX o9C/Zq81LdbUDL9h4JRhO8uayFGk/c6QcmcYoE/FavR6CXiAnIGYbtU3rDQ6lncnuv 3tQbvbokq+/jBKsnktihuj24VVeOFdbLZQXsey+tuVPjZhug4NPEkcLu7/0eLGUe0v ObRecdnwqXYwMNcFxusqK1yaTIo44TkQrNnNILupHCsl6wX7Kvkg9M0ePckOWuh/Qv B10DmJzx0N8AA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p01PF-0003xI-FN; Tue, 29 Nov 2022 15:16:17 +0100 From: Johan Hovold To: Johan Hovold Cc: Alex Henrie , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] USB: serial: cp210x: add support for B0 hangup Date: Tue, 29 Nov 2022 15:15:39 +0100 Message-Id: <20221129141539.15176-1-johan@kernel.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A request to set the line speed to B0 is used to hang up a modem connection by deasserting the modem control lines. Note that there is no need reconfigure the line speed in hardware when B0 is requested (even if some drivers do set it to an arbitrary value for implementation or protocol reasons). Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index f6fb23620e87..67372acc2352 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -1049,11 +1049,12 @@ static void cp210x_change_speed(struct tty_struct *tty, struct cp210x_serial_private *priv = usb_get_serial_data(serial); u32 baud; + if (tty->termios.c_ospeed == 0) + return; + /* * This maps the requested rate to the actual rate, a valid rate on * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed]. - * - * NOTE: B0 is not implemented. */ baud = clamp(tty->termios.c_ospeed, priv->min_speed, priv->max_speed); @@ -1146,7 +1147,8 @@ static void cp210x_set_flow_control(struct tty_struct *tty, tty->termios.c_iflag &= ~(IXON | IXOFF); } - if (old_termios && + if (tty->termios.c_ospeed != 0 && + old_termios && old_termios->c_ospeed != 0 && C_CRTSCTS(tty) == (old_termios->c_cflag & CRTSCTS) && I_IXON(tty) == (old_termios->c_iflag & IXON) && I_IXOFF(tty) == (old_termios->c_iflag & IXOFF) && @@ -1171,6 +1173,14 @@ static void cp210x_set_flow_control(struct tty_struct *tty, mutex_lock(&port_priv->mutex); + if (tty->termios.c_ospeed == 0) { + port_priv->dtr = false; + port_priv->rts = false; + } else if (old_termios && old_termios->c_ospeed == 0) { + port_priv->dtr = true; + port_priv->rts = true; + } + ret = cp210x_read_reg_block(port, CP210X_GET_FLOW, &flow_ctl, sizeof(flow_ctl)); if (ret) @@ -1243,7 +1253,8 @@ static void cp210x_set_termios(struct tty_struct *tty, u16 bits; int ret; - if (old_termios && !cp210x_termios_change(&tty->termios, old_termios)) + if (old_termios && !cp210x_termios_change(&tty->termios, old_termios) && + tty->termios.c_ospeed != 0) return; if (!old_termios || tty->termios.c_ospeed != old_termios->c_ospeed) -- 2.37.4