Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'ktime-get-clock-ts64-for-ptp' into timers/ptp

Pull the base implementation of ktime_get_clock_ts64() for PTP, which
contains a temporary CLOCK_AUX* workaround. That was created to allow
integration of depending changes into the networking tree. The workaround
is going to be removed in a subsequent change in the timekeeping tree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+44
+10
include/linux/timekeeping.h
··· 44 44 extern void ktime_get_real_ts64(struct timespec64 *tv); 45 45 extern void ktime_get_coarse_ts64(struct timespec64 *ts); 46 46 extern void ktime_get_coarse_real_ts64(struct timespec64 *ts); 47 + extern void ktime_get_clock_ts64(clockid_t id, struct timespec64 *ts); 47 48 48 49 /* Multigrain timestamp interfaces */ 49 50 extern void ktime_get_coarse_real_ts64_mg(struct timespec64 *ts); ··· 355 354 struct timespec64 *boot_offset); 356 355 #ifdef CONFIG_GENERIC_CMOS_UPDATE 357 356 extern int update_persistent_clock64(struct timespec64 now); 357 + #endif 358 + 359 + /* Temporary workaround to avoid merge dependencies and cross tree messes */ 360 + #ifndef CLOCK_AUX 361 + #define CLOCK_AUX MAX_CLOCKS 362 + #define MAX_AUX_CLOCKS 8 363 + #define CLOCK_AUX_LAST (CLOCK_AUX + MAX_AUX_CLOCKS - 1) 364 + 365 + static inline bool ktime_get_aux_ts64(clockid_t id, struct timespec64 *kt) { return false; } 358 366 #endif 359 367 360 368 #endif
+34
kernel/time/timekeeping.c
··· 1641 1641 EXPORT_SYMBOL(ktime_get_raw_ts64); 1642 1642 1643 1643 /** 1644 + * ktime_get_clock_ts64 - Returns time of a clock in a timespec 1645 + * @id: POSIX clock ID of the clock to read 1646 + * @ts: Pointer to the timespec64 to be set 1647 + * 1648 + * The timestamp is invalidated (@ts->sec is set to -1) if the 1649 + * clock @id is not available. 1650 + */ 1651 + void ktime_get_clock_ts64(clockid_t id, struct timespec64 *ts) 1652 + { 1653 + /* Invalidate time stamp */ 1654 + ts->tv_sec = -1; 1655 + ts->tv_nsec = 0; 1656 + 1657 + switch (id) { 1658 + case CLOCK_REALTIME: 1659 + ktime_get_real_ts64(ts); 1660 + return; 1661 + case CLOCK_MONOTONIC: 1662 + ktime_get_ts64(ts); 1663 + return; 1664 + case CLOCK_MONOTONIC_RAW: 1665 + ktime_get_raw_ts64(ts); 1666 + return; 1667 + case CLOCK_AUX ... CLOCK_AUX_LAST: 1668 + if (IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS)) 1669 + ktime_get_aux_ts64(id, ts); 1670 + return; 1671 + default: 1672 + WARN_ON_ONCE(1); 1673 + } 1674 + } 1675 + EXPORT_SYMBOL_GPL(ktime_get_clock_ts64); 1676 + 1677 + /** 1644 1678 * timekeeping_valid_for_hres - Check if timekeeping is suitable for hres 1645 1679 */ 1646 1680 int timekeeping_valid_for_hres(void)