]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
m68k: hash: Use lower_16_bits() helper
authorGeert Uytterhoeven <geert@linux-m68k.org>
Thu, 4 Jun 2026 07:54:23 +0000 (09:54 +0200)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 8 Jun 2026 12:50:56 +0000 (14:50 +0200)
When building for m68k with CONFIG_M68000=y and C=1:

    drivers/clk/rockchip/clk-rk3528.c: note: in included file (through include/linux/hash.h, include/linux/slab.h):
    arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (18720 becomes 8720)
    arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (1e8e8 becomes e8e8)

Sparse does not realize the truncation is intentional.
Make this explicit by using the lower_16_bits() helper instead, which
also masks the unwanted bits.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605191434.PQkj2Rki-lkp@intel.com/
Reported-by: Heiko Stuebner <heiko@sntech.de>
Closes: https://lore.kernel.org/20260603213726.1025094-1-heiko@sntech.de/
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Daniel Palmer <daniel@thingy.jp>
Acked-by: Greg Ungerer <gerg@linux-m68k.org>
Link: https://patch.msgid.link/b55e9bd0532c0cad519809c86e0a8400060d75a1.1780559561.git.geert@linux-m68k.org
arch/m68k/include/asm/hash.h

index 6d0d0c893f16dd4954a8ee76ef7dcb5b0b3f527b..6dadf493706632f52872f6ac34cdab637a302ee6 100644 (file)
@@ -2,6 +2,8 @@
 #ifndef _ASM_HASH_H
 #define _ASM_HASH_H
 
+#include <linux/wordpart.h>
+
 /*
  * If CONFIG_M68000=y (original mc68000/010), this file is #included
  * to work around the lack of a MULU.L instruction.
@@ -54,7 +56,7 @@ static inline u32 __attribute_const__ __hash_32(u32 x)
        : "=&d,d" (a), "=&r,r" (b)
        : "r,roi?" (x));        /* a+b = x*0x8647 */
 
-       return ((u16)(x*0x61c8) << 16) + a + b;
+       return (lower_16_bits(x * 0x61c8) << 16) + a + b;
 }
 
 #endif /* _ASM_HASH_H */