aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Spelvin <linux@horizon.com>2013-02-12 02:00:43 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-13 13:13:58 -0500
commit593fb1ae457aab28b392ac114f6e3358788da985 (patch)
tree6f8cc5465000eb8c148bc0d20f957a85e873966a
parentce3da1a654c83c6c9cb0b33477815e5d1293cc00 (diff)
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 <w.d.hubbs@gmail.com> Cc: Chris Brannon <chris@the-brannons.com> Cc: Kirk Reiser <kirk@braille.uwo.ca> Cc: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: George Spelvin <linux@horizon.com> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/pps/clients/pps-ldisc.c11
-rw-r--r--drivers/staging/dgrp/dgrp_net_ops.c1
-rw-r--r--drivers/staging/dgrp/dgrp_tty.c1
-rw-r--r--drivers/staging/speakup/selection.c1
-rw-r--r--drivers/tty/n_tty.c3
-rw-r--r--drivers/tty/serial/serial_core.c5
-rw-r--r--drivers/tty/tty_buffer.c1
-rw-r--r--include/linux/serial_core.h1
-rw-r--r--include/linux/tty_ldisc.h11
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 @@
29 29
30#define PPS_TTY_MAGIC 0x0001 30#define PPS_TTY_MAGIC 0x0001
31 31
32static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, 32static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status)
33 struct pps_event_time *ts)
34{ 33{
35 struct pps_device *pps = pps_lookup_dev(tty); 34 struct pps_device *pps;
35 struct pps_event_time ts;
36
37 pps_get_ts(&ts);
36 38
39 pps = pps_lookup_dev(tty);
37 /* 40 /*
38 * This should never fail, but the ldisc locking is very 41 * This should never fail, but the ldisc locking is very
39 * convoluted, so don't crash just in case. 42 * 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,
42 return; 45 return;
43 46
44 /* Now do the PPS event report */ 47 /* Now do the PPS event report */
45 pps_event(pps, ts, status ? PPS_CAPTUREASSERT : 48 pps_event(pps, &ts, status ? PPS_CAPTUREASSERT :
46 PPS_CAPTURECLEAR, NULL); 49 PPS_CAPTURECLEAR, NULL);
47 50
48 dev_dbg(pps->dev, "PPS %s at %lu\n", 51 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 @@
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/types.h> 38#include <linux/types.h>
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/device.h>
40#include <linux/tty.h> 41#include <linux/tty.h>
41#include <linux/tty_flip.h> 42#include <linux/tty_flip.h>
42#include <linux/spinlock.h> 43#include <linux/spinlock.h>
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 @@
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/tty.h> 40#include <linux/tty.h>
41#include <linux/tty_flip.h> 41#include <linux/tty_flip.h>
42#include <linux/device.h>
42#include <linux/sched.h> 43#include <linux/sched.h>
43#include <linux/uaccess.h> 44#include <linux/uaccess.h>
44 45
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 @@
2#include <linux/consolemap.h> 2#include <linux/consolemap.h>
3#include <linux/interrupt.h> 3#include <linux/interrupt.h>
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/device.h> /* for dev_warn */
5#include <linux/selection.h> 6#include <linux/selection.h>
6 7
7#include "speakup.h" 8#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 @@
49#include <linux/file.h> 49#include <linux/file.h>
50#include <linux/uaccess.h> 50#include <linux/uaccess.h>
51#include <linux/module.h> 51#include <linux/module.h>
52#include <linux/ratelimit.h>
52 53
53 54
54/* number of characters left in xmit buffer before select has we have room */ 55/* 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 = {
2188 * n_tty_inherit_ops - inherit N_TTY methods 2189 * n_tty_inherit_ops - inherit N_TTY methods
2189 * @ops: struct tty_ldisc_ops where to save N_TTY methods 2190 * @ops: struct tty_ldisc_ops where to save N_TTY methods
2190 * 2191 *
2191 * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY 2192 * Enables a 'subclass' line discipline to 'inherit' N_TTY
2192 * methods. 2193 * methods.
2193 */ 2194 */
2194 2195
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)
2726 struct uart_state *state = uport->state; 2726 struct uart_state *state = uport->state;
2727 struct tty_port *port = &state->port; 2727 struct tty_port *port = &state->port;
2728 struct tty_ldisc *ld = NULL; 2728 struct tty_ldisc *ld = NULL;
2729 struct pps_event_time ts;
2730 struct tty_struct *tty = port->tty; 2729 struct tty_struct *tty = port->tty;
2731 2730
2732 if (tty) 2731 if (tty)
2733 ld = tty_ldisc_ref(tty); 2732 ld = tty_ldisc_ref(tty);
2734 if (ld && ld->ops->dcd_change) 2733 if (ld && ld->ops->dcd_change)
2735 pps_get_ts(&ts); 2734 ld->ops->dcd_change(tty, status);
2736 2735
2737 uport->icount.dcd++; 2736 uport->icount.dcd++;
2738#ifdef CONFIG_HARD_PPS 2737#ifdef CONFIG_HARD_PPS
@@ -2747,8 +2746,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
2747 tty_hangup(tty); 2746 tty_hangup(tty);
2748 } 2747 }
2749 2748
2750 if (ld && ld->ops->dcd_change)
2751 ld->ops->dcd_change(tty, status, &ts);
2752 if (ld) 2749 if (ld)
2753 tty_ldisc_deref(ld); 2750 tty_ldisc_deref(ld);
2754} 2751}
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 @@
16#include <linux/bitops.h> 16#include <linux/bitops.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/ratelimit.h>
19 20
20/** 21/**
21 * tty_buffer_free_all - free buffers used by a tty 22 * 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 @@
29#include <linux/tty.h> 29#include <linux/tty.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/sysrq.h> 31#include <linux/sysrq.h>
32#include <linux/pps_kernel.h>
33#include <uapi/linux/serial_core.h> 32#include <uapi/linux/serial_core.h>
34 33
35struct uart_port; 34struct 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 @@
100 * seek to perform this action quickly but should wait until 100 * seek to perform this action quickly but should wait until
101 * any pending driver I/O is completed. 101 * any pending driver I/O is completed.
102 * 102 *
103 * void (*dcd_change)(struct tty_struct *tty, unsigned int status, 103 * void (*dcd_change)(struct tty_struct *tty, unsigned int status)
104 * struct pps_event_time *ts)
105 * 104 *
106 * Tells the discipline that the DCD pin has changed its status and 105 * Tells the discipline that the DCD pin has changed its status.
107 * the relative timestamp. Pointer ts cannot be NULL. 106 * Used exclusively by the N_PPS (Pulse-Per-Second) line discipline.
108 */ 107 */
109 108
110#include <linux/fs.h> 109#include <linux/fs.h>
111#include <linux/wait.h> 110#include <linux/wait.h>
112#include <linux/pps_kernel.h>
113#include <linux/wait.h> 111#include <linux/wait.h>
114 112
115struct tty_ldisc_ops { 113struct tty_ldisc_ops {
@@ -144,8 +142,7 @@ struct tty_ldisc_ops {
144 void (*receive_buf)(struct tty_struct *, const unsigned char *cp, 142 void (*receive_buf)(struct tty_struct *, const unsigned char *cp,
145 char *fp, int count); 143 char *fp, int count);
146 void (*write_wakeup)(struct tty_struct *); 144 void (*write_wakeup)(struct tty_struct *);
147 void (*dcd_change)(struct tty_struct *, unsigned int, 145 void (*dcd_change)(struct tty_struct *, unsigned int);
148 struct pps_event_time *);
149 146
150 struct module *owner; 147 struct module *owner;
151 148