aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleksandr Suvorov <oleksandr.suvorov@toradex.com>2020-07-06 11:56:24 +0300
committerHauke Mehrtens <hauke@hauke-m.de>2020-08-03 22:45:44 +0200
commit2cd67f9cc0084dc772b205a40b4a3266ddd6e5a7 (patch)
tree3dfc0241ef906bef43a6dc62fd253b79ce4cae2f
parentcf0810efa9ab873467cb5a3c04deaca1394af6b6 (diff)
downloadbackports-2cd67f9cc0084dc772b205a40b4a3266ddd6e5a7.tar.gz
backports: make backports-4.18 compatible with kernel < 3.19
backports-4.18.c uses ktime_divns() function. As ktime_divns() is not exported in kernel < 3.19, this symbol will not be resolved on compat.ko loading. This commit fixes the linking issue [1]. [1] ------------------------------- WARNING: "ktime_divns" [compat/compat.ko] undefined! ------------------------------- Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
-rw-r--r--backport/compat/backport-4.18.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/backport/compat/backport-4.18.c b/backport/compat/backport-4.18.c
index c47fabe5..40551c76 100644
--- a/backport/compat/backport-4.18.c
+++ b/backport/compat/backport-4.18.c
@@ -1,11 +1,47 @@
/*
* Copyright (C) 2018 Intel Corporation
+ * Copyright (c) 2020 Toradex
*/
#include <linux/hrtimer.h>
+/*
+ * Before the commit 8b618628b2b the ktime_divns was non-exported function.
+ * Add the simple implementation of ktime_divns() to use in
+ * ktime_get_boottime_seconds().
+ */
+#if LINUX_VERSION_IS_LESS(3,19,0)
+
+#include <linux/ktime.h>
+
+#if BITS_PER_LONG < 64
+/*
+ * Divide a ktime value by a nanosecond value
+ */
+u64 ktime_divns(const ktime_t kt, s64 div)
+{
+ int sft = 0;
+ s64 dclc;
+ u64 tmp;
+
+ dclc = ktime_to_ns(kt);
+ tmp = dclc < 0 ? -dclc : dclc;
+
+ /* Make sure the divisor is less than 2^32: */
+ while (div >> 32) {
+ sft++;
+ div >>= 1;
+ }
+ tmp >>= sft;
+ do_div(tmp, (unsigned long) div);
+ return dclc < 0 ? -tmp : tmp;
+}
+#endif /* BITS_PER_LONG >= 64 */
+#endif /* < 3.19 */
+
time64_t ktime_get_boottime_seconds(void)
{
return ktime_divns(ktime_get_boottime(), NSEC_PER_SEC);
}
EXPORT_SYMBOL_GPL(ktime_get_boottime_seconds);
+