diff options
Diffstat (limited to 'kernel/time.c')
-rw-r--r-- | kernel/time.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/kernel/time.c b/kernel/time.c index ba18ec4899bd..f04791f69408 100644 --- a/kernel/time.c +++ b/kernel/time.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/timex.h> | 31 | #include <linux/timex.h> |
32 | #include <linux/capability.h> | 32 | #include <linux/capability.h> |
33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
34 | #include <linux/smp_lock.h> | ||
35 | #include <linux/syscalls.h> | 34 | #include <linux/syscalls.h> |
36 | #include <linux/security.h> | 35 | #include <linux/security.h> |
37 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
@@ -247,6 +246,36 @@ struct timespec current_fs_time(struct super_block *sb) | |||
247 | } | 246 | } |
248 | EXPORT_SYMBOL(current_fs_time); | 247 | EXPORT_SYMBOL(current_fs_time); |
249 | 248 | ||
249 | /* | ||
250 | * Convert jiffies to milliseconds and back. | ||
251 | * | ||
252 | * Avoid unnecessary multiplications/divisions in the | ||
253 | * two most common HZ cases: | ||
254 | */ | ||
255 | unsigned int inline jiffies_to_msecs(const unsigned long j) | ||
256 | { | ||
257 | #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) | ||
258 | return (MSEC_PER_SEC / HZ) * j; | ||
259 | #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) | ||
260 | return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); | ||
261 | #else | ||
262 | return (j * MSEC_PER_SEC) / HZ; | ||
263 | #endif | ||
264 | } | ||
265 | EXPORT_SYMBOL(jiffies_to_msecs); | ||
266 | |||
267 | unsigned int inline jiffies_to_usecs(const unsigned long j) | ||
268 | { | ||
269 | #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) | ||
270 | return (USEC_PER_SEC / HZ) * j; | ||
271 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) | ||
272 | return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); | ||
273 | #else | ||
274 | return (j * USEC_PER_SEC) / HZ; | ||
275 | #endif | ||
276 | } | ||
277 | EXPORT_SYMBOL(jiffies_to_usecs); | ||
278 | |||
250 | /** | 279 | /** |
251 | * timespec_trunc - Truncate timespec to a granularity | 280 | * timespec_trunc - Truncate timespec to a granularity |
252 | * @t: Timespec | 281 | * @t: Timespec |
@@ -473,36 +502,6 @@ struct timeval ns_to_timeval(const s64 nsec) | |||
473 | EXPORT_SYMBOL(ns_to_timeval); | 502 | EXPORT_SYMBOL(ns_to_timeval); |
474 | 503 | ||
475 | /* | 504 | /* |
476 | * Convert jiffies to milliseconds and back. | ||
477 | * | ||
478 | * Avoid unnecessary multiplications/divisions in the | ||
479 | * two most common HZ cases: | ||
480 | */ | ||
481 | unsigned int jiffies_to_msecs(const unsigned long j) | ||
482 | { | ||
483 | #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) | ||
484 | return (MSEC_PER_SEC / HZ) * j; | ||
485 | #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) | ||
486 | return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); | ||
487 | #else | ||
488 | return (j * MSEC_PER_SEC) / HZ; | ||
489 | #endif | ||
490 | } | ||
491 | EXPORT_SYMBOL(jiffies_to_msecs); | ||
492 | |||
493 | unsigned int jiffies_to_usecs(const unsigned long j) | ||
494 | { | ||
495 | #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) | ||
496 | return (USEC_PER_SEC / HZ) * j; | ||
497 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) | ||
498 | return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); | ||
499 | #else | ||
500 | return (j * USEC_PER_SEC) / HZ; | ||
501 | #endif | ||
502 | } | ||
503 | EXPORT_SYMBOL(jiffies_to_usecs); | ||
504 | |||
505 | /* | ||
506 | * When we convert to jiffies then we interpret incoming values | 505 | * When we convert to jiffies then we interpret incoming values |
507 | * the following way: | 506 | * the following way: |
508 | * | 507 | * |