]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ARM: clean up the memset64() C wrapper
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Fri, 13 Feb 2026 07:39:29 +0000 (08:39 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Feb 2026 19:15:05 +0000 (11:15 -0800)
The current logic to split the 64-bit argument into its 32-bit halves is
byte-order specific and a bit clunky.  Use a union instead which is
easier to read and works in all cases.

GCC still generates the same machine code.

While at it, rename the arguments of the __memset64() prototype to
actually reflect their semantics.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/arm/include/asm/string.h

index c35250c4991bc7b01fbdf5a460758235b2965354..96fc6cf460ecbeefd84d1d221c0b9166453a7730 100644 (file)
@@ -39,13 +39,17 @@ static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
 }
 
 #define __HAVE_ARCH_MEMSET64
-extern void *__memset64(uint64_t *, uint32_t low, __kernel_size_t, uint32_t hi);
+extern void *__memset64(uint64_t *, uint32_t first, __kernel_size_t, uint32_t second);
 static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
 {
-       if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
-               return __memset64(p, v, n * 8, v >> 32);
-       else
-               return __memset64(p, v >> 32, n * 8, v);
+       union {
+               uint64_t val;
+               struct {
+                       uint32_t first, second;
+               };
+       } word = { .val = v };
+
+       return __memset64(p, word.first, n * 8, word.second);
 }
 
 /*