dsa: b53/sf2
Andrew Lunn
maintainercover dsa: b53/sf2
Fixup most of the C=1 W=1 warnings in these drivers.
Andrew Lunn (3):
net: dsa: b53: Fixup endianness warnings
dsa: bcm_sf2: Initialize __be16 with a __be16 value
dsa: bmc_sf2: Pass GENMASK() signed bits
drivers/net/dsa/b53/b53_spi.c | 26 ++++++++++++++++++-------- drivers/net/dsa/bcm_sf2_cfp.c | 8 ++++---- 2 files changed, 22 insertions(+), 12 deletions(-)
Signature · 1 line
2.27.0.rc2
Andrew Lunn
maintainerPATCH 1/3 net: dsa: b53: Fixup endianness warnings
leX_to_cpu() expects to be passed an __leX type.
--- drivers/net/dsa/b53/b53_spi.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/net/dsa/b53/b53_spi.c +18 -8
@@ -145,42 +145,52 @@ static int b53_spi_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)static int b53_spi_read16 (struct b53_device *dev,u8 page,u8 reg,u16 *val) { -int ret =b53_spi_read (dev, page, reg, (u8 *)val,2 ); +__le16 value; +int ret; + + ret =b53_spi_read (dev, page, reg, (u8 *)&value,2 );if (!ret) - *val =le16_to_cpu (*val); + *val =le16_to_cpu (value);return ret; }static int b53_spi_read32 (struct b53_device *dev,u8 page,u8 reg,u32 *val) { -int ret =b53_spi_read (dev, page, reg, (u8 *)val,4 ); +__le32 value; +int ret; + + ret =b53_spi_read (dev, page, reg, (u8 *)&value,4 );if (!ret) - *val =le32_to_cpu (*val); + *val =le32_to_cpu (value);return ret; }static int b53_spi_read48 (struct b53_device *dev,u8 page,u8 reg,u64 *val) { +__le64 value;int ret; *val =0 ; - ret =b53_spi_read (dev, page, reg, (u8 *)val,6 ); + ret =b53_spi_read (dev, page, reg, (u8 *)&value,6 );if (!ret) - *val =le64_to_cpu (*val); + *val =le64_to_cpu (value);return ret; }static int b53_spi_read64 (struct b53_device *dev,u8 page,u8 reg,u64 *val) { -int ret =b53_spi_read (dev, page, reg, (u8 *)val,8 ); +__le64 value; +int ret; + + ret =b53_spi_read (dev, page, reg, (u8 *)&value,8 );if (!ret) - *val =le64_to_cpu (*val); + *val =le64_to_cpu (value);return ret; }
Signature · 1 line
2.27.0.rc2
Re: [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings
Quoted 3 lines · Andrew Lunn
leX_to_cpu()expects to be passed an__leXtype.Signed-off-by Andrew Lunn <[email protected]>
Signature · 1 line
Florian
Andrew Lunn
maintainerPATCH 2/3 dsa: bcm_sf2: Initialize __be16 with a __be16 value
In reply to Andrew LunnA __be16 variable should be initialised with a __be16 value. So add a htons(). In this case it is pointless, given the value being assigned is 0xffff, but it stops sparse from warnings.
--- drivers/net/dsa/bcm_sf2_cfp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/bcm_sf2_cfp.c +2 -2
@@ -348,8 +348,8 @@ static int bcm_sf2_cfp_ipv4_rule_set(struct bcm_sf2_priv *priv, int port,unsigned int queue_num, struct ethtool_rx_flow_spec *fs) { + __be16 vlan_tci = 0, vlan_m_tci = htons(0xffff);struct ethtool_rx_flow_spec_input input = {}; -__be16 vlan_tci =0 , vlan_m_tci =0xffff ;const struct cfp_udf_layout *layout;unsigned int slice_num, rule_index;struct ethtool_rx_flow_rule *flow;
@@ -629,8 +629,8 @@ static int bcm_sf2_cfp_ipv6_rule_set(struct bcm_sf2_priv *priv, int port,unsigned int queue_num, struct ethtool_rx_flow_spec *fs) { + __be16 vlan_tci = 0, vlan_m_tci = htons(0xffff);struct ethtool_rx_flow_spec_input input = {}; -__be16 vlan_tci =0 , vlan_m_tci =0xffff ;unsigned int slice_num, rule_index[2 ];const struct cfp_udf_layout *layout;struct ethtool_rx_flow_rule *flow;
Signature · 1 line
2.27.0.rc2
Re: [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value
Quoted 5 lines · Andrew Lunn
A
__be16variable should be initialised with a__be16value. So add ahtons(). In this case it is pointless, given the value being assigned is0xffff, but it stops sparse from warnings.Signed-off-by Andrew Lunn <[email protected]>
The subject should be:
net: dsa: bcm_sf2: Initialize __be16 with a __be16 value
to be consistent with other commits done to the same file, with that:
Signature · 1 line
Florian
Andrew Lunn
maintainerPATCH 3/3 dsa: bmc_sf2: Pass GENMASK() signed bits
In reply to Andrew LunnOddly, 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.
--- drivers/net/dsa/bcm_sf2_cfp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/bcm_sf2_cfp.c +2 -2
@@ -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 ); }
Signature · 1 line
2.27.0.rc2
Re: [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits
Quoted 6 lines · Andrew Lunn
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 <[email protected]>
Likewise for this patch, the subject should be:
net: dsa: bcm_sf2: Pass GENMASK() signed bits
(not the typo on bmc_sf2 vs. bcm_sf2), with that fixed:
Signature · 1 line
Florian
David Miller
maintainerFrom: Andrew Lunn <[email protected]>
Date: Sun, 5 Jul 2020 22:36:22 +0200
Quoted 1 line
Fixup most of the C=1 W=1 warnings in these drivers.
Series applied with patch #1 and #2's subjects fixed.