Skip to contentSkip to conversation

net: stmmac: compare p->des0 and p->des1 with __le32 type values

PATCH Superseded Min-Hua Chen 2 participants 4 messages May 19, 2023

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: stmmac: compare p->des0 and p->des1 with __le32 type values

Use cpu_to_le32 to convert the constants to __le32 type before comparing them with p->des0 and p->des1 (they are __le32 type) and to fix following sparse warnings:

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:23: sparse: warning: restricted __le32 degrades to integer drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:50: sparse: warning: restricted __le32 degrades to integer

---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +2 -1
index 13c347ee8be9..eefbeea04964 100644
@@ -107,7 +107,8 @@ static int dwxgmac2_rx_check_timestamp(void *desc)
 	ts_valid = !(rdes3 & XGMAC_RDES3_TSD) && (rdes3 & XGMAC_RDES3_TSA);
 
 	if (likely(desc_valid && ts_valid)) {
-		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
+		if ((p->des0 == cpu_to_le32(0xffffffff)) &&
+		    (p->des1 == cpu_to_le32(0xffffffff)))
 			return -EINVAL;
 		return 0;
 	}
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Min-Hua Chen

Use cpu_to_le32 to convert the constants to __le32 type before comparing them with p->des0 and p->des1 (they are __le32 type) and to fix following sparse warnings:

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:23: sparse: warning: restricted __le32 degrades to integer drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:50: sparse: warning: restricted __le32 degrades to integer

Quoted 9 lines
---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +0 -0
index 13c347ee8be9..eefbeea04964 100644

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c static int dwxgmac2_rx_check_timestamp(void *desc) · line 111

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +2 -1
@@ -107,7 +107,8 @@ static int dwxgmac2_rx_check_timestamp(void *desc)
 	ts_valid = !(rdes3 & XGMAC_RDES3_TSD) && (rdes3 & XGMAC_RDES3_TSA);
 
 	if (likely(desc_valid && ts_valid)) {
-		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
+		if ((p->des0 == cpu_to_le32(0xffffffff)) &&
+		    (p->des1 == cpu_to_le32(0xffffffff)))

nit: Sorry for not noticing this in v1.
There are unnecessary parentheses (both before and after this change).

#2 lore raw

Re: [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32

Quoted 23 lines · Min-Hua Chen
Quoted 8 lines

Use cpu_to_le32 to convert the constants to __le32 type before comparing them with p->des0 and p->des1 (they are __le32 type) and to fix following sparse warnings:

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:23: sparse: warning: restricted __le32 degrades to integer drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:50: sparse: warning: restricted __le32 degrades to integer

Quoted 11 lines
---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +0 -0
index 13c347ee8be9..eefbeea04964 100644
@@ -107,7 +107,8 @@ static int dwxgmac2_rx_check_timestamp(void *desc)
 	ts_valid = !(rdes3 & XGMAC_RDES3_TSD) && (rdes3 & XGMAC_RDES3_TSA);
 
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c static int dwxgmac2_rx_check_timestamp(void *desc) · line 111

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +2 -1
 	if (likely(desc_valid && ts_valid)) {
-		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
+		if ((p->des0 == cpu_to_le32(0xffffffff)) &&
+		    (p->des1 == cpu_to_le32(0xffffffff)))

nit: Sorry for not noticing this in v1.
There are unnecessary parentheses (both before and after this change).

Thanks, I noticed this before submitting v2 (by checkpath.pl) but I keep the original parentheses.

I will do v3 with your Reviewed-by tag. :-)

thanks,
Min-Hua

#3 lore raw

Re: [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32

Quoted 33 lines · Min-Hua Chen

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Quoted 23 lines · Min-Hua Chen
Quoted 8 lines

Use cpu_to_le32 to convert the constants to __le32 type before comparing them with p->des0 and p->des1 (they are __le32 type) and to fix following sparse warnings:

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:23: sparse: warning: restricted __le32 degrades to integer drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:110:50: sparse: warning: restricted __le32 degrades to integer

Quoted 11 lines
---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +0 -0
index 13c347ee8be9..eefbeea04964 100644
@@ -107,7 +107,8 @@ static int dwxgmac2_rx_check_timestamp(void *desc)
     ts_valid = !(rdes3 & XGMAC_RDES3_TSD) && (rdes3 & XGMAC_RDES3_TSA);
 
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c static int dwxgmac2_rx_check_timestamp(void *desc) · line 111

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +2 -1
     if (likely(desc_valid && ts_valid)) {
-            if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
+            if ((p->des0 == cpu_to_le32(0xffffffff)) &&
+                (p->des1 == cpu_to_le32(0xffffffff)))

nit: Sorry for not noticing this in v1.
There are unnecessary parentheses (both before and after this change).

Quoted 4 lines

Thanks, I noticed this before submitting v2 (by checkpath.pl) but I keep the original parentheses.

I will do v3 with your Reviewed-by tag. :-)

Thanks.