Skip to contentSkip to conversation

dsa: b53/sf2

PATCH In review Andrew Lunn 3 participants 8 messages Jul 5, 2020

Subsystems (4)
lore
Share & tools
lore

Andrew Lunn

author maintainer
#0 lore raw

cover 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
author maintainer
#1 lore raw

PATCH 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
index f89f5308a99b..7abec8dab8ba 100644
@@ -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
author maintainer
#3 lore raw

PATCH 2/3 dsa: bcm_sf2: Initialize __be16 with a __be16 value

In reply to Andrew Lunn

A __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
index f707edc641cf..b54339477853 100644
@@ -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
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value

Quoted 5 lines · Andrew Lunn

A __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.

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
author maintainer
#5 lore raw

PATCH 3/3 dsa: bmc_sf2: Pass GENMASK() signed bits

In reply to 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.

---
 drivers/net/dsa/bcm_sf2_cfp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/bcm_sf2_cfp.c +2 -2
index b54339477853..d82cee5d9202 100644
@@ -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
Reviewed-by on v1 3/3
#6 lore raw

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.

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