summaryrefslogtreecommitdiff
path: root/include/linux/jiffies.h
diff options
context:
space:
mode:
authorNishanth Aravamudan <nacc@us.ibm.com>2005-02-04 03:16:31 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-02-04 03:16:31 -0800
commit49cc01f416229e7f5eee0daa3fe2c6050b575a74 (patch)
treed76dd789385f2f95c1e9092675f6e45e756ffdfd /include/linux/jiffies.h
parent14d23203572b7dd595db73df58dc0cb818a9537e (diff)
[PATCH] include/jiffies: fix usecs_to_jiffies()/jiffies_to_usecs() math
Fixes the math of both jiffies_to_usecs() and usecs_to_jiffies() which improperly assume the same rounding point -- 1,000 -- as jiffies_to_msecs() and msecs_to_jiffies(), when in fact it should be 1,000,000. Furthermore, the actual math of both functions is actually wrong and will lead to more than just rounding errors. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/jiffies.h')
-rw-r--r--include/linux/jiffies.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 5808e8041e0c..d7a2555a886c 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -265,10 +265,10 @@ static inline unsigned int jiffies_to_msecs(const unsigned long j)
static inline unsigned int jiffies_to_usecs(const unsigned long j)
{
-#if HZ <= 1000 && !(1000 % HZ)
+#if HZ <= 1000000 && !(1000000 % HZ)
return (1000000 / HZ) * j;
-#elif HZ > 1000 && !(HZ % 1000)
- return (j*1000 + (HZ - 1000))/(HZ / 1000);
+#elif HZ > 1000000 && !(HZ % 1000000)
+ return (j + (HZ / 1000000) - 1)/(HZ / 1000000);
#else
return (j * 1000000) / HZ;
#endif
@@ -291,9 +291,9 @@ static inline unsigned long usecs_to_jiffies(const unsigned int u)
{
if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
return MAX_JIFFY_OFFSET;
-#if HZ <= 1000 && !(1000 % HZ)
- return (u + (1000000 / HZ) - 1000) / (1000000 / HZ);
-#elif HZ > 1000 && !(HZ % 1000)
+#if HZ <= 1000000 && !(1000000 % HZ)
+ return (u + (1000000 / HZ) - 1) / (1000000 / HZ);
+#elif HZ > 1000000 && !(HZ % 1000000)
return u * (HZ / 1000000);
#else
return (u * HZ + 999999) / 1000000;