static enum hrtimer_restart dahdi_dummy_hr_int(struct hrtimer *htmr) { unsigned long overrun; /* Trigger DAHDI */ dahdi_receive(&ztd->span); dahdi_transmit(&ztd->span); /* Overrun should always return 1, since we are in the timer that * expired. * We should worry if overrun is 2 or more; then we really missed * a tick */ overrun = hrtimer_forward(&zaptimer, hrtimer_get_expires(htmr), ktime_set(0, DAHDI_TIME_NS)); if(overrun > 1) { if(printk_ratelimit()) printk(KERN_NOTICE "dahdi_dummy: HRTimer missed %lu ticks\n", overrun - 1); } if(debug && DEBUG_TICKS) { static int count = 0; /* Printk every 5 seconds, good test to see if timer is * running properly */ if (count++ % 5000 == 0) printk(KERN_DEBUG "dahdi_dummy: 5000 ticks from hrtimer\n"); } /* Always restart the timer */ return HRTIMER_RESTART; }
static void dahdi_dummy_timer(unsigned long param) { unsigned long ms_since_start; struct timespec now; const unsigned long MAX_INTERVAL = 100000L; const unsigned long MS_LIMIT = 3000; if (!atomic_read(&shutdown)) mod_timer(&timer, jiffies + JIFFIES_INTERVAL); now = current_kernel_time(); ms_since_start = timespec_diff_ms(&ztd->start_interval, &now); /* * If the system time has changed, it is possible for us to be far * behind. If we are more than MS_LIMIT milliseconds behind, just * reset our time base and continue so that we do not hang the system * here. * */ if (unlikely((ms_since_start - ztd->calls_since_start) > MS_LIMIT)) { if (printk_ratelimit()) { printk(KERN_INFO "dahdi_dummy: Detected time shift.\n"); } ztd->calls_since_start = 0; ztd->start_interval = now; return; } while (ms_since_start > ztd->calls_since_start) { ztd->calls_since_start++; dahdi_receive(&ztd->span); dahdi_transmit(&ztd->span); } if (ms_since_start > MAX_INTERVAL) { ztd->calls_since_start = 0; ztd->start_interval = now; } }
static void dahdi_dummy_timer(unsigned long param) { unsigned long ms_since_start; struct timespec now; const unsigned long MAX_INTERVAL = 100000L; if (!atomic_read(&shutdown)) mod_timer(&timer, jiffies + JIFFIES_INTERVAL); now = current_kernel_time(); ms_since_start = timespec_diff_ms(&ztd->start_interval, &now); while (ms_since_start > ztd->calls_since_start) { ztd->calls_since_start++; dahdi_receive(&ztd->span); dahdi_transmit(&ztd->span); } if (ms_since_start > MAX_INTERVAL) { ztd->calls_since_start = 0; ztd->start_interval = now; } }