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

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+5 -73
-20
include/linux/jiffies.h
··· 422 422 extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); 423 423 extern void jiffies_to_timespec64(const unsigned long jiffies, 424 424 struct timespec64 *value); 425 - static 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 - 432 - static 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 - 441 - extern unsigned long timeval_to_jiffies(const struct timeval *value); 442 - extern void jiffies_to_timeval(const unsigned long jiffies, 443 - struct timeval *value); 444 - 445 425 extern clock_t jiffies_to_clock_t(unsigned long x); 446 426 static inline clock_t jiffies_delta_to_clock_t(long delta) 447 427 {
+5 -53
kernel/time/time.c
··· 626 626 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec 627 627 * value to a scaled second value. 628 628 */ 629 - static unsigned long 630 - __timespec64_to_jiffies(u64 sec, long nsec) 629 + 630 + unsigned long 631 + timespec64_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 636 if (sec >= MAX_SEC_IN_JIFFIES){ 635 637 sec = MAX_SEC_IN_JIFFIES; ··· 641 639 (((u64)nsec * NSEC_CONVERSION) >> 642 640 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; 643 641 644 - } 645 - 646 - static unsigned long 647 - __timespec_to_jiffies(unsigned long sec, long nsec) 648 - { 649 - return __timespec64_to_jiffies((u64)sec, nsec); 650 - } 651 - 652 - unsigned long 653 - timespec64_to_jiffies(const struct timespec64 *value) 654 - { 655 - return __timespec64_to_jiffies(value->tv_sec, value->tv_nsec); 656 642 } 657 643 EXPORT_SYMBOL(timespec64_to_jiffies); 658 644 ··· 657 667 value->tv_nsec = rem; 658 668 } 659 669 EXPORT_SYMBOL(jiffies_to_timespec64); 660 - 661 - /* 662 - * We could use a similar algorithm to timespec_to_jiffies (with a 663 - * different multiplier for usec instead of nsec). But this has a 664 - * problem with rounding: we can't exactly add TICK_NSEC - 1 to the 665 - * usec value, since it's not necessarily integral. 666 - * 667 - * We could instead round in the intermediate scaled representation 668 - * (i.e. in units of 1/2^(large scale) jiffies) but that's also 669 - * perilous: the scaling introduces a small positive error, which 670 - * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1 671 - * units to the intermediate before shifting) leads to accidental 672 - * overflow and overestimates. 673 - * 674 - * At the cost of one additional multiplication by a constant, just 675 - * use the timespec implementation. 676 - */ 677 - unsigned long 678 - timeval_to_jiffies(const struct timeval *value) 679 - { 680 - return __timespec_to_jiffies(value->tv_sec, 681 - value->tv_usec * NSEC_PER_USEC); 682 - } 683 - EXPORT_SYMBOL(timeval_to_jiffies); 684 - 685 - void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value) 686 - { 687 - /* 688 - * Convert jiffies to nanoseconds and separate with 689 - * one divide. 690 - */ 691 - u32 rem; 692 - 693 - value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, 694 - NSEC_PER_SEC, &rem); 695 - value->tv_usec = rem / NSEC_PER_USEC; 696 - } 697 - EXPORT_SYMBOL(jiffies_to_timeval); 698 670 699 671 /* 700 672 * Convert jiffies/jiffies_64 to clock_t and back.