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

net: dsa: bcm_sf2: cleanup bcm_sf2_cfp_rule_get() a little

This patch doesn't affect how the code works.

My static checker complains that the mask and shift doesn't make sense
because 0xffffff << 16 goes beyond the end of 32 bits. It should be
0xffff instead but the existing code won't cause runtime bugs.

Also the casting here is not needed and not consistent with the rest of
the code.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Dan Carpenter and committed by
David S. Miller
ff4cf0e5 3efa70d7

+4 -4
+4 -4
drivers/net/dsa/bcm_sf2_cfp.c
··· 441 441 nfc->fs.m_u.tcp_ip4_spec.psrc = cpu_to_be16(~0); 442 442 443 443 /* IPv4 dst [15:8] */ 444 - ipv4 = (u16)(reg & 0xff) << 8; 444 + ipv4 = (reg & 0xff) << 8; 445 445 reg = core_readl(priv, CORE_CFP_DATA_PORT(1)); 446 446 /* IPv4 dst [31:16] */ 447 - ipv4 |= (u32)((reg >> 8) & 0xffffff) << 16; 447 + ipv4 |= ((reg >> 8) & 0xffff) << 16; 448 448 /* IPv4 dst [7:0] */ 449 449 ipv4 |= (reg >> 24) & 0xff; 450 450 v4_spec->ip4dst = cpu_to_be32(ipv4); 451 451 nfc->fs.m_u.tcp_ip4_spec.ip4dst = cpu_to_be32(~0); 452 452 453 453 /* IPv4 src [15:8] */ 454 - ipv4 = (u16)(reg & 0xff) << 8; 454 + ipv4 = (reg & 0xff) << 8; 455 455 reg = core_readl(priv, CORE_CFP_DATA_PORT(0)); 456 456 457 457 if (!(reg & SLICE_VALID)) ··· 460 460 /* IPv4 src [7:0] */ 461 461 ipv4 |= (reg >> 24) & 0xff; 462 462 /* IPv4 src [31:16] */ 463 - ipv4 |= ((reg >> 8) & 0xffffff) << 16; 463 + ipv4 |= ((reg >> 8) & 0xffff) << 16; 464 464 v4_spec->ip4src = cpu_to_be32(ipv4); 465 465 nfc->fs.m_u.tcp_ip4_spec.ip4src = cpu_to_be32(~0); 466 466