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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ktime-get-clock-ts64-for-ptp' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Base implementation for PTP with a temporary CLOCK_AUX* workaround to
allow integration of depending changes into the networking tree.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Paolo Abeni 4f38a6db 135faae6

+43
+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); ··· 344 343 struct timespec64 *boot_offset); 345 344 #ifdef CONFIG_GENERIC_CMOS_UPDATE 346 345 extern int update_persistent_clock64(struct timespec64 now); 346 + #endif 347 + 348 + /* Temporary workaround to avoid merge dependencies and cross tree messes */ 349 + #ifndef CLOCK_AUX 350 + #define CLOCK_AUX MAX_CLOCKS 351 + #define MAX_AUX_CLOCKS 8 352 + #define CLOCK_AUX_LAST (CLOCK_AUX + MAX_AUX_CLOCKS - 1) 353 + 354 + static inline bool ktime_get_aux_ts64(clockid_t id, struct timespec64 *kt) { return false; } 347 355 #endif 348 356 349 357 #endif
+33
kernel/time/timekeeping.c
··· 1573 1573 } 1574 1574 EXPORT_SYMBOL(ktime_get_raw_ts64); 1575 1575 1576 + /** 1577 + * ktime_get_clock_ts64 - Returns time of a clock in a timespec 1578 + * @id: POSIX clock ID of the clock to read 1579 + * @ts: Pointer to the timespec64 to be set 1580 + * 1581 + * The timestamp is invalidated (@ts->sec is set to -1) if the 1582 + * clock @id is not available. 1583 + */ 1584 + void ktime_get_clock_ts64(clockid_t id, struct timespec64 *ts) 1585 + { 1586 + /* Invalidate time stamp */ 1587 + ts->tv_sec = -1; 1588 + ts->tv_nsec = 0; 1589 + 1590 + switch (id) { 1591 + case CLOCK_REALTIME: 1592 + ktime_get_real_ts64(ts); 1593 + return; 1594 + case CLOCK_MONOTONIC: 1595 + ktime_get_ts64(ts); 1596 + return; 1597 + case CLOCK_MONOTONIC_RAW: 1598 + ktime_get_raw_ts64(ts); 1599 + return; 1600 + case CLOCK_AUX ... CLOCK_AUX_LAST: 1601 + if (IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS)) 1602 + ktime_get_aux_ts64(id, ts); 1603 + return; 1604 + default: 1605 + WARN_ON_ONCE(1); 1606 + } 1607 + } 1608 + EXPORT_SYMBOL_GPL(ktime_get_clock_ts64); 1576 1609 1577 1610 /** 1578 1611 * timekeeping_valid_for_hres - Check if timekeeping is suitable for hres