History

y2038: remove obsolete jiffies conversion functions

Now that the last user of timespec_to_jiffies() is gone, these can just be removed, everything else is using ktime_t or timespec64 already.

Arnd Bergmann committed 7 years ago

Commit 751adda1 parent 6e31ded2 files · +5 −73Browse files

Unified · Split

2 files
  1. include/linux/jiffies.h +0 −20
  2. kernel/time/time.c +5 −53
include/linux/jiffies.h+0−20
@@ -422,26 +422,6 @@ static __always_inline unsigned long usecs_to_jiffies(const unsigned int u) · 421 unmodified lines
422extern unsigned long timespec64_to_jiffies(const struct timespec64 *value);422extern unsigned long timespec64_to_jiffies(const struct timespec64 *value);
423extern void jiffies_to_timespec64(const unsigned long jiffies,423extern void jiffies_to_timespec64(const unsigned long jiffies,
424 struct timespec64 *value);424 struct timespec64 *value);
425static inline unsigned long timespec_to_jiffies(const struct timespec *value)
426{
427 struct timespec64 ts = timespec_to_timespec64(*value);
428
429 return timespec64_to_jiffies(&ts);
430}
431
432static inline void jiffies_to_timespec(const unsigned long jiffies,
433 struct timespec *value)
434{
435 struct timespec64 ts;
436
437 jiffies_to_timespec64(jiffies, &ts);
438 *value = timespec64_to_timespec(ts);
439}
440
441extern unsigned long timeval_to_jiffies(const struct timeval *value);
442extern void jiffies_to_timeval(const unsigned long jiffies,
443 struct timeval *value);
444
445extern clock_t jiffies_to_clock_t(unsigned long x);425extern clock_t jiffies_to_clock_t(unsigned long x);
446static inline clock_t jiffies_delta_to_clock_t(long delta)426static inline clock_t jiffies_delta_to_clock_t(long delta)
447{427{
kernel/time/time.c+5−53
@@ -626,10 +626,12 @@ EXPORT_SYMBOL(__usecs_to_jiffies); · 625 unmodified lines
626 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec626 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
627 * value to a scaled second value.627 * value to a scaled second value.
628 */628 */
629static unsigned long629
630__timespec64_to_jiffies(u64 sec, long nsec)630unsigned long
631timespec64_to_jiffies(const struct timespec64 *value)
631{632{
632 nsec = nsec + TICK_NSEC - 1;633 u64 sec = value->tv_sec;
634 long nsec = value->tv_nsec + TICK_NSEC - 1;
633 635
634 if (sec >= MAX_SEC_IN_JIFFIES){636 if (sec >= MAX_SEC_IN_JIFFIES){
635 sec = MAX_SEC_IN_JIFFIES;637 sec = MAX_SEC_IN_JIFFIES;
@@ -640,18 +642,6 @@ __timespec64_to_jiffies(u64 sec, long nsec) · 4 unmodified lines
640 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;642 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
641 643
642}644}
643
644static unsigned long
645__timespec_to_jiffies(unsigned long sec, long nsec)
646{
647 return __timespec64_to_jiffies((u64)sec, nsec);
648}
649
650unsigned long
651timespec64_to_jiffies(const struct timespec64 *value)
652{
653 return __timespec64_to_jiffies(value->tv_sec, value->tv_nsec);
654}
655EXPORT_SYMBOL(timespec64_to_jiffies);645EXPORT_SYMBOL(timespec64_to_jiffies);
656 646
657void647void
@@ -668,44 +658,6 @@ jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value) · 10 unmodified lines
668}658}
669EXPORT_SYMBOL(jiffies_to_timespec64);659EXPORT_SYMBOL(jiffies_to_timespec64);
670 660
671/*
672 * We could use a similar algorithm to timespec_to_jiffies (with a
673 * different multiplier for usec instead of nsec). But this has a
674 * problem with rounding: we can't exactly add TICK_NSEC - 1 to the
675 * usec value, since it's not necessarily integral.
676 *
677 * We could instead round in the intermediate scaled representation
678 * (i.e. in units of 1/2^(large scale) jiffies) but that's also
679 * perilous: the scaling introduces a small positive error, which
680 * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1
681 * units to the intermediate before shifting) leads to accidental
682 * overflow and overestimates.
683 *
684 * At the cost of one additional multiplication by a constant, just
685 * use the timespec implementation.
686 */
687unsigned long
688timeval_to_jiffies(const struct timeval *value)
689{
690 return __timespec_to_jiffies(value->tv_sec,
691 value->tv_usec * NSEC_PER_USEC);
692}
693EXPORT_SYMBOL(timeval_to_jiffies);
694
695void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
696{
697 /*
698 * Convert jiffies to nanoseconds and separate with
699 * one divide.
700 */
701 u32 rem;
702
703 value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC,
704 NSEC_PER_SEC, &rem);
705 value->tv_usec = rem / NSEC_PER_USEC;
706}
707EXPORT_SYMBOL(jiffies_to_timeval);
708
709/*661/*
710 * Convert jiffies/jiffies_64 to clock_t and back.662 * Convert jiffies/jiffies_64 to clock_t and back.
711 */663 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t