]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
linux/kernel.h: Update upper_NN_bits() and lower_NN_bits() macros
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Mon, 22 Sep 2025 12:29:22 +0000 (14:29 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 3 Oct 2025 22:55:18 +0000 (16:55 -0600)
Synchronize upper_NN_bits() and lower_NN_bits() macros with Linux 6.16
commit 118d777c4cb4 ("wordpart.h: Add REPEAT_BYTE_U32()"). This fixes the
lower_32_bits() macros and assures it works with 64bit systems correctly.
This also adds 16bit variants of these macros, which will be used by the
Airoha PHY driver.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
include/linux/kernel.h

index e0443ecac8452a3d5d379aebd5919033a0be0baf..44a639a5e4e5e0447ad869f7cba5f46364fe43c9 100644 (file)
  * lower_32_bits - return bits 0-31 of a number
  * @n: the number we're accessing
  */
-#define lower_32_bits(n) ((u32)(n))
+#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
+
+/**
+ * upper_16_bits - return bits 16-31 of a number
+ * @n: the number we're accessing
+ */
+#define upper_16_bits(n) ((u16)((n) >> 16))
+
+/**
+ * lower_16_bits - return bits 0-15 of a number
+ * @n: the number we're accessing
+ */
+#define lower_16_bits(n) ((u16)((n) & 0xffff))
 
 /*
  * abs() handles unsigned and signed longs, ints, shorts and chars.  For all