aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time.c')
-rw-r--r--kernel/time.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/time.c b/kernel/time.c
index 4064c0566e77..33af3e55570d 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -566,7 +566,11 @@ EXPORT_SYMBOL(jiffies_to_timeval);
566clock_t jiffies_to_clock_t(long x) 566clock_t jiffies_to_clock_t(long x)
567{ 567{
568#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 568#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
569# if HZ < USER_HZ
570 return x * (USER_HZ / HZ);
571# else
569 return x / (HZ / USER_HZ); 572 return x / (HZ / USER_HZ);
573# endif
570#else 574#else
571 u64 tmp = (u64)x * TICK_NSEC; 575 u64 tmp = (u64)x * TICK_NSEC;
572 do_div(tmp, (NSEC_PER_SEC / USER_HZ)); 576 do_div(tmp, (NSEC_PER_SEC / USER_HZ));
@@ -599,7 +603,14 @@ EXPORT_SYMBOL(clock_t_to_jiffies);
599u64 jiffies_64_to_clock_t(u64 x) 603u64 jiffies_64_to_clock_t(u64 x)
600{ 604{
601#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 605#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
606# if HZ < USER_HZ
607 x *= USER_HZ;
608 do_div(x, HZ);
609# elif HZ > USER_HZ
602 do_div(x, HZ / USER_HZ); 610 do_div(x, HZ / USER_HZ);
611# else
612 /* Nothing to do */
613# endif
603#else 614#else
604 /* 615 /*
605 * There are better ways that don't overflow early, 616 * There are better ways that don't overflow early,
@@ -611,7 +622,6 @@ u64 jiffies_64_to_clock_t(u64 x)
611#endif 622#endif
612 return x; 623 return x;
613} 624}
614
615EXPORT_SYMBOL(jiffies_64_to_clock_t); 625EXPORT_SYMBOL(jiffies_64_to_clock_t);
616 626
617u64 nsec_to_clock_t(u64 x) 627u64 nsec_to_clock_t(u64 x)
@@ -646,7 +656,6 @@ u64 get_jiffies_64(void)
646 } while (read_seqretry(&xtime_lock, seq)); 656 } while (read_seqretry(&xtime_lock, seq));
647 return ret; 657 return ret;
648} 658}
649
650EXPORT_SYMBOL(get_jiffies_64); 659EXPORT_SYMBOL(get_jiffies_64);
651#endif 660#endif
652 661