summaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorLi RongQing2019-02-28 06:13:26 +0100
committerPablo Neira Ayuso2019-04-08 22:56:14 +0200
commit3b15d09f7e6db44065aaba5fd16dc7420035c5ad (patch)
treea0c490bd2ca02e475ab4b92dc7e86092a6e0d758 /kernel/time
parentcxgb4: Don't return EAGAIN when TCAM is full. (diff)
downloadkernel-qcow2-linux-3b15d09f7e6db44065aaba5fd16dc7420035c5ad.tar.gz
kernel-qcow2-linux-3b15d09f7e6db44065aaba5fd16dc7420035c5ad.tar.xz
kernel-qcow2-linux-3b15d09f7e6db44065aaba5fd16dc7420035c5ad.zip
time: Introduce jiffies64_to_msecs()
there is a similar helper in net/netfilter/nf_tables_api.c, this maybe become a common request someday, so move it to time.c Signed-off-by: Zhang Yu <zhangyu31@baidu.com> Signed-off-by: Li RongQing <lirongqing@baidu.com> Acked-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/time.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/time/time.c b/kernel/time/time.c
index c3f756f8534b..9e3f79d4f5a8 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -783,6 +783,16 @@ u64 jiffies64_to_nsecs(u64 j)
}
EXPORT_SYMBOL(jiffies64_to_nsecs);
+u64 jiffies64_to_msecs(const u64 j)
+{
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+ return (MSEC_PER_SEC / HZ) * j;
+#else
+ return div_u64(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
+#endif
+}
+EXPORT_SYMBOL(jiffies64_to_msecs);
+
/**
* nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64
*