backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] backports: make backports-4.18 compatible with kernel < 3.19
@ 2020-07-06  8:56 Oleksandr Suvorov
  2020-08-08 15:53 ` Hauke Mehrtens
  0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Suvorov @ 2020-07-06  8:56 UTC (permalink / raw)
  To: hauke, mcgrof; +Cc: backports, Oleksandr Suvorov

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>
---

 backport/compat/backport-4.18.c | 36 +++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

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);
+
-- 
2.25.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] backports: make backports-4.18 compatible with kernel < 3.19
  2020-07-06  8:56 [PATCH] backports: make backports-4.18 compatible with kernel < 3.19 Oleksandr Suvorov
@ 2020-08-08 15:53 ` Hauke Mehrtens
  0 siblings, 0 replies; 2+ messages in thread
From: Hauke Mehrtens @ 2020-08-08 15:53 UTC (permalink / raw)
  To: Oleksandr Suvorov, mcgrof; +Cc: backports


[-- Attachment #1.1: Type: text/plain, Size: 683 bytes --]

On 7/6/20 10:56 AM, Oleksandr Suvorov wrote:
> 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>
> ---
> 
>  backport/compat/backport-4.18.c | 36 +++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 

Thank you for the patches, I applied all 3 of them to master and the 5.4
branch.

Hauke


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-08 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06  8:56 [PATCH] backports: make backports-4.18 compatible with kernel < 3.19 Oleksandr Suvorov
2020-08-08 15:53 ` Hauke Mehrtens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).