From: Nishanth Aravamudan 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 Signed-off-by: Andrew Morton --- 25-akpm/include/linux/jiffies.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff -puN include/linux/jiffies.h~include-jiffies-fix-usecs_to_jiffies-jiffies_to_usecs-math include/linux/jiffies.h --- 25/include/linux/jiffies.h~include-jiffies-fix-usecs_to_jiffies-jiffies_to_usecs-math 2005-02-03 17:39:37.911724872 -0800 +++ 25-akpm/include/linux/jiffies.h 2005-02-03 17:39:37.915724264 -0800 @@ -265,10 +265,10 @@ static inline unsigned int jiffies_to_ms 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_jif { 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; _