From patchwork Tue Apr 2 08:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10881229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DA5117E1 for ; Tue, 2 Apr 2019 08:19:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFFEA28793 for ; Tue, 2 Apr 2019 08:19:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4545287D3; Tue, 2 Apr 2019 08:19:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DF0328793 for ; Tue, 2 Apr 2019 08:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729366AbfDBIT2 (ORCPT ); Tue, 2 Apr 2019 04:19:28 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46597 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfDBIT2 (ORCPT ); Tue, 2 Apr 2019 04:19:28 -0400 Received: by mail-lj1-f193.google.com with SMTP id h21so10682265ljk.13 for ; Tue, 02 Apr 2019 01:19:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x1VXnEXEjl8bkILD6Hh3xXYfN2hyl5JeyjdFfU1Ecpw=; b=t6kk0YXm1JfVfZqOh51jSll/QPm0bu3GDFqsiZ7klWy7daHbBGy9c3Ms0kPxmCAGah SIAFWDBkaAwU3ry+CmeaNE/UUgnEc6dt/60kA1ZfGvzD1+p+sj7L1uq72M6y8iAvAflO T8fCCTY/lKSPtD/z0FfIL29q85YMBg30Nq3MzvHGa63ab+TPuDP2oq3yDUd3Y68vPLwX 73Cmk2YXlwfRK/h/Ip3obwjbQhntUYWzd6UN2WnWIYz08H1/61gRWE0TlAC+vj+lNJxx y+5y8WjRKs3dRB/ETu0cbxBoJvufzl9cPQzIE9kb9GyQtGFBnQZhPWq75kREGhtZPWmZ VrWw== X-Gm-Message-State: APjAAAVm7GEPsSIfx9lHNNfRK6YH89qiC2M70t97ADzNgI+LvLurWDJv h3UXMpo2KT8yo4wMDuH3M2/4BD1W X-Google-Smtp-Source: APXvYqx/GLCV9EaskiUrNwU10YWgmgpxdjyKK35hUCLBd5OsrHTLvy33APc9ueWs4qd4Rh1ShdKWbw== X-Received: by 2002:a2e:7311:: with SMTP id o17mr28965850ljc.124.1554193166046; Tue, 02 Apr 2019 01:19:26 -0700 (PDT) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id m1sm2332347lfk.84.2019.04.02.01.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 01:19:24 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1hBEdz-0007SQ-Sr; Tue, 02 Apr 2019 10:19:43 +0200 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Florian Zumbiehl , Charles Yeh , Johan Hovold Subject: [PATCH 1/2] USB: serial: pl2303: fix non-supported xon/xoff Date: Tue, 2 Apr 2019 10:19:30 +0200 Message-Id: <20190402081931.28621-2-johan@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190402081931.28621-1-johan@kernel.org> References: <20190402081931.28621-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Older pl2303 devices do not support automatic xon/xoff flow control, so add add a flag to prevent trying to enable it for legacy device types. Refactor the IXON test into a helper function to improve readability. Fixes: 7041d9c3f01b ("USB: serial: pl2303: add support for tx xon/xoff flow control") Signed-off-by: Johan Hovold Reviewed-by: Greg Kroah-Hartman --- drivers/usb/serial/pl2303.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index bb3f9aa4a909..e7ccd06df802 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -156,6 +156,7 @@ enum pl2303_type { struct pl2303_type_data { speed_t max_baud_rate; unsigned long quirks; + unsigned int no_autoxonxoff:1; }; struct pl2303_serial_private { @@ -173,11 +174,12 @@ struct pl2303_private { static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = { [TYPE_01] = { - .max_baud_rate = 1228800, - .quirks = PL2303_QUIRK_LEGACY, + .max_baud_rate = 1228800, + .quirks = PL2303_QUIRK_LEGACY, + .no_autoxonxoff = 1, }, [TYPE_HX] = { - .max_baud_rate = 12000000, + .max_baud_rate = 12000000, }, }; @@ -552,6 +554,20 @@ static bool pl2303_termios_change(const struct ktermios *a, const struct ktermio return tty_termios_hw_change(a, b) || ixon_change; } +static bool pl2303_enable_xonxoff(struct tty_struct *tty, const struct pl2303_type_data *type) +{ + if (!I_IXON(tty) || I_IXANY(tty)) + return false; + + if (START_CHAR(tty) != 0x11 || STOP_CHAR(tty) != 0x13) + return false; + + if (type->no_autoxonxoff) + return false; + + return true; +} + static void pl2303_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { @@ -681,8 +697,7 @@ static void pl2303_set_termios(struct tty_struct *tty, pl2303_vendor_write(serial, 0x0, 0x41); else pl2303_vendor_write(serial, 0x0, 0x61); - } else if (I_IXON(tty) && !I_IXANY(tty) && START_CHAR(tty) == 0x11 && - STOP_CHAR(tty) == 0x13) { + } else if (pl2303_enable_xonxoff(tty, spriv->type)) { pl2303_vendor_write(serial, 0x0, 0xc0); } else { pl2303_vendor_write(serial, 0x0, 0x0);