From patchwork Tue Apr 2 08:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10881231 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 8025018E8 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 6F22128793 for ; Tue, 2 Apr 2019 08:19:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 636D8287CC; Tue, 2 Apr 2019 08:19:30 +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 059A7287DC for ; Tue, 2 Apr 2019 08:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729415AbfDBIT3 (ORCPT ); Tue, 2 Apr 2019 04:19:29 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44921 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbfDBIT2 (ORCPT ); Tue, 2 Apr 2019 04:19:28 -0400 Received: by mail-lj1-f194.google.com with SMTP id h16so10689032ljg.11 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=Yr8HL287kKvK1+1cIsx69Z4cW0c51s/jL6O5gwr0l3o=; b=fS8BiDHBNv1H5Idkz6OUkUms3ZKUdrn5vjh8jA/C1Uqgijw6t5PMfZq3lUNO9/PmNk BkZq+0eEucMYFbcsK4DIdVyZqKHczaPahVqUw62EMiNRO/8HDfBW/+EF7XyN4cVbgFV5 74S6fYQ6UByS08K3pYkHbxQfgLvz00yweUwPzUD+WIT9ZkeH+fh5DzzIYG6yIWp4KW22 9j57IACBJXzvOCCD2xZ5QTenTOVz4C89FsU9I3TUncZ0PQoglSAd4sSJx67Ser323z+P 8oov7z7rgvQeJFnnAtXp/MFE+tgRx+tlC3edwMo9VAezHG2umed6qa66lcvMRERQ4RS/ ZVtQ== X-Gm-Message-State: APjAAAWZsTs5CPVxrXAGqFMYCJ0ECh425dIsDWDkUFMdeRb3WfQFN8l+ sB3VjHsEZ32emZw/Qf9nVwIdS1rm X-Google-Smtp-Source: APXvYqw5y/VxYjdQVCnG8NbdvdlnpUVnl7fgfY7IM+TPYgiaktLkFlLulIWXmwxr+e90m5dg4cQSjw== X-Received: by 2002:a2e:9194:: with SMTP id f20mr13338921ljg.10.1554193166541; 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 u11sm2334265lfb.17.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-0007SV-Vp; Tue, 02 Apr 2019 10:19:44 +0200 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Florian Zumbiehl , Charles Yeh , Johan Hovold Subject: [PATCH 2/2] USB: serial: pl2303: fix tranceiver suspend mode Date: Tue, 2 Apr 2019 10:19:31 +0200 Message-Id: <20190402081931.28621-3-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 Add helper function to update register bits instead of overwriting the entire control register when updating the flow-control settings. This specifically avoids having the tranceiver suspend mode (bit 0) depend on the flow control setting. The tranceiver is currently configured at probe to be disabled during suspend, but this was overridden when disabling flow control or enabling xon/xoff. Fixes: 715f9527c1c1 ("USB: flow control fix for pl2303") 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 | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index e7ccd06df802..55122ac84518 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -145,6 +145,8 @@ MODULE_DEVICE_TABLE(usb, id_table); #define UART_OVERRUN_ERROR 0x40 #define UART_CTS 0x80 +#define PL2303_FLOWCTRL_MASK 0xf0 + static void pl2303_set_break(struct usb_serial_port *port, bool enable); enum pl2303_type { @@ -176,7 +178,7 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = { [TYPE_01] = { .max_baud_rate = 1228800, .quirks = PL2303_QUIRK_LEGACY, - .no_autoxonxoff = 1, + .no_autoxonxoff = true, }, [TYPE_HX] = { .max_baud_rate = 12000000, @@ -225,6 +227,29 @@ static int pl2303_vendor_write(struct usb_serial *serial, u16 value, u16 index) return 0; } +static int pl2303_update_reg(struct usb_serial *serial, u8 reg, u8 mask, u8 val) +{ + int ret = 0; + u8 *buf; + + buf = kmalloc(1, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + ret = pl2303_vendor_read(serial, reg | 0x80, buf); + if (ret) + goto out_free; + + *buf &= ~mask; + *buf |= val & mask; + + ret = pl2303_vendor_write(serial, reg, *buf); +out_free: + kfree(buf); + + return ret; +} + static int pl2303_probe(struct usb_serial *serial, const struct usb_device_id *id) { @@ -694,13 +719,13 @@ static void pl2303_set_termios(struct tty_struct *tty, if (C_CRTSCTS(tty)) { if (spriv->quirks & PL2303_QUIRK_LEGACY) - pl2303_vendor_write(serial, 0x0, 0x41); + pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x40); else - pl2303_vendor_write(serial, 0x0, 0x61); + pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x60); } else if (pl2303_enable_xonxoff(tty, spriv->type)) { - pl2303_vendor_write(serial, 0x0, 0xc0); + pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0xc0); } else { - pl2303_vendor_write(serial, 0x0, 0x0); + pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0); } kfree(buf);