mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-04 05:11:46 +00:00
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:
parent
3003d55b59
commit
6f4229b511
6 changed files with 45 additions and 31 deletions
|
@ -40,18 +40,13 @@ static struct timer_list ktimer;
|
|||
|
||||
static void pps_ktimer_event(unsigned long ptr)
|
||||
{
|
||||
struct timespec __ts;
|
||||
struct pps_ktime ts;
|
||||
struct pps_event_time ts;
|
||||
|
||||
/* First of all we get the time stamp... */
|
||||
getnstimeofday(&__ts);
|
||||
pps_get_ts(&ts);
|
||||
|
||||
pr_info("PPS event at %lu\n", jiffies);
|
||||
|
||||
/* ... and translate it to PPS time data struct */
|
||||
ts.sec = __ts.tv_sec;
|
||||
ts.nsec = __ts.tv_nsec;
|
||||
|
||||
pps_event(source, &ts, PPS_CAPTUREASSERT, NULL);
|
||||
|
||||
mod_timer(&ktimer, jiffies + HZ);
|
||||
|
|
|
@ -27,26 +27,20 @@
|
|||
#define PPS_TTY_MAGIC 0x0001
|
||||
|
||||
static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
|
||||
struct timespec *ts)
|
||||
struct pps_event_time *ts)
|
||||
{
|
||||
int id = (long)tty->disc_data;
|
||||
struct timespec __ts;
|
||||
struct pps_ktime pps_ts;
|
||||
struct pps_event_time __ts;
|
||||
|
||||
/* First of all we get the time stamp... */
|
||||
getnstimeofday(&__ts);
|
||||
pps_get_ts(&__ts);
|
||||
|
||||
/* Does caller give us a timestamp? */
|
||||
if (ts) { /* Yes. Let's use it! */
|
||||
pps_ts.sec = ts->tv_sec;
|
||||
pps_ts.nsec = ts->tv_nsec;
|
||||
} else { /* No. Do it ourself! */
|
||||
pps_ts.sec = __ts.tv_sec;
|
||||
pps_ts.nsec = __ts.tv_nsec;
|
||||
}
|
||||
if (!ts) /* No. Do it ourself! */
|
||||
ts = &__ts;
|
||||
|
||||
/* Now do the PPS event report */
|
||||
pps_event(id, &pps_ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR,
|
||||
pps_event(id, ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR,
|
||||
NULL);
|
||||
|
||||
pr_debug("PPS %s at %lu on source #%d\n",
|
||||
|
|
|
@ -268,11 +268,12 @@ EXPORT_SYMBOL(pps_unregister_source);
|
|||
* pps->info.echo(source, event, data);
|
||||
*/
|
||||
|
||||
void pps_event(int source, struct pps_ktime *ts, int event, void *data)
|
||||
void pps_event(int source, struct pps_event_time *ts, int event, void *data)
|
||||
{
|
||||
struct pps_device *pps;
|
||||
unsigned long flags;
|
||||
int captured = 0;
|
||||
struct pps_ktime ts_real;
|
||||
|
||||
if ((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0) {
|
||||
printk(KERN_ERR "pps: unknown event (%x) for source %d\n",
|
||||
|
@ -284,8 +285,10 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data)
|
|||
if (!pps)
|
||||
return;
|
||||
|
||||
pr_debug("PPS event on source %d at %llu.%06u\n",
|
||||
pps->id, (unsigned long long) ts->sec, ts->nsec);
|
||||
pr_debug("PPS event on source %d at %ld.%09ld\n",
|
||||
pps->id, ts->ts_real.tv_sec, ts->ts_real.tv_nsec);
|
||||
|
||||
timespec_to_pps_ktime(&ts_real, ts->ts_real);
|
||||
|
||||
spin_lock_irqsave(&pps->lock, flags);
|
||||
|
||||
|
@ -299,10 +302,11 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data)
|
|||
(pps->params.mode & PPS_CAPTUREASSERT)) {
|
||||
/* We have to add an offset? */
|
||||
if (pps->params.mode & PPS_OFFSETASSERT)
|
||||
pps_add_offset(ts, &pps->params.assert_off_tu);
|
||||
pps_add_offset(&ts_real,
|
||||
&pps->params.assert_off_tu);
|
||||
|
||||
/* Save the time stamp */
|
||||
pps->assert_tu = *ts;
|
||||
pps->assert_tu = ts_real;
|
||||
pps->assert_sequence++;
|
||||
pr_debug("capture assert seq #%u for source %d\n",
|
||||
pps->assert_sequence, source);
|
||||
|
@ -313,10 +317,11 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data)
|
|||
(pps->params.mode & PPS_CAPTURECLEAR)) {
|
||||
/* We have to add an offset? */
|
||||
if (pps->params.mode & PPS_OFFSETCLEAR)
|
||||
pps_add_offset(ts, &pps->params.clear_off_tu);
|
||||
pps_add_offset(&ts_real,
|
||||
&pps->params.clear_off_tu);
|
||||
|
||||
/* Save the time stamp */
|
||||
pps->clear_tu = *ts;
|
||||
pps->clear_tu = ts_real;
|
||||
pps->clear_sequence++;
|
||||
pr_debug("capture clear seq #%u for source %d\n",
|
||||
pps->clear_sequence, source);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue