From patchwork Sun Aug 6 02:26:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Drown X-Patchwork-Id: 13342706 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 081D4EB64DD for ; Sun, 6 Aug 2023 02:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjHFCdE (ORCPT ); Sat, 5 Aug 2023 22:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjHFCdD (ORCPT ); Sat, 5 Aug 2023 22:33:03 -0400 X-Greylist: delayed 406 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 05 Aug 2023 19:33:02 PDT Received: from vps3.drown.org (vps3.drown.org [96.126.122.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554231FEB for ; Sat, 5 Aug 2023 19:33:02 -0700 (PDT) X-Envelope-From: dan-netdev@drown.org Received: from vps3.drown.org (vps3.drown.org [IPv6:2600:3c00::f03c:91ff:fedf:5654]) by vps3.drown.org (Postfix) with ESMTPSA id 32C9B3A04EC for ; Sat, 5 Aug 2023 21:26:15 -0500 (CDT) Date: Sat, 5 Aug 2023 21:26:13 -0500 From: Dan Drown To: linux-usb@vger.kernel.org Subject: [PATCH] usb: cdc-acm: add PPS support Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch adds support for PPS to CDC devices. Changes to the DCD pin are monitored and passed to the ldisc system, which is used by pps-ldisc. Signed-off-by: Dan Drown --- drivers/usb/class/cdc-acm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 11da5fb284d0..9b34199474c4 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -324,8 +325,17 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf) if (difference & USB_CDC_SERIAL_STATE_DSR) acm->iocount.dsr++; - if (difference & USB_CDC_SERIAL_STATE_DCD) + if (difference & USB_CDC_SERIAL_STATE_DCD) { + if (acm->port.tty) { + struct tty_ldisc *ld = tty_ldisc_ref(acm->port.tty); + if (ld) { + if (ld->ops->dcd_change) + ld->ops->dcd_change(acm->port.tty, newctrl & USB_CDC_SERIAL_STATE_DCD); + tty_ldisc_deref(ld); + } + } acm->iocount.dcd++; + } if (newctrl & USB_CDC_SERIAL_STATE_BREAK) { acm->iocount.brk++; tty_insert_flip_char(&acm->port, 0, TTY_BREAK);