// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2008 by Andreas Eversberg <andreas@eversberg.eu> * * Quick API description: * * A clock source registers using mISDN_register_clock: * name = text string to name clock source * priority = value to priorize clock sources (0 = default) * ctl = callback function to enable/disable clock source * priv = private pointer of clock source * return = pointer to clock source structure; * * Note: Callback 'ctl' can be called before mISDN_register_clock returns! * Also it can be called during mISDN_unregister_clock. * * A clock source calls mISDN_clock_update with given samples elapsed, if * enabled. If function call is delayed, tv must be set with the timestamp * of the actual event. * * A clock source unregisters using mISDN_unregister_clock. * * To get current clock, call mISDN_clock_get. The signed short value * counts the number of samples since. Time since last clock event is added.
*/
write_lock_irqsave(&iclock_lock, flags); if (iclock_current != iclock) {
printk(KERN_ERR "%s: '%s' sends us clock updates, but we do " "listen to '%s'. This is a bug!\n", __func__,
iclock->name,
iclock_current ? iclock_current->name : "nothing");
iclock->ctl(iclock->priv, 0);
write_unlock_irqrestore(&iclock_lock, flags); return;
} if (iclock_timestamp_valid) { /* increment sample counter by given samples */
iclock_count += samples; if (timestamp) { /* timestamp must be set, if function call is delayed */
iclock_timestamp = *timestamp;
} else {
iclock_timestamp = ktime_get();
}
} else { /* calc elapsed time by system clock */ if (timestamp) { /* timestamp must be set, if function call is delayed */
timestamp_now = *timestamp;
} else {
timestamp_now = ktime_get();
}
delta = ktime_divns(ktime_sub(timestamp_now, iclock_timestamp),
(NSEC_PER_SEC / 8000)); /* add elapsed time to counter and set new timestamp */
iclock_count += delta;
iclock_timestamp = timestamp_now;
iclock_timestamp_valid = 1; if (*debug & DEBUG_CLOCK)
printk("Received first clock from source '%s'.\n",
iclock_current ? iclock_current->name : "nothing");
}
write_unlock_irqrestore(&iclock_lock, flags);
}
EXPORT_SYMBOL(mISDN_clock_update);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.