diff mbox series

[2/3] net: macb: add port constant to fix __be16 warnings

Message ID 20230622130507.606713-3-ben.dooks@codethink.co.uk (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/3] net: macb: check constant to define and fix __be32 warnings | expand

Checks

Context Check Description
netdev/series_format warning Series does not have a cover letter; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 25 this patch: 20
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 25 this patch: 20
netdev/checkpatch warning CHECK: Unnecessary parentheses around 'tp4sp_m->pdst == MACB_PORT_MASK' CHECK: Unnecessary parentheses around 'tp4sp_m->psrc == MACB_PORT_MASK' WARNING: line length of 103 exceeds 80 columns WARNING: line length of 85 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ben Dooks June 22, 2023, 1:05 p.m. UTC
Add a constant MACB_PORT_MASK to use instead of 0xffff when checking against
ipv4 address port numbers. This allows the use of the __be16 constant and
silences the following sparse warnings:

drivers/net/ethernet/cadence/macb_main.c:3458:40: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3458:69: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3511:21: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3511:50: warning: restricted __be16 degrades to integer

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/net/ethernet/cadence/macb_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 538d4c7e023b..56e202b74bd7 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3419,6 +3419,7 @@  static int macb_get_ts_info(struct net_device *netdev,
 }
 
 #define MACB_IPV4_MASK htonl(0xFFFFFFFF)
+#define MACB_PORT_MASK htons(0xFFFF)
 
 static void gem_enable_flow_filters(struct macb *bp, bool enable)
 {
@@ -3457,7 +3458,7 @@  static void gem_enable_flow_filters(struct macb *bp, bool enable)
 		else
 			t2_scr = GEM_BFINS(CMPBEN, 0, t2_scr);
 
-		if (enable && ((tp4sp_m->psrc == 0xFFFF) || (tp4sp_m->pdst == 0xFFFF)))
+		if (enable && ((tp4sp_m->psrc == MACB_PORT_MASK) || (tp4sp_m->pdst == MACB_PORT_MASK)))
 			t2_scr = GEM_BFINS(CMPCEN, 1, t2_scr);
 		else
 			t2_scr = GEM_BFINS(CMPCEN, 0, t2_scr);
@@ -3510,7 +3511,7 @@  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 == MACB_PORT_MASK) || (tp4sp_m->pdst == MACB_PORT_MASK)) {
 		/* 3rd compare reg - source port, destination port */
 		w0 = 0;
 		w1 = 0;
@@ -3524,7 +3525,7 @@  static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
 			/* 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 */
+			if (tp4sp_m->psrc == MACB_PORT_MASK) { /* src port */
 				w0 = GEM_BFINS(T2CMP, tp4sp_v->psrc, w0);
 				w1 = GEM_BFINS(T2OFST, IPHDR_SRCPORT_OFFSET, w1);
 			} else { /* dst port */