Skip to content

Commit 593fb1a

Browse files
George Spelvingregkh
authored andcommitted
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 <[email protected]> Cc: Chris Brannon <[email protected]> Cc: Kirk Reiser <[email protected]> Cc: Samuel Thibault <[email protected]> Signed-off-by: Peter Hurley <[email protected]> Signed-off-by: George Spelvin <[email protected]> Acked-by: Rodolfo Giometti <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ce3da1a commit 593fb1a

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

drivers/pps/clients/pps-ldisc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929

3030
#define PPS_TTY_MAGIC 0x0001
3131

32-
static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
33-
struct pps_event_time *ts)
32+
static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status)
3433
{
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);
3638

39+
pps = pps_lookup_dev(tty);
3740
/*
3841
* This should never fail, but the ldisc locking is very
3942
* 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,
4245
return;
4346

4447
/* Now do the PPS event report */
45-
pps_event(pps, ts, status ? PPS_CAPTUREASSERT :
48+
pps_event(pps, &ts, status ? PPS_CAPTUREASSERT :
4649
PPS_CAPTURECLEAR, NULL);
4750

4851
dev_dbg(pps->dev, "PPS %s at %lu\n",

drivers/staging/dgrp/dgrp_net_ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/proc_fs.h>
3838
#include <linux/types.h>
3939
#include <linux/string.h>
40+
#include <linux/device.h>
4041
#include <linux/tty.h>
4142
#include <linux/tty_flip.h>
4243
#include <linux/spinlock.h>

drivers/staging/dgrp/dgrp_tty.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/slab.h>
4040
#include <linux/tty.h>
4141
#include <linux/tty_flip.h>
42+
#include <linux/device.h>
4243
#include <linux/sched.h>
4344
#include <linux/uaccess.h>
4445

drivers/staging/speakup/selection.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/consolemap.h>
33
#include <linux/interrupt.h>
44
#include <linux/sched.h>
5+
#include <linux/device.h> /* for dev_warn */
56
#include <linux/selection.h>
67

78
#include "speakup.h"

drivers/tty/n_tty.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/file.h>
5050
#include <linux/uaccess.h>
5151
#include <linux/module.h>
52+
#include <linux/ratelimit.h>
5253

5354

5455
/* 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 = {
21882189
* n_tty_inherit_ops - inherit N_TTY methods
21892190
* @ops: struct tty_ldisc_ops where to save N_TTY methods
21902191
*
2191-
* Used by a generic struct tty_ldisc_ops to easily inherit N_TTY
2192+
* Enables a 'subclass' line discipline to 'inherit' N_TTY
21922193
* methods.
21932194
*/
21942195

drivers/tty/serial/serial_core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,13 +2726,12 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
27262726
struct uart_state *state = uport->state;
27272727
struct tty_port *port = &state->port;
27282728
struct tty_ldisc *ld = NULL;
2729-
struct pps_event_time ts;
27302729
struct tty_struct *tty = port->tty;
27312730

27322731
if (tty)
27332732
ld = tty_ldisc_ref(tty);
27342733
if (ld && ld->ops->dcd_change)
2735-
pps_get_ts(&ts);
2734+
ld->ops->dcd_change(tty, status);
27362735

27372736
uport->icount.dcd++;
27382737
#ifdef CONFIG_HARD_PPS
@@ -2747,8 +2746,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
27472746
tty_hangup(tty);
27482747
}
27492748

2750-
if (ld && ld->ops->dcd_change)
2751-
ld->ops->dcd_change(tty, status, &ts);
27522749
if (ld)
27532750
tty_ldisc_deref(ld);
27542751
}

drivers/tty/tty_buffer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/bitops.h>
1717
#include <linux/delay.h>
1818
#include <linux/module.h>
19+
#include <linux/ratelimit.h>
1920

2021
/**
2122
* tty_buffer_free_all - free buffers used by a tty

include/linux/serial_core.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <linux/tty.h>
3030
#include <linux/mutex.h>
3131
#include <linux/sysrq.h>
32-
#include <linux/pps_kernel.h>
3332
#include <uapi/linux/serial_core.h>
3433

3534
struct uart_port;

include/linux/tty_ldisc.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,14 @@
100100
* seek to perform this action quickly but should wait until
101101
* any pending driver I/O is completed.
102102
*
103-
* void (*dcd_change)(struct tty_struct *tty, unsigned int status,
104-
* struct pps_event_time *ts)
103+
* void (*dcd_change)(struct tty_struct *tty, unsigned int status)
105104
*
106-
* Tells the discipline that the DCD pin has changed its status and
107-
* the relative timestamp. Pointer ts cannot be NULL.
105+
* Tells the discipline that the DCD pin has changed its status.
106+
* Used exclusively by the N_PPS (Pulse-Per-Second) line discipline.
108107
*/
109108

110109
#include <linux/fs.h>
111110
#include <linux/wait.h>
112-
#include <linux/pps_kernel.h>
113111
#include <linux/wait.h>
114112

115113
struct tty_ldisc_ops {
@@ -144,8 +142,7 @@ struct tty_ldisc_ops {
144142
void (*receive_buf)(struct tty_struct *, const unsigned char *cp,
145143
char *fp, int count);
146144
void (*write_wakeup)(struct tty_struct *);
147-
void (*dcd_change)(struct tty_struct *, unsigned int,
148-
struct pps_event_time *);
145+
void (*dcd_change)(struct tty_struct *, unsigned int);
149146

150147
struct module *owner;
151148

0 commit comments

Comments
 (0)