pps: unify timestamp gathering
Add a helper function to gather timestamps. This way clients don't have to duplicate it. Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su> Acked-by: Rodolfo Giometti <giometti@linux.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
3003d55b59
commit
6f4229b511
@@ -43,6 +43,10 @@ struct pps_source_info {
|
||||
struct device *dev;
|
||||
};
|
||||
|
||||
struct pps_event_time {
|
||||
struct timespec ts_real;
|
||||
};
|
||||
|
||||
/* The main struct */
|
||||
struct pps_device {
|
||||
struct pps_source_info info; /* PSS source info */
|
||||
@@ -88,6 +92,20 @@ extern int pps_register_source(struct pps_source_info *info,
|
||||
extern void pps_unregister_source(int source);
|
||||
extern int pps_register_cdev(struct pps_device *pps);
|
||||
extern void pps_unregister_cdev(struct pps_device *pps);
|
||||
extern void pps_event(int source, struct pps_ktime *ts, int event, void *data);
|
||||
extern void pps_event(int source, struct pps_event_time *ts, int event,
|
||||
void *data);
|
||||
|
||||
static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
|
||||
struct timespec ts)
|
||||
{
|
||||
kt->sec = ts.tv_sec;
|
||||
kt->nsec = ts.tv_nsec;
|
||||
}
|
||||
|
||||
static inline void pps_get_ts(struct pps_event_time *ts)
|
||||
{
|
||||
getnstimeofday(&ts->ts_real);
|
||||
}
|
||||
|
||||
#endif /* LINUX_PPS_KERNEL_H */
|
||||
|
||||
|
@@ -212,6 +212,7 @@
|
||||
#include <linux/tty.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysrq.h>
|
||||
#include <linux/pps_kernel.h>
|
||||
|
||||
struct uart_port;
|
||||
struct serial_struct;
|
||||
@@ -528,10 +529,10 @@ 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 = tty_ldisc_ref(port->tty);
|
||||
struct timespec ts;
|
||||
struct pps_event_time ts;
|
||||
|
||||
if (ld && ld->ops->dcd_change)
|
||||
getnstimeofday(&ts);
|
||||
pps_get_ts(&ts);
|
||||
|
||||
uport->icount.dcd++;
|
||||
#ifdef CONFIG_HARD_PPS
|
||||
|
@@ -101,7 +101,7 @@
|
||||
* any pending driver I/O is completed.
|
||||
*
|
||||
* void (*dcd_change)(struct tty_struct *tty, unsigned int status,
|
||||
* struct timespec *ts)
|
||||
* struct pps_event_time *ts)
|
||||
*
|
||||
* Tells the discipline that the DCD pin has changed its status and
|
||||
* the relative timestamp. Pointer ts can be NULL.
|
||||
@@ -109,6 +109,7 @@
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/pps_kernel.h>
|
||||
|
||||
struct tty_ldisc_ops {
|
||||
int magic;
|
||||
@@ -143,7 +144,7 @@ struct tty_ldisc_ops {
|
||||
char *fp, int count);
|
||||
void (*write_wakeup)(struct tty_struct *);
|
||||
void (*dcd_change)(struct tty_struct *, unsigned int,
|
||||
struct timespec *);
|
||||
struct pps_event_time *);
|
||||
|
||||
struct module *owner;
|
||||
|
||||
|
Reference in New Issue
Block a user