提交 593fb1ae 编写于 作者: G George Spelvin 提交者: Greg Kroah-Hartman

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: NPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: NGeorge Spelvin <linux@horizon.com>
Acked-by: NRodolfo Giometti <giometti@enneenne.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 ce3da1a6
...@@ -29,11 +29,14 @@ ...@@ -29,11 +29,14 @@
#define PPS_TTY_MAGIC 0x0001 #define PPS_TTY_MAGIC 0x0001
static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status)
struct pps_event_time *ts)
{ {
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 * This should never fail, but the ldisc locking is very
* convoluted, so don't crash just in case. * 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,7 +45,7 @@ static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
return; return;
/* Now do the PPS event report */ /* Now do the PPS event report */
pps_event(pps, ts, status ? PPS_CAPTUREASSERT : pps_event(pps, &ts, status ? PPS_CAPTUREASSERT :
PPS_CAPTURECLEAR, NULL); PPS_CAPTURECLEAR, NULL);
dev_dbg(pps->dev, "PPS %s at %lu\n", dev_dbg(pps->dev, "PPS %s at %lu\n",
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/device.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/tty_flip.h> #include <linux/tty_flip.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/tty_flip.h> #include <linux/tty_flip.h>
#include <linux/device.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/consolemap.h> #include <linux/consolemap.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/device.h> /* for dev_warn */
#include <linux/selection.h> #include <linux/selection.h>
#include "speakup.h" #include "speakup.h"
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include <linux/file.h> #include <linux/file.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/ratelimit.h>
/* number of characters left in xmit buffer before select has we have room */ /* 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,7 +2189,7 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = {
* n_tty_inherit_ops - inherit N_TTY methods * n_tty_inherit_ops - inherit N_TTY methods
* @ops: struct tty_ldisc_ops where to save 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. * methods.
*/ */
......
...@@ -2726,13 +2726,12 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) ...@@ -2726,13 +2726,12 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
struct uart_state *state = uport->state; struct uart_state *state = uport->state;
struct tty_port *port = &state->port; struct tty_port *port = &state->port;
struct tty_ldisc *ld = NULL; struct tty_ldisc *ld = NULL;
struct pps_event_time ts;
struct tty_struct *tty = port->tty; struct tty_struct *tty = port->tty;
if (tty) if (tty)
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld && ld->ops->dcd_change) if (ld && ld->ops->dcd_change)
pps_get_ts(&ts); ld->ops->dcd_change(tty, status);
uport->icount.dcd++; uport->icount.dcd++;
#ifdef CONFIG_HARD_PPS #ifdef CONFIG_HARD_PPS
...@@ -2747,8 +2746,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) ...@@ -2747,8 +2746,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
tty_hangup(tty); tty_hangup(tty);
} }
if (ld && ld->ops->dcd_change)
ld->ops->dcd_change(tty, status, &ts);
if (ld) if (ld)
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/ratelimit.h>
/** /**
* tty_buffer_free_all - free buffers used by a tty * tty_buffer_free_all - free buffers used by a tty
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/pps_kernel.h>
#include <uapi/linux/serial_core.h> #include <uapi/linux/serial_core.h>
struct uart_port; struct uart_port;
......
...@@ -100,16 +100,14 @@ ...@@ -100,16 +100,14 @@
* seek to perform this action quickly but should wait until * seek to perform this action quickly but should wait until
* any pending driver I/O is completed. * any pending driver I/O is completed.
* *
* void (*dcd_change)(struct tty_struct *tty, unsigned int status, * void (*dcd_change)(struct tty_struct *tty, unsigned int status)
* struct pps_event_time *ts)
* *
* Tells the discipline that the DCD pin has changed its status and * Tells the discipline that the DCD pin has changed its status.
* the relative timestamp. Pointer ts cannot be NULL. * Used exclusively by the N_PPS (Pulse-Per-Second) line discipline.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/pps_kernel.h>
#include <linux/wait.h> #include <linux/wait.h>
struct tty_ldisc_ops { struct tty_ldisc_ops {
...@@ -144,8 +142,7 @@ struct tty_ldisc_ops { ...@@ -144,8 +142,7 @@ struct tty_ldisc_ops {
void (*receive_buf)(struct tty_struct *, const unsigned char *cp, void (*receive_buf)(struct tty_struct *, const unsigned char *cp,
char *fp, int count); char *fp, int count);
void (*write_wakeup)(struct tty_struct *); void (*write_wakeup)(struct tty_struct *);
void (*dcd_change)(struct tty_struct *, unsigned int, void (*dcd_change)(struct tty_struct *, unsigned int);
struct pps_event_time *);
struct module *owner; struct module *owner;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册