__iter_div_u64_rem() is only split out in Linux for its vDSO header, which
has no use in U-Boot. Inline the body of the helper directly into its only
user, which is the iter_div_u64_rem() wrapper in this same file, and drop
the static inline, so that a subsequent resync of include/linux/math64.h
against Linux does not have to carry an exception for it.

include/vdso/math64.h is deliberately not created: its only other resident,
mul_u64_u32_add_u64_shr(), has no U-Boot user.

No functional change: the generated code is identical, verified by
comparing objdump -d of lib/div64.o before and after for
evb-rk3288-rk808_defconfig. The compiler was already inlining the sole
call.

iter_div_u64_rem() itself has no in-tree callers either, but it is
upstream API and is left in place.

Signed-off-by: Alexey Charkov <[email protected]>
---
 include/linux/math64.h | 19 -------------------
 lib/div64.c            | 17 ++++++++++++++++-
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/include/linux/math64.h b/include/linux/math64.h
index 70a7ee3ff1d3..eb560e3183a9 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -118,25 +118,6 @@ static inline s64 div_s64(s64 dividend, s32 divisor)
 
 u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder);
 
-static __always_inline u32
-__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
-{
-       u32 ret = 0;
-
-       while (dividend >= divisor) {
-               /* The following asm() prevents the compiler from
-                  optimising this loop into a modulo operation.  */
-               asm("" : "+rm"(dividend));
-
-               dividend -= divisor;
-               ret++;
-       }
-
-       *remainder = dividend;
-
-       return ret;
-}
-
 #ifndef mul_u32_u32
 /*
  * Many a GCC version messes this up and generates a 64x64 mult :-(
diff --git a/lib/div64.c b/lib/div64.c
index f5624279086a..9db7499fcd34 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -192,6 +192,21 @@ EXPORT_SYMBOL(div64_s64);
  */
 u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
 {
-       return __iter_div_u64_rem(dividend, divisor, remainder);
+       u32 ret = 0;
+
+       while (dividend >= divisor) {
+               /*
+                * The following asm() prevents the compiler from
+                * optimising this loop into a modulo operation.
+                */
+               asm("" : "+rm"(dividend));
+
+               dividend -= divisor;
+               ret++;
+       }
+
+       *remainder = dividend;
+
+       return ret;
 }
 EXPORT_SYMBOL(iter_div_u64_rem);

-- 
2.54.0

Reply via email to