* [PATCH net-next 0/3] dsa: b53/sf2
@ 2020-07-05 20:36 Andrew Lunn
2020-07-05 20:36 ` [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings Andrew Lunn
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Andrew Lunn @ 2020-07-05 20:36 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Florian Fainelli, Andrew Lunn
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(-)
--
2.27.0.rc2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings
2020-07-05 20:36 [PATCH net-next 0/3] dsa: b53/sf2 Andrew Lunn
@ 2020-07-05 20:36 ` Andrew Lunn
2020-07-05 20:38 ` Florian Fainelli
2020-07-05 20:36 ` [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value Andrew Lunn
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2020-07-05 20:36 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Florian Fainelli, Andrew Lunn
leX_to_cpu() expects to be passed an __leX type.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/dsa/b53/b53_spi.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_spi.c b/drivers/net/dsa/b53/b53_spi.c
index f89f5308a99b..7abec8dab8ba 100644
--- a/drivers/net/dsa/b53/b53_spi.c
+++ b/drivers/net/dsa/b53/b53_spi.c
@@ -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;
}
--
2.27.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value
2020-07-05 20:36 [PATCH net-next 0/3] dsa: b53/sf2 Andrew Lunn
2020-07-05 20:36 ` [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings Andrew Lunn
@ 2020-07-05 20:36 ` Andrew Lunn
2020-07-05 20:38 ` Florian Fainelli
2020-07-05 20:36 ` [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits Andrew Lunn
2020-07-05 22:46 ` [PATCH net-next 0/3] dsa: b53/sf2 David Miller
3 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2020-07-05 20:36 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Florian Fainelli, 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.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/dsa/bcm_sf2_cfp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c
index f707edc641cf..b54339477853 100644
--- a/drivers/net/dsa/bcm_sf2_cfp.c
+++ b/drivers/net/dsa/bcm_sf2_cfp.c
@@ -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;
--
2.27.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits
2020-07-05 20:36 [PATCH net-next 0/3] dsa: b53/sf2 Andrew Lunn
2020-07-05 20:36 ` [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings Andrew Lunn
2020-07-05 20:36 ` [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value Andrew Lunn
@ 2020-07-05 20:36 ` Andrew Lunn
2020-07-05 20:39 ` Florian Fainelli
2020-07-05 22:46 ` [PATCH net-next 0/3] dsa: b53/sf2 David Miller
3 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2020-07-05 20:36 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Florian Fainelli, 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 <andrew@lunn.ch>
---
drivers/net/dsa/bcm_sf2_cfp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c
index b54339477853..d82cee5d9202 100644
--- a/drivers/net/dsa/bcm_sf2_cfp.c
+++ b/drivers/net/dsa/bcm_sf2_cfp.c
@@ -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);
}
--
2.27.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value
2020-07-05 20:36 ` [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value Andrew Lunn
@ 2020-07-05 20:38 ` Florian Fainelli
0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2020-07-05 20:38 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: netdev
On 7/5/2020 1:36 PM, Andrew Lunn wrote:
> 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.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
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:
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings
2020-07-05 20:36 ` [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings Andrew Lunn
@ 2020-07-05 20:38 ` Florian Fainelli
0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2020-07-05 20:38 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: netdev
On 7/5/2020 1:36 PM, Andrew Lunn wrote:
> leX_to_cpu() expects to be passed an __leX type.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits
2020-07-05 20:36 ` [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits Andrew Lunn
@ 2020-07-05 20:39 ` Florian Fainelli
0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2020-07-05 20:39 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: netdev
On 7/5/2020 1:36 PM, Andrew Lunn wrote:
> 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>
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:
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/3] dsa: b53/sf2
2020-07-05 20:36 [PATCH net-next 0/3] dsa: b53/sf2 Andrew Lunn
` (2 preceding siblings ...)
2020-07-05 20:36 ` [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits Andrew Lunn
@ 2020-07-05 22:46 ` David Miller
3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2020-07-05 22:46 UTC (permalink / raw)
To: andrew; +Cc: netdev, f.fainelli
From: Andrew Lunn <andrew@lunn.ch>
Date: Sun, 5 Jul 2020 22:36:22 +0200
> Fixup most of the C=1 W=1 warnings in these drivers.
Series applied with patch #1 and #2's subjects fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-07-05 22:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-05 20:36 [PATCH net-next 0/3] dsa: b53/sf2 Andrew Lunn
2020-07-05 20:36 ` [PATCH net-next 1/3] net: dsa: b53: Fixup endianness warnings Andrew Lunn
2020-07-05 20:38 ` Florian Fainelli
2020-07-05 20:36 ` [PATCH net-next 2/3] dsa: bcm_sf2: Initialize __be16 with a __be16 value Andrew Lunn
2020-07-05 20:38 ` Florian Fainelli
2020-07-05 20:36 ` [PATCH net-next 3/3] dsa: bmc_sf2: Pass GENMASK() signed bits Andrew Lunn
2020-07-05 20:39 ` Florian Fainelli
2020-07-05 22:46 ` [PATCH net-next 0/3] dsa: b53/sf2 David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).