Bring the structure of this file in line with Linux v7.1
lib/math/div64.c, so that future resyncs are a near-verbatim diff. No
functional change: the compiled lib/div64.o is byte-identical before and
after, verified by comparing objdump -d output for both
evb-rk3288-rk808_defconfig (32-bit, where these out-of-line helpers are
actually built) and generic-rk3576_defconfig (64-bit).
- Add the SPDX license identifier, as upstream did in commit
b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier
to files with no license").
- Demote the kernel-doc blocks on div64_u64_rem() and div64_u64() to
plain comments and drop the one on div64_s64() entirely, following
upstream commit d28a1de5d112 ("math64: favor kernel-doc from header
files"). The kernel-doc for these lands in <linux/math64.h> in a
later patch of this series; keeping it in both places would only let
the two copies drift apart.
- Guard iter_div_u64_rem() with #ifndef iter_div_u64_rem, matching
upstream, so an arch can override it the same way it can override
the other helpers here.
Two U-Boot-local deviations are kept deliberately and are now marked as
such so that the next resync does not silently drop them:
- __div64_32() carries a no_instrument_function attribute, needed
because CONFIG_TRACE builds with -finstrument-functions and this
function is reachable from tracing code via do_div().
- The includes stay as they are. <linux/compat.h> provides U-Boot's
no-op EXPORT_SYMBOL() in place of upstream's <linux/export.h>, and
<linux/kernel.h> provides abs()/abs64() in place of upstream's
<linux/math.h>, which U-Boot does not have.
The u32/u64 spelling is also left alone rather than converted to Linux's
uint32_t/uint64_t: U-Boot's <div64.h> already made the opposite choice,
and matching Linux here would make the two files inconsistent for no
benefit.
Signed-off-by: Alexey Charkov <[email protected]>
---
lib/div64.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/lib/div64.c b/lib/div64.c
index 9db7499fcd34..e3553c3956ed 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2003 Bernardo Innocenti <[email protected]>
*
@@ -27,9 +28,9 @@
#ifndef __div64_32
/*
- * Don't instrument this function as it may be called from tracing code, since
- * it needs to read the timer and this often requires calling do_div(), which
- * calls this function.
+ * U-Boot addition, not present upstream: don't instrument this function as it
+ * may be called from tracing code, since it needs to read the timer and this
+ * often requires calling do_div(), which calls this function.
*/
uint32_t __attribute__((weak, no_instrument_function)) __div64_32(u64 *n,
u32 base)
@@ -87,7 +88,7 @@ s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
EXPORT_SYMBOL(div_s64_rem);
#endif
-/**
+/*
* div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder
* @dividend: 64bit dividend
* @divisor: 64bit divisor
@@ -127,7 +128,7 @@ u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
EXPORT_SYMBOL(div64_u64_rem);
#endif
-/**
+/*
* div64_u64 - unsigned 64bit divide with 64bit divisor
* @dividend: 64bit dividend
* @divisor: 64bit divisor
@@ -161,11 +162,6 @@ u64 div64_u64(u64 dividend, u64 divisor)
EXPORT_SYMBOL(div64_u64);
#endif
-/**
- * div64_s64 - signed 64bit divide with 64bit divisor
- * @dividend: 64bit dividend
- * @divisor: 64bit divisor
- */
#ifndef div64_s64
s64 div64_s64(s64 dividend, s64 divisor)
{
@@ -190,6 +186,7 @@ EXPORT_SYMBOL(div64_s64);
* Iterative div/mod for use when dividend is not expected to be much
* bigger than divisor.
*/
+#ifndef iter_div_u64_rem
u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
{
u32 ret = 0;
@@ -210,3 +207,4 @@ u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64
*remainder)
return ret;
}
EXPORT_SYMBOL(iter_div_u64_rem);
+#endif
--
2.54.0