From patchwork Fri Jul 2 13:42: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: 469766 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.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 505F6C11F6C for ; Fri, 2 Jul 2021 13:42:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3856961432 for ; Fri, 2 Jul 2021 13:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232710AbhGBNp2 (ORCPT ); Fri, 2 Jul 2021 09:45:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:48676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbhGBNp0 (ORCPT ); Fri, 2 Jul 2021 09:45:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 876596142D; Fri, 2 Jul 2021 13:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625233374; bh=AYm6WKJ+TZhob2+LiBgKZ9p9qBKekXiMOR4Tkn4xqR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hfRcUan9HIWQnCRbQW6o7dChLwSYizd5MAAq9MGrpU1eDowsrTJI7zopZaWb5y44T LA98G8R0M/ypkvnNQHu/ek8g16hH+C+OPE9jowF/S19LN05YMEwbCvfJuElOlswRnO 5aW0TaQLJyrgzzsYDP/ppsFwu+Qe88ZD6/jCobauRM70uM+3WYrtNlyHaJl0oo5QfF 1/1MszHxz0UWkos5UUl6DYJWVh2g34w7oOzZG1wjouxvmpvRRXLCGmRlCIB9VbTKyq QtPJSB+5w7cm92DJAfPQTakg0Pv6w+2NLeuoxZonO2AYD1pm3+2FheQvGsbIe12XWO t2HtYAtacVdFw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1lzJRS-0006Q2-WD; Fri, 02 Jul 2021 15:42:51 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/6] USB: serial: cp210x: fix control-characters error handling Date: Fri, 2 Jul 2021 15:42:22 +0200 Message-Id: <20210702134227.24621-2-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702134227.24621-1-johan@kernel.org> References: <20210702134227.24621-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org In the unlikely event that setting the software flow-control characters fails the other flow-control settings should still be updated. 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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 09b845d0da41..b41e2c7649fb 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -1217,9 +1217,7 @@ static void cp210x_set_flow_control(struct tty_struct *tty, chars.bXonChar = START_CHAR(tty); chars.bXoffChar = STOP_CHAR(tty); - ret = cp210x_set_chars(port, &chars); - if (ret) - return; + cp210x_set_chars(port, &chars); } mutex_lock(&port_priv->mutex); From patchwork Fri Jul 2 13:42:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 469763 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.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 48D18C11F73 for ; Fri, 2 Jul 2021 13:43:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BD97613CE for ; Fri, 2 Jul 2021 13:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbhGBNqC (ORCPT ); Fri, 2 Jul 2021 09:46:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:48824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbhGBNp2 (ORCPT ); Fri, 2 Jul 2021 09:45:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E3626142B; Fri, 2 Jul 2021 13:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625233376; bh=YE/LCnkMIv6fwH7bk4ME2EQ7qcy5Vj5/29RRN5K4+ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jb1l3cakLEMvw7JpHXk4ANbsjYL2PcNp+wG6HalxrKxauY5FEJh7faOMGSA+UHerK iN2y96J6BxeiuKatGhCcvcq/3MaXALcE/qwRWzpITOMkBWArgFIU+cEmeOmh1v8Qt3 aOGItxamv2ZdI6+4OtMHFqwEgOoMT7bXrwsy1pUN+nO3Zj2IBaYc+X9/CFV5ecYvfn dk0BqGXCRBEbaHmhQ1+K/wpz88bJzorMlUDcRV3M0rDpObxSkWEsZ36DcQug09dDtO A/u31QN7mQDjRscgUN9GLRoZgUqncNDnrWVBesLKDah648/mvpMZdXqfV8F3ZDjfzg ZpGydTmHTJi+Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1lzJRT-0006Q7-5j; Fri, 02 Jul 2021 15:42:51 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] USB: serial: cp210x: clean up control-request timeout Date: Fri, 2 Jul 2021 15:42:24 +0200 Message-Id: <20210702134227.24621-4-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702134227.24621-1-johan@kernel.org> References: <20210702134227.24621-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For consistency use the USB_CTRL_GET_TIMEOUT define for the read-register request timeout (same value as USB_CTRL_SET_TIMEOUT). Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index eb3be4f65603..c7cea86c659c 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -637,7 +637,7 @@ static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req, result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), req, REQTYPE_INTERFACE_TO_HOST, 0, port_priv->bInterfaceNumber, dmabuf, bufsize, - USB_CTRL_SET_TIMEOUT); + USB_CTRL_GET_TIMEOUT); if (result == bufsize) { memcpy(buf, dmabuf, bufsize); result = 0; From patchwork Fri Jul 2 13:42:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 469764 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.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 22004C11F6C for ; Fri, 2 Jul 2021 13:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 088A6613CE for ; Fri, 2 Jul 2021 13:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232839AbhGBNqA (ORCPT ); Fri, 2 Jul 2021 09:46:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:48828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232719AbhGBNp2 (ORCPT ); Fri, 2 Jul 2021 09:45:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9342D61439; Fri, 2 Jul 2021 13:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625233376; bh=j0sAISF6TrBQtWd6KwNA6oEpI+hi30rZzbLkvV/VyfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DaIXhci4yXdsTZEoExhJxWrn6fMvIla8KC26KGtmV8V58K56JABVBE6kR/5M7gI/B 9XNgJdF1mZ5IK1aFBKUwIsyjVRHw5xy1+H0cPUHvu55O31vYaW8bq/N7bysi98403z rciqSt/HwLC+uFG1oEOoZU7cExV3nvOJdViUY3rIgA+6Neg0PL1opPp6bD7Eqxlscb JMiPDxq8Hzy7VfqFujARoMrlccSklECURrTmjwib8N/I5gJuarRDE6gJvNbo9BzRHm Yrd8xkd8dRKP/Gc8j80t9+sC+ljQCr/cvMyxIl0U5qqLfm330wVt6pEbQr9/qmMvyr pc2/GmDDUnY+Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1lzJRT-0006QA-7s; Fri, 02 Jul 2021 15:42:51 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] USB: serial: cp210x: clean up set-chars request Date: Fri, 2 Jul 2021 15:42:25 +0200 Message-Id: <20210702134227.24621-5-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702134227.24621-1-johan@kernel.org> References: <20210702134227.24621-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the generic control request helper to implement the SET_CHARS request. Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index c7cea86c659c..4c51381cf9aa 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -1144,33 +1144,6 @@ static void cp210x_disable_event_mode(struct usb_serial_port *port) port_priv->event_mode = false; } -static int cp210x_set_chars(struct usb_serial_port *port, - struct cp210x_special_chars *chars) -{ - struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); - struct usb_serial *serial = port->serial; - void *dmabuf; - int result; - - dmabuf = kmemdup(chars, sizeof(*chars), GFP_KERNEL); - if (!dmabuf) - return -ENOMEM; - - result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - CP210X_SET_CHARS, REQTYPE_HOST_TO_INTERFACE, 0, - port_priv->bInterfaceNumber, - dmabuf, sizeof(*chars), USB_CTRL_SET_TIMEOUT); - - kfree(dmabuf); - - if (result < 0) { - dev_err(&port->dev, "failed to set special chars: %d\n", result); - return result; - } - - return 0; -} - static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b) { bool iflag_change, cc_change; @@ -1218,7 +1191,8 @@ static void cp210x_set_flow_control(struct tty_struct *tty, chars.bXonChar = START_CHAR(tty); chars.bXoffChar = STOP_CHAR(tty); - cp210x_set_chars(port, &chars); + cp210x_write_reg_block(port, CP210X_SET_CHARS, &chars, + sizeof(chars)); } mutex_lock(&port_priv->mutex); From patchwork Fri Jul 2 13:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 469765 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.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 41E9FC11F68 for ; Fri, 2 Jul 2021 13:42:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30D6B613CE for ; Fri, 2 Jul 2021 13:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232730AbhGBNp3 (ORCPT ); Fri, 2 Jul 2021 09:45:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:48822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232714AbhGBNp2 (ORCPT ); Fri, 2 Jul 2021 09:45:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8ED306142C; Fri, 2 Jul 2021 13:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625233376; bh=iQ511ti6tPKWj9+Fpr2R4MwXkxW+DRti6nYPHc/VfnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hJrROcYyJBc/V9bdA4lRLf5PAh6VGY6cP/rxMpe0lJy32mBWVKnZsPZyDqxaGR5mS knrn9+2pYfVRsUyxGCokMIkRbWJwtFwkc1nGYE8U904yUQCxv7rd+6It3KmpIcCtn2 LZ5My1NvIAXgXtBJf8oidsjG3v1J5UYEBShvQVcNTmAU+nw+mM0i7FyLGFZULqJFgL 3MTYnpKGaN7d5Dge+GRV+7z4gxtKmet3OdIWqI6GO5KAl6O3+iPMKKNOcltjJ/ByJN 5kJbPiaSC50QzzdrrsbvnSYGd0hrtLXZQxrze6sqSuzttl70OiqCqisNDMcL4d4Yhh rquobRv8M5Uiw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1lzJRT-0006QH-Cv; Fri, 02 Jul 2021 15:42:51 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] USB: serial: cp210x: determine fw version for CP2105 and CP2108 Date: Fri, 2 Jul 2021 15:42:27 +0200 Message-Id: <20210702134227.24621-7-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702134227.24621-1-johan@kernel.org> References: <20210702134227.24621-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org CP2105, CP2108 and CP2102N have vendor requests that can be used to retrieve the firmware version. Having this information available is essential when trying to work around buggy firmware as a recent CP2102N regression showed. Determine and log the firmware version also for CP2105 and CP2108 during type detection at probe. Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 0f4cdba160d9..7908e336f962 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -399,6 +399,7 @@ struct cp210x_special_chars { }; /* CP210X_VENDOR_SPECIFIC values */ +#define CP210X_GET_FW_VER 0x000E #define CP210X_READ_2NCONFIG 0x000E #define CP210X_GET_FW_VER_2N 0x0010 #define CP210X_READ_LATCH 0x00C2 @@ -2103,6 +2104,10 @@ static void cp210x_determine_type(struct usb_serial *serial) } switch (priv->partnum) { + case CP210X_PARTNUM_CP2105: + case CP210X_PARTNUM_CP2108: + cp210x_get_fw_version(serial, CP210X_GET_FW_VER); + break; case CP210X_PARTNUM_CP2102N_QFN28: case CP210X_PARTNUM_CP2102N_QFN24: case CP210X_PARTNUM_CP2102N_QFN20: