net: dsa: bcm_sf2: Pass GENMASK() signed bits
authorAndrew Lunn <andrew@lunn.ch>
Sun, 5 Jul 2020 20:36:25 +0000 (22:36 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 5 Jul 2020 22:45:38 +0000 (15:45 -0700)
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>
drivers/net/dsa/bcm_sf2_cfp.c

index b543394..d82cee5 100644 (file)
@@ -128,12 +128,12 @@ static inline unsigned int bcm_sf2_get_num_udf_slices(const u8 *layout)
        return count;
 }
 
-static inline u32 udf_upper_bits(unsigned int num_udf)
+static inline u32 udf_upper_bits(int num_udf)
 {
        return GENMASK(num_udf - 1, 0) >> (UDFS_PER_SLICE - 1);
 }
 
-static inline u32 udf_lower_bits(unsigned int num_udf)
+static inline u32 udf_lower_bits(int num_udf)
 {
        return (u8)GENMASK(num_udf - 1, 0);
 }