Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: bcm_sf2: Pass GENMASK() signed bits

Oddly, GENMASK() requires signed bit numbers, so that it can compare
them for < 0. If passed an unsigned type, we get warnings about the
test never being true. There is no danger of overflow here, udf is
always a u8, so there is plenty of space when expanding to an int.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andrew Lunn and committed by
David S. Miller
c226e271 f76b6ef1

+2 -2
+2 -2
drivers/net/dsa/bcm_sf2_cfp.c
··· 128 128 return count; 129 129 } 130 130 131 - static inline u32 udf_upper_bits(unsigned int num_udf) 131 + static inline u32 udf_upper_bits(int num_udf) 132 132 { 133 133 return GENMASK(num_udf - 1, 0) >> (UDFS_PER_SLICE - 1); 134 134 } 135 135 136 - static inline u32 udf_lower_bits(unsigned int num_udf) 136 + static inline u32 udf_lower_bits(int num_udf) 137 137 { 138 138 return (u8)GENMASK(num_udf - 1, 0); 139 139 }