[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230519221942.53942-1-minhuadotchen@gmail.com>
Date: Sat, 20 May 2023 06:19:39 +0800
From: Min-Hua Chen <minhuadotchen@...il.com>
To: Nicolas Ferre <nicolas.ferre@...rochip.com>,
Claudiu Beznea <claudiu.beznea@...rochip.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: Min-Hua Chen <minhuadotchen@...il.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] net: macb: use correct __be32 and __be16 types
This patch fixes the following sparse warnings. No functional changes.
Use cpu_to_be16() and cpu_to_be32() to convert constants before comparing
them with __be16 type of psrc/pdst and __be32 type of ip4src/ip4dst.
Apply be16_to_cpu() in GEM_BFINS().
Also, remove unnecessary parentheses reported by checkpatch.pl.
drivers/net/ethernet/cadence/macb_main.c:3448:39: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3453:39: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3458:40: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3458:69: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3483:20: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3497:20: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3511:21: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3511:50: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3517:30: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3518:30: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3525:36: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3526:38: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3529:38: sparse: warning: restricted __be16 degrades to integer
Signed-off-by: Min-Hua Chen <minhuadotchen@...il.com>
---
drivers/net/ethernet/cadence/macb_main.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 29a1199dad14..034ec42eaf6d 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3445,17 +3445,18 @@ static void gem_enable_flow_filters(struct macb *bp, bool enable)
/* only enable fields with no masking */
tp4sp_m = &(fs->m_u.tcp_ip4_spec);
- if (enable && (tp4sp_m->ip4src == 0xFFFFFFFF))
+ if (enable && tp4sp_m->ip4src == cpu_to_be32(0xFFFFFFFF))
t2_scr = GEM_BFINS(CMPAEN, 1, t2_scr);
else
t2_scr = GEM_BFINS(CMPAEN, 0, t2_scr);
- if (enable && (tp4sp_m->ip4dst == 0xFFFFFFFF))
+ if (enable && tp4sp_m->ip4dst == cpu_to_be32(0xFFFFFFFF))
t2_scr = GEM_BFINS(CMPBEN, 1, t2_scr);
else
t2_scr = GEM_BFINS(CMPBEN, 0, t2_scr);
- if (enable && ((tp4sp_m->psrc == 0xFFFF) || (tp4sp_m->pdst == 0xFFFF)))
+ if (enable && (tp4sp_m->psrc == cpu_to_be16(0xFFFF) ||
+ tp4sp_m->pdst == cpu_to_be16(0xFFFF)))
t2_scr = GEM_BFINS(CMPCEN, 1, t2_scr);
else
t2_scr = GEM_BFINS(CMPCEN, 0, t2_scr);
@@ -3480,7 +3481,7 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
tp4sp_m = &(fs->m_u.tcp_ip4_spec);
/* ignore field if any masking set */
- if (tp4sp_m->ip4src == 0xFFFFFFFF) {
+ if (tp4sp_m->ip4src == cpu_to_be32(0xFFFFFFFF)) {
/* 1st compare reg - IP source address */
w0 = 0;
w1 = 0;
@@ -3494,7 +3495,7 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
}
/* ignore field if any masking set */
- if (tp4sp_m->ip4dst == 0xFFFFFFFF) {
+ if (tp4sp_m->ip4dst == cpu_to_be32(0xFFFFFFFF)) {
/* 2nd compare reg - IP destination address */
w0 = 0;
w1 = 0;
@@ -3508,25 +3509,26 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
}
/* ignore both port fields if masking set in both */
- if ((tp4sp_m->psrc == 0xFFFF) || (tp4sp_m->pdst == 0xFFFF)) {
+ if (tp4sp_m->psrc == cpu_to_be16(0xFFFF) ||
+ tp4sp_m->pdst == cpu_to_be16(0xFFFF)) {
/* 3rd compare reg - source port, destination port */
w0 = 0;
w1 = 0;
w1 = GEM_BFINS(T2CMPOFST, GEM_T2COMPOFST_IPHDR, w1);
if (tp4sp_m->psrc == tp4sp_m->pdst) {
- w0 = GEM_BFINS(T2MASK, tp4sp_v->psrc, w0);
- w0 = GEM_BFINS(T2CMP, tp4sp_v->pdst, w0);
+ w0 = GEM_BFINS(T2MASK, be16_to_cpu(tp4sp_v->psrc), w0);
+ w0 = GEM_BFINS(T2CMP, be16_to_cpu(tp4sp_v->pdst), w0);
w1 = GEM_BFINS(T2DISMSK, 1, w1); /* 32-bit compare */
w1 = GEM_BFINS(T2OFST, IPHDR_SRCPORT_OFFSET, w1);
} else {
/* only one port definition */
w1 = GEM_BFINS(T2DISMSK, 0, w1); /* 16-bit compare */
w0 = GEM_BFINS(T2MASK, 0xFFFF, w0);
- if (tp4sp_m->psrc == 0xFFFF) { /* src port */
- w0 = GEM_BFINS(T2CMP, tp4sp_v->psrc, w0);
+ if (tp4sp_m->psrc == cpu_to_be16(0xFFFF)) { /* src port */
+ w0 = GEM_BFINS(T2CMP, be16_to_cpu(tp4sp_v->psrc), w0);
w1 = GEM_BFINS(T2OFST, IPHDR_SRCPORT_OFFSET, w1);
} else { /* dst port */
- w0 = GEM_BFINS(T2CMP, tp4sp_v->pdst, w0);
+ w0 = GEM_BFINS(T2CMP, be16_to_cpu(tp4sp_v->pdst), w0);
w1 = GEM_BFINS(T2OFST, IPHDR_DSTPORT_OFFSET, w1);
}
}
--
2.34.1
Powered by blists - more mailing lists