From 593fb1ae457aab28b392ac114f6e3358788da985 Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Tue, 12 Feb 2013 02:00:43 -0500 Subject: pps: Move timestamp read into PPS code proper The PPS (Pulse-Per-Second) line discipline has developed a number of unhealthy attachments to core tty data and functions, ultimately leading to its breakage. The previous patches fixed the crashing. This one reduces coupling further by eliminating the timestamp parameter from the dcd_change ldisc method. This reduces header file linkage and makes the extension more generic, and the timestamp read is delayed only slightly, from just before the ldisc->ops->dcd_change method call to just after. Fix attendant build breakage in drivers/tty/n_tty.c drivers/tty/tty_buffer.c drivers/staging/speakup/selection.c drivers/staging/dgrp/dgrp_*.c Cc: William Hubbs Cc: Chris Brannon Cc: Kirk Reiser Cc: Samuel Thibault Signed-off-by: Peter Hurley Signed-off-by: George Spelvin Acked-by: Rodolfo Giometti Signed-off-by: Greg Kroah-Hartman --- drivers/pps/clients/pps-ldisc.c | 11 +++++++---- drivers/staging/dgrp/dgrp_net_ops.c | 1 + drivers/staging/dgrp/dgrp_tty.c | 1 + drivers/staging/speakup/selection.c | 1 + drivers/tty/n_tty.c | 3 ++- drivers/tty/serial/serial_core.c | 5 +---- drivers/tty/tty_buffer.c | 1 + include/linux/serial_core.h | 1 - include/linux/tty_ldisc.h | 11 ++++------- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c index a94f73e1480d..73bd3bb4d93b 100644 --- a/drivers/pps/clients/pps-ldisc.c +++ b/drivers/pps/clients/pps-ldisc.c @@ -29,11 +29,14 @@ #define PPS_TTY_MAGIC 0x0001 -static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, - struct pps_event_time *ts) +static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status) { - struct pps_device *pps = pps_lookup_dev(tty); + struct pps_device *pps; + struct pps_event_time ts; + + pps_get_ts(&ts); + pps = pps_lookup_dev(tty); /* * This should never fail, but the ldisc locking is very * convoluted, so don't crash just in case. @@ -42,7 +45,7 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, return; /* Now do the PPS event report */ - pps_event(pps, ts, status ? PPS_CAPTUREASSERT : + pps_event(pps, &ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR, NULL); dev_dbg(pps->dev, "PPS %s at %lu\n", diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 4c7abfabf197..e6018823b9de 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c index 51d3ed3dca27..654f6010b473 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c index 0612df06a4bf..2aa22379fda0 100644 --- a/drivers/staging/speakup/selection.c +++ b/drivers/staging/speakup/selection.c @@ -2,6 +2,7 @@ #include #include #include +#include /* for dev_warn */ #include #include "speakup.h" diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 095072899b5e..05e72bea9b07 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -49,6 +49,7 @@ #include #include #include +#include /* number of characters left in xmit buffer before select has we have room */ @@ -2188,7 +2189,7 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { * n_tty_inherit_ops - inherit N_TTY methods * @ops: struct tty_ldisc_ops where to save N_TTY methods * - * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY + * Enables a 'subclass' line discipline to 'inherit' N_TTY * methods. */ diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index ca98a3f65fe1..765be520cd2e 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2726,13 +2726,12 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) struct uart_state *state = uport->state; struct tty_port *port = &state->port; struct tty_ldisc *ld = NULL; - struct pps_event_time ts; struct tty_struct *tty = port->tty; if (tty) ld = tty_ldisc_ref(tty); if (ld && ld->ops->dcd_change) - pps_get_ts(&ts); + ld->ops->dcd_change(tty, status); uport->icount.dcd++; #ifdef CONFIG_HARD_PPS @@ -2747,8 +2746,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) tty_hangup(tty); } - if (ld && ld->ops->dcd_change) - ld->ops->dcd_change(tty, status, &ts); if (ld) tty_ldisc_deref(ld); } diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 61ec4ddf47e0..bb119934e76c 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -16,6 +16,7 @@ #include #include #include +#include /** * tty_buffer_free_all - free buffers used by a tty diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index d97142159e0f..87d4bbc773fc 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -29,7 +29,6 @@ #include #include #include -#include #include struct uart_port; diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index fb79dd8d1537..455a0d7bf220 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -100,16 +100,14 @@ * seek to perform this action quickly but should wait until * any pending driver I/O is completed. * - * void (*dcd_change)(struct tty_struct *tty, unsigned int status, - * struct pps_event_time *ts) + * void (*dcd_change)(struct tty_struct *tty, unsigned int status) * - * Tells the discipline that the DCD pin has changed its status and - * the relative timestamp. Pointer ts cannot be NULL. + * Tells the discipline that the DCD pin has changed its status. + * Used exclusively by the N_PPS (Pulse-Per-Second) line discipline. */ #include #include -#include #include struct tty_ldisc_ops { @@ -144,8 +142,7 @@ struct tty_ldisc_ops { void (*receive_buf)(struct tty_struct *, const unsigned char *cp, char *fp, int count); void (*write_wakeup)(struct tty_struct *); - void (*dcd_change)(struct tty_struct *, unsigned int, - struct pps_event_time *); + void (*dcd_change)(struct tty_struct *, unsigned int); struct module *owner; -- cgit v1.2.3