]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
lib: Import rol32 function from Linux
authorHeiko Schocher <hs@nabladev.com>
Tue, 18 Nov 2025 04:30:37 +0000 (05:30 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 4 Dec 2025 15:38:58 +0000 (09:38 -0600)
sm3 crypto algorithm uses rol32 function from linux, so
import it. Linux base was:

commit ca91b9500108:("Merge tag 'v6.15-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd")

Signed-off-by: Heiko Schocher <hs@nabladev.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
include/linux/bitops.h

index f826d7f3b34b3488f9dc9562feba79410ca75a9d..29e0da48de855b2ca6eb00d35871d1fb1282791d 100644 (file)
@@ -148,6 +148,17 @@ static inline unsigned long hweight_long(unsigned long w)
        return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w);
 }
 
+/**
+ * rol32 - rotate a 32-bit value left
+ * @word: value to rotate
+ * @shift: bits to roll
+ */
+
+static inline __u32 rol32(__u32 word, unsigned int shift)
+{
+       return (word << (shift & 31)) | (word >> ((-shift) & 31));
+}
+
 #include <asm/bitops.h>
 
 /* linux/include/asm-generic/bitops/non-atomic.h */