From patchwork Mon Jul 25 07:58:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F12FC433EF for ; Mon, 25 Jul 2022 08:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232905AbiGYIAH (ORCPT ); Mon, 25 Jul 2022 04:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbiGYIAE (ORCPT ); Mon, 25 Jul 2022 04:00:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CDCD13D10; Mon, 25 Jul 2022 01:00:03 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 40083B80DFD; Mon, 25 Jul 2022 08:00:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E47C341C6; Mon, 25 Jul 2022 08:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=foX6nf1pYS8r8PQACJBat3Wk6rDL4/p2BD6eGaKMujI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LMP6cfhgD8NZdjE0/kEUhFFzKnxpxcp402c3tWetzjeP7OsuvvqjcpWe1ja5i4w6z ELMl0ruvhApRJH5SZKayPsqoN+eC0Fkhx3d4DgaSjbcn02iuKFlPEcd5jIAeTWl39j EUEUbze1SjaeBkO2kIcIbzBRAvLv5fngOs+SKjqVxeTd7Hu3ZLFlo2yboceFa8OxGN zb3OZ25ESyEjSSmbbdtdOqVTtQEAx3Ed6/tNC8sN6x92KvV0dPwqO8FaOmdDP28UlM zaH3mJku1p2zocQExzUYxVUJEaw5FaDtVC39eVkNYLo4TUvUVF2EFjpR9bPe7tUeEH 35J7fQUWZuFJg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0d-0000K1-TY; Mon, 25 Jul 2022 10:00:11 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/7] USB: cdc: add control-signal defines Date: Mon, 25 Jul 2022 09:58:35 +0200 Message-Id: <20220725075841.1187-2-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add defines for the Control Signal Bitmap Values from section 6.2.14 SetControlLineState of the CDC specification version 1.1. Signed-off-by: Johan Hovold --- include/uapi/linux/usb/cdc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h index 6d61550959ef..372c81425cae 100644 --- a/include/uapi/linux/usb/cdc.h +++ b/include/uapi/linux/usb/cdc.h @@ -271,6 +271,10 @@ struct usb_cdc_line_coding { __u8 bDataBits; } __attribute__ ((packed)); +/* Control Signal Bitmap Values from 6.2.14 SetControlLineState */ +#define USB_CDC_CTRL_DTR (1 << 0) +#define USB_CDC_CTRL_RTS (1 << 1) + /* table 62; bits in multicast filter */ #define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0) #define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */ From patchwork Mon Jul 25 07:58:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF95FC43334 for ; Mon, 25 Jul 2022 08:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233079AbiGYIAM (ORCPT ); Mon, 25 Jul 2022 04:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232679AbiGYIAE (ORCPT ); Mon, 25 Jul 2022 04:00:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1AC713D11; Mon, 25 Jul 2022 01:00:03 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 53DC8B80E06; Mon, 25 Jul 2022 08:00:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE027C341C7; Mon, 25 Jul 2022 08:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=Mcc6YivlY7VsK7Pilttr0NsQ6d26btY/8h5TMOw2PWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTcdmQFFSblHtu/LzHjNKm3rcRHiKWRdZihdddxw9oTwwnBlupuck1iDCKWs4d5g0 YGM6uJvZHBJWHJeZHCmdd6K0NcKtPFAw1iCLo9gLnR/U2dv5Vh/y7qBP7lS3weLxWy 5Clbf5T0EzJLSPjt4OzU6Jn8dj4AHcU4MngcOSPrnt7O6qjt52OFW9yfVw3noHbMBu /J4w4GPSACf7GgaWXCd0zTzPo+j4u8ZqrGsBwY2cRrA6T4Yr9nrB6pbW7RdhL/qFnQ TaVjZr6n8nnPhv/CwMH8S3g9ghdQei0JpKGMtGFa3HqmYj53NA4gs3baPl4hbAyLCl 2ilRyADzegWDA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0e-0000K3-09; Mon, 25 Jul 2022 10:00:12 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/7] USB: cdc: add serial-state defines Date: Mon, 25 Jul 2022 09:58:36 +0200 Message-Id: <20220725075841.1187-3-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add defines for the serial-state bitmap values from section 6.3.5 SerialState of the CDC specification version 1.1. Note that the bTxCarrier and bRxCarrier bits have been named after their RS-232 signal equivalents DSR and DCD. Signed-off-by: Johan Hovold --- include/uapi/linux/usb/cdc.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h index 372c81425cae..78caa9bdc4ae 100644 --- a/include/uapi/linux/usb/cdc.h +++ b/include/uapi/linux/usb/cdc.h @@ -306,6 +306,15 @@ struct usb_cdc_notification { __le16 wLength; } __attribute__ ((packed)); +/* UART State Bitmap Values from 6.3.5 SerialState */ +#define USB_CDC_SERIAL_STATE_DCD (1 << 0) +#define USB_CDC_SERIAL_STATE_DSR (1 << 1) +#define USB_CDC_SERIAL_STATE_BREAK (1 << 2) +#define USB_CDC_SERIAL_STATE_RING_SIGNAL (1 << 3) +#define USB_CDC_SERIAL_STATE_FRAMING (1 << 4) +#define USB_CDC_SERIAL_STATE_PARITY (1 << 5) +#define USB_CDC_SERIAL_STATE_OVERRUN (1 << 6) + struct usb_cdc_speed_change { __le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */ __le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */ From patchwork Mon Jul 25 07:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 228F6C433EF for ; Mon, 25 Jul 2022 08:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbiGYIAO (ORCPT ); Mon, 25 Jul 2022 04:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232735AbiGYIAF (ORCPT ); Mon, 25 Jul 2022 04:00:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0A7112ADE; Mon, 25 Jul 2022 01:00:03 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 3AD54B80E01; Mon, 25 Jul 2022 08:00:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB79CC341CE; Mon, 25 Jul 2022 08:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=8uPr3usVlCsjnqLcOgTKXGdRijZxw3Cdyggomg261cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jA0Q24Ipqarxik+K0eTDUhxHG+nNXZQaTwKEZjB7KCZpvk4MhJe4xcqH2PUKB1sQh 0WUZMm6JQJ1Eq1TJ0ErWCCwQCTRNI7u0pJ/cCqOFggZQzZ/ntP4Idv5O5Jx4PxZQXw tjZ58WMFrX/qzSq9uv5I64PNYkstpXm5+q7QreiRC5q5jrWTepfqVum/AxMuhF/ldD f4eJbPoyYbtzyoQ9gaUPME+RIJ+77x1NQlT5tAPrlhcsUqIlwR5q1XxRYfmfR2FKOT XXaaLx9WvqLa96syMqn8uCDJ9i3wGON76mipX6u1mbxwF/Gp3zkMY+ddfXNcZyl8mk LPBMcDPpwSqRw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0e-0000K6-32; Mon, 25 Jul 2022 10:00:12 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 3/7] USB: cdc-acm: use CDC control-line defines Date: Mon, 25 Jul 2022 09:58:37 +0200 Message-Id: <20220725075841.1187-4-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the new CDC control-line defines. Signed-off-by: Johan Hovold --- drivers/usb/class/cdc-acm.c | 18 +++++++++--------- drivers/usb/class/cdc-acm.h | 7 ------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 9b9aea24d58c..e2d80b99e074 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -658,7 +658,7 @@ static void acm_port_dtr_rts(struct tty_port *port, int raise) int res; if (raise) - val = ACM_CTRL_DTR | ACM_CTRL_RTS; + val = USB_CDC_CTRL_DTR | USB_CDC_CTRL_RTS; else val = 0; @@ -903,8 +903,8 @@ static int acm_tty_tiocmget(struct tty_struct *tty) { struct acm *acm = tty->driver_data; - return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) | - (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) | + return (acm->ctrlout & USB_CDC_CTRL_DTR ? TIOCM_DTR : 0) | + (acm->ctrlout & USB_CDC_CTRL_RTS ? TIOCM_RTS : 0) | (acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) | (acm->ctrlin & ACM_CTRL_RI ? TIOCM_RI : 0) | (acm->ctrlin & ACM_CTRL_DCD ? TIOCM_CD : 0) | @@ -918,10 +918,10 @@ static int acm_tty_tiocmset(struct tty_struct *tty, unsigned int newctrl; newctrl = acm->ctrlout; - set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | - (set & TIOCM_RTS ? ACM_CTRL_RTS : 0); - clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) | - (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0); + set = (set & TIOCM_DTR ? USB_CDC_CTRL_DTR : 0) | + (set & TIOCM_RTS ? USB_CDC_CTRL_RTS : 0); + clear = (clear & TIOCM_DTR ? USB_CDC_CTRL_DTR : 0) | + (clear & TIOCM_RTS ? USB_CDC_CTRL_RTS : 0); newctrl = (newctrl & ~clear) | set; @@ -1068,9 +1068,9 @@ static void acm_tty_set_termios(struct tty_struct *tty, if (C_BAUD(tty) == B0) { newline.dwDTERate = acm->line.dwDTERate; - newctrl &= ~ACM_CTRL_DTR; + newctrl &= ~USB_CDC_CTRL_DTR; } else if (termios_old && (termios_old->c_cflag & CBAUD) == B0) { - newctrl |= ACM_CTRL_DTR; + newctrl |= USB_CDC_CTRL_DTR; } if (newctrl != acm->ctrlout) diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index d26ecd15be60..da7e8b8aaf28 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -22,13 +22,6 @@ #define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE) -/* - * Output control lines. - */ - -#define ACM_CTRL_DTR 0x01 -#define ACM_CTRL_RTS 0x02 - /* * Input control lines and line errors. */ From patchwork Mon Jul 25 07:58:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593424 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2443C43334 for ; Mon, 25 Jul 2022 08:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233249AbiGYIAR (ORCPT ); Mon, 25 Jul 2022 04:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbiGYIAI (ORCPT ); Mon, 25 Jul 2022 04:00:08 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A5813CD2; Mon, 25 Jul 2022 01:00:05 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 3743BCE10D1; Mon, 25 Jul 2022 08:00:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ABB9C36AF2; Mon, 25 Jul 2022 08:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=nubT7YyzSn8WkHv349JLvBEMunsHi77aVjSDGDc7v1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZOfwFpp9tRdA/LNmfLQQDp+aW0/JmHKNUafl/71KHqxxsm4RSp+a+/GY1aonyzqKw 8EDErBXUyTpLFLG09yVWSLjxfZ7k20H3a5KyxcOH93W8XqIqlp928yRwtClbyhDVLv qUFukJUpnMcod7GF3/tTqlVtpiOI46nnJrfhHQDmZeqXWnuYtqqHaHlTgu3Lr+z0wV TBWcdki5F8XTYpGWXaEuhSXsqZPaUZzkvxUJfJRQTGhhzvLzH05x5L4YKONcA5dixz 3dbEBqNc9NQaPn1wB5DpAs3mjrDSYzsrqWhtOEw4DSmqFC+tpLyzDPbapmSjU2FAG2 xZnTm39J3sAPw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0e-0000K8-5x; Mon, 25 Jul 2022 10:00:12 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 4/7] USB: cdc-acm: use CDC serial-state defines Date: Mon, 25 Jul 2022 09:58:38 +0200 Message-Id: <20220725075841.1187-5-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the new CDC serial-state defines. Signed-off-by: Johan Hovold --- drivers/usb/class/cdc-acm.c | 24 ++++++++++++------------ drivers/usb/class/cdc-acm.h | 13 ------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index e2d80b99e074..352df48469b2 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -311,7 +311,7 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf) dev_dbg(&acm->control->dev, "%s - serial state: 0x%x\n", __func__, newctrl); - if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { + if (!acm->clocal && (acm->ctrlin & ~newctrl & USB_CDC_SERIAL_STATE_DCD)) { dev_dbg(&acm->control->dev, "%s - calling hangup\n", __func__); tty_port_tty_hangup(&acm->port, false); @@ -322,25 +322,25 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf) acm->ctrlin = newctrl; acm->oldcount = acm->iocount; - if (difference & ACM_CTRL_DSR) + if (difference & USB_CDC_SERIAL_STATE_DSR) acm->iocount.dsr++; - if (difference & ACM_CTRL_DCD) + if (difference & USB_CDC_SERIAL_STATE_DCD) acm->iocount.dcd++; - if (newctrl & ACM_CTRL_BRK) { + if (newctrl & USB_CDC_SERIAL_STATE_BREAK) { acm->iocount.brk++; tty_insert_flip_char(&acm->port, 0, TTY_BREAK); } - if (newctrl & ACM_CTRL_RI) + if (newctrl & USB_CDC_SERIAL_STATE_RING_SIGNAL) acm->iocount.rng++; - if (newctrl & ACM_CTRL_FRAMING) + if (newctrl & USB_CDC_SERIAL_STATE_FRAMING) acm->iocount.frame++; - if (newctrl & ACM_CTRL_PARITY) + if (newctrl & USB_CDC_SERIAL_STATE_PARITY) acm->iocount.parity++; - if (newctrl & ACM_CTRL_OVERRUN) + if (newctrl & USB_CDC_SERIAL_STATE_OVERRUN) acm->iocount.overrun++; spin_unlock_irqrestore(&acm->read_lock, flags); - if (newctrl & ACM_CTRL_BRK) + if (newctrl & USB_CDC_SERIAL_STATE_BREAK) tty_flip_buffer_push(&acm->port); if (difference) @@ -905,9 +905,9 @@ static int acm_tty_tiocmget(struct tty_struct *tty) return (acm->ctrlout & USB_CDC_CTRL_DTR ? TIOCM_DTR : 0) | (acm->ctrlout & USB_CDC_CTRL_RTS ? TIOCM_RTS : 0) | - (acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) | - (acm->ctrlin & ACM_CTRL_RI ? TIOCM_RI : 0) | - (acm->ctrlin & ACM_CTRL_DCD ? TIOCM_CD : 0) | + (acm->ctrlin & USB_CDC_SERIAL_STATE_DSR ? TIOCM_DSR : 0) | + (acm->ctrlin & USB_CDC_SERIAL_STATE_RING_SIGNAL ? TIOCM_RI : 0) | + (acm->ctrlin & USB_CDC_SERIAL_STATE_DCD ? TIOCM_CD : 0) | TIOCM_CTS; } diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index da7e8b8aaf28..759ac15631d3 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -22,19 +22,6 @@ #define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE) -/* - * Input control lines and line errors. - */ - -#define ACM_CTRL_DCD 0x01 -#define ACM_CTRL_DSR 0x02 -#define ACM_CTRL_BRK 0x04 -#define ACM_CTRL_RI 0x08 - -#define ACM_CTRL_FRAMING 0x10 -#define ACM_CTRL_PARITY 0x20 -#define ACM_CTRL_OVERRUN 0x40 - /* * Internal driver structures. */ From patchwork Mon Jul 25 07:58:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7E65CCA48D for ; Mon, 25 Jul 2022 08:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232859AbiGYIAH (ORCPT ); Mon, 25 Jul 2022 04:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232622AbiGYIAE (ORCPT ); Mon, 25 Jul 2022 04:00:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735A413CD2; Mon, 25 Jul 2022 01:00:03 -0700 (PDT) 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 04409611A8; Mon, 25 Jul 2022 08:00:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3164CC341D4; Mon, 25 Jul 2022 08:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=htGIi81EhWUDNiQ/aByjFq9q+tZ8eQTA0UOuG8tIDtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=exP5EuW8jNwWGnNiR4WGtBGzStxIKSZJbIoTDBI3PTzOl6t3QUsed9F1MZiZTJbiY VOzc5hFJrbinc+WUIGBEH2Da2ltE57J100ZWee+U6Tft/33lfxsnAx1zO95UjCCMrs ZHCKPc0UgxQ+1to3Lr6z7aEia/4PPkoYQYx9Oq5lz7L3cyWF7y+sWyu0/XdtPPTVOE 6p2Bzk/obbsUtsEw3zhAmZsRaeXA3nHluw7Qn8IxNtBS3N1eplOkWbJxyo9qCUBy2F qRkHxmPxRBgttk0u+T3Msivq3tGFfsH+qQvu6OiPwKKCvMFvYUGxj3W8tsLGPhfDuQ lKw4HZXzKyzAQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0e-0000KB-8o; Mon, 25 Jul 2022 10:00:12 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 5/7] staging: gdm724x: drop unused CDC defines Date: Mon, 25 Jul 2022 09:58:39 +0200 Message-Id: <20220725075841.1187-6-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This driver has a copy of some of the CDC defines but which are currently unused. Signed-off-by: Johan Hovold --- drivers/staging/gdm724x/gdm_tty.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 04df6f9f5403..cc6d80554c98 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -17,12 +17,6 @@ #define GDM_TTY_MAJOR 0 #define GDM_TTY_MINOR 32 -#define ACM_CTRL_DTR 0x01 -#define ACM_CTRL_RTS 0x02 -#define ACM_CTRL_DSR 0x02 -#define ACM_CTRL_RI 0x08 -#define ACM_CTRL_DCD 0x01 - #define WRITE_SIZE 2048 #define MUX_TX_MAX_SIZE 2048 From patchwork Mon Jul 25 07:58:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03E76C433EF for ; Mon, 25 Jul 2022 08:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233087AbiGYIAN (ORCPT ); Mon, 25 Jul 2022 04:00:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232738AbiGYIAF (ORCPT ); Mon, 25 Jul 2022 04:00:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEEF913D16; Mon, 25 Jul 2022 01:00:03 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 78A7FB80E03; Mon, 25 Jul 2022 08:00:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31690C385A5; Mon, 25 Jul 2022 08:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=Sai1lNpDE0Gu+p7BvQNkHpZkKEh/wcOyz6NHIZZokP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9iOoMIJExdRig6gVkcyXV4CIb7Rc4iGUCPDI4Rjx18UuRHM1FCdiNZcZxIswUHFE pY+I4/7BW2Z8g9XkRaLYLIDjWZFSMpC8eC6kqIkvtDZW7RVN9ci2EWq/mD0R9wZ+s2 vu6HQRGgSjoBsfU7tYZH+jLAsDCxsJk1O4YK0tm+SMcA1TKrRQ94j4KX4MSbdHLrhJ WmPn6jUF9plVb1Q+3eG6QyUM6wuV6yR4P3mwIWXg832G4cBTuBy8BG9lfczBx12mPJ A5N0n9qpuOSfkiOKGXHj/Cw04NArk9M0VEDsrZghNnv6sVd0R0kV2IixGM3QeE/fCC t55U5z5KFfTtQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0e-0000KE-Bi; Mon, 25 Jul 2022 10:00:12 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 6/7] USB: gadget: f_acm: use CDC defines Date: Mon, 25 Jul 2022 09:58:40 +0200 Message-Id: <20220725075841.1187-7-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the new CDC control-line and serial-state defines. Signed-off-by: Johan Hovold --- drivers/usb/gadget/function/f_acm.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index 411eb489e0ff..cb523f118f04 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c @@ -57,18 +57,8 @@ struct f_acm { /* SetControlLineState request -- CDC 1.1 section 6.2.14 (INPUT) */ u16 port_handshake_bits; -#define ACM_CTRL_RTS (1 << 1) /* unused with full duplex */ -#define ACM_CTRL_DTR (1 << 0) /* host is ready for data r/w */ - /* SerialState notification -- CDC 1.1 section 6.3.5 (OUTPUT) */ u16 serial_state; -#define ACM_CTRL_OVERRUN (1 << 6) -#define ACM_CTRL_PARITY (1 << 5) -#define ACM_CTRL_FRAMING (1 << 4) -#define ACM_CTRL_RI (1 << 3) -#define ACM_CTRL_BRK (1 << 2) -#define ACM_CTRL_DSR (1 << 1) -#define ACM_CTRL_DCD (1 << 0) }; static inline struct f_acm *func_to_acm(struct usb_function *f) @@ -387,7 +377,7 @@ static int acm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) value = 0; /* FIXME we should not allow data to flow until the - * host sets the ACM_CTRL_DTR bit; and when it clears + * host sets the USB_CDC_CTRL_DTR bit; and when it clears * that bit, we should return to that no-flow state. */ acm->port_handshake_bits = w_value; @@ -585,7 +575,7 @@ static void acm_connect(struct gserial *port) { struct f_acm *acm = port_to_acm(port); - acm->serial_state |= ACM_CTRL_DSR | ACM_CTRL_DCD; + acm->serial_state |= USB_CDC_SERIAL_STATE_DSR | USB_CDC_SERIAL_STATE_DCD; acm_notify_serial_state(acm); } @@ -593,7 +583,7 @@ static void acm_disconnect(struct gserial *port) { struct f_acm *acm = port_to_acm(port); - acm->serial_state &= ~(ACM_CTRL_DSR | ACM_CTRL_DCD); + acm->serial_state &= ~(USB_CDC_SERIAL_STATE_DSR | USB_CDC_SERIAL_STATE_DCD); acm_notify_serial_state(acm); } @@ -603,9 +593,9 @@ static int acm_send_break(struct gserial *port, int duration) u16 state; state = acm->serial_state; - state &= ~ACM_CTRL_BRK; + state &= ~USB_CDC_SERIAL_STATE_BREAK; if (duration) - state |= ACM_CTRL_BRK; + state |= USB_CDC_SERIAL_STATE_BREAK; acm->serial_state = state; return acm_notify_serial_state(acm); From patchwork Mon Jul 25 07:58:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 593730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F8A6CCA473 for ; Mon, 25 Jul 2022 08:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233106AbiGYIAS (ORCPT ); Mon, 25 Jul 2022 04:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbiGYIAI (ORCPT ); Mon, 25 Jul 2022 04:00:08 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D966613CE5; Mon, 25 Jul 2022 01:00:05 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 55B21CE10D4; Mon, 25 Jul 2022 08:00:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 311B7C341D2; Mon, 25 Jul 2022 08:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658736001; bh=7HPL7TSph7xHTwSwFr2eiOHKgS3Uzq/+C4Qi1l0Xe+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o7liZPuaHI1qRg0PKIiLRfQuTCCno8X5u0oznAEQuftElgWtko5jHR38a2nm5A5pL IDvruIlHGBrHtS4Qocx4CLEo7Bxg6qwmJWabYB+GDZJCCYQceMy4gP30ao6AMYyvke 23U7AIHk8Rm3FgSdzAB7c9NSgHcNDYOemUxkV8OkrQ2kNagPE8snG/jJwU/OCVgqW5 AsOwHkdYlz09iv9jcb0OhiHXobP5rYASQq2R+u9E8fyLyZumIeoMIjy1ycfUfAq1f+ SyP8se2dngo6744xj8uc2bsBw6Tg2r2NChBwGJ1PXs3BKTPfpC7Ssaq7/DQFXDdNmz RJ9lnQ0jqIqzA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oFt0e-0000KG-Ec; Mon, 25 Jul 2022 10:00:12 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Oliver Neukum , Felipe Balbi Cc: Yan Xinyu , linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 7/7] USB: serial: usb_wwan: replace DTR/RTS magic numbers with macros Date: Mon, 25 Jul 2022 09:58:41 +0200 Message-Id: <20220725075841.1187-8-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220725075841.1187-1-johan@kernel.org> References: <20220725075841.1187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Yan Xinyu The usb_wwan_send_setup function generates DTR/RTS signals in compliance with CDC ACM standard. This patch changes magic numbers in this function to equivalent macros. Signed-off-by: Yan Xinyu Link: https://lore.kernel.org/r/20220722085040.704885-1-sdlyyxy@bupt.edu.cn [ johan: use the new CDC control-line defines ] Signed-off-by: Johan Hovold --- drivers/usb/serial/usb_wwan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index dab38b63eaf7..6129a6e26f2c 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include "usb-wwan.h" @@ -48,9 +49,9 @@ static int usb_wwan_send_setup(struct usb_serial_port *port) portdata = usb_get_serial_port_data(port); if (portdata->dtr_state) - val |= 0x01; + val |= USB_CDC_CTRL_DTR; if (portdata->rts_state) - val |= 0x02; + val |= USB_CDC_CTRL_RTS; ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; @@ -59,8 +60,9 @@ static int usb_wwan_send_setup(struct usb_serial_port *port) return res; res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - 0x22, 0x21, val, ifnum, NULL, 0, - USB_CTRL_SET_TIMEOUT); + USB_CDC_REQ_SET_CONTROL_LINE_STATE, + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + val, ifnum, NULL, 0, USB_CTRL_SET_TIMEOUT); usb_autopm_put_interface(port->serial->interface);