All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* Patch:  Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event.
@ 2024-04-29  1:45 Sergio Ammirata, Ph.D.
  2024-04-29  6:13 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Sergio Ammirata, Ph.D. @ 2024-04-29  1:45 UTC (permalink / raw
  To: linux-kernel, linux-serial; +Cc: gregkh, jirislaby

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.



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Patch:  Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event.
  2024-04-29  1:45 Patch: Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event Sergio Ammirata, Ph.D.
@ 2024-04-29  6:13 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2024-04-29  6:13 UTC (permalink / raw
  To: Sergio Ammirata, Ph.D.; +Cc: linux-kernel, linux-serial, jirislaby

On Sun, Apr 28, 2024 at 09:45:29PM -0400, Sergio Ammirata, Ph.D. wrote:
> 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.
> 
> 
> 


Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch contains warnings and/or errors noticed by the
  scripts/checkpatch.pl tool.

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/process/email-clients.rst in order to fix this.

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/process/submitting-patches.rst and resend
  it after adding that line.  Note, the line needs to be in the body of
  the email, before the patch, not at the bottom of the patch or in the
  email signature.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/process/submitting-patches.rst for what is needed in
  order to properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/process/submitting-patches.rst for what a proper
  Subject: line should look like.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-29  6:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29  1:45 Patch: Allow the use of the uart’s CTS (clear to send) signal to trigger the cd_change ldisk event Sergio Ammirata, Ph.D.
2024-04-29  6:13 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.