lkml.org 
[lkml]   [2024]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectPatch: Allow the use of the uart’s CTS (cl ear to send) signal to trigger the cd change ldisk event.
Date
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.


\
 
 \ /
  Last update: 2024-04-29 03:45    [W:0.042 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site