Linux-Serial Archive mirror
 help / color / mirror / Atom feed
From: "Sergio Ammirata, Ph.D." <sergio.ammirata@sipradius.com>
To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org
Subject: Patch:  Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event.
Date: Sun, 28 Apr 2024 21:45:29 -0400	[thread overview]
Message-ID: <76A55B35-0954-4AEF-BAEB-61F2EF32CE95@sipradius.com> (raw)

Hello Greg, Jiri,

commit eb8cb8d62ff718d2fcf7583da8699ba29196f707 (HEAD -> master)
Author: Sergio Ammirata <sergio@ammirata.net>
Date:   Sat Apr 27 22:22:25 2024 -0400

   Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event.
   This is particularly useful for the PPS ldisk as it is common to use the uart’s CD or CTS indistinguishably for PPS. The userspace apps such as gpsd and chronyd already recognize and use both signals for timing data in userspace and will now be able to use CTS for kernel KPPS to significantly increase the accuracy of the measurement.

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c476d8843..8128f64c4 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3515,6 +3515,10 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
 */
void uart_handle_cts_change(struct uart_port *uport, bool active)
{
+       struct tty_port *port = &uport->state->port;
+       struct tty_struct *tty = port->tty;
+       struct tty_ldisc *ld;
+
       lockdep_assert_held_once(&uport->lock);
         uport->icount.cts++;
@@ -3532,7 +3536,13 @@ void uart_handle_cts_change(struct uart_port *uport, bool active)
                               uport->ops->stop_tx(uport);
                       }
               }
-
+       } else if (tty) {
+               ld = tty_ldisc_ref(tty);
+               if (ld) {
+                       if (ld->ops->dcd_change)
+                               ld->ops->dcd_change(tty, active);
+                       tty_ldisc_deref(ld);
+               }
       }
}
EXPORT_SYMBOL_GPL(uart_handle_cts_change);

Regards,

Sergio Ammirata, Ph.D.



             reply	other threads:[~2024-04-29  1:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29  1:45 Sergio Ammirata, Ph.D. [this message]
2024-04-29  6:13 ` Patch: Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=76A55B35-0954-4AEF-BAEB-61F2EF32CE95@sipradius.com \
    --to=sergio.ammirata@sipradius.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).