* [PATCH] net: stmmac: use le32_to_cpu for p->des0 and p->des1
@ 2023-05-19 0:25 Min-Hua Chen
2023-05-19 8:01 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Min-Hua Chen @ 2023-05-19 0:25 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin
Cc: Min-Hua Chen, netdev, linux-stm32, linux-arm-kernel, linux-kernel
Use le32_to_cpu for p->des0 and p->des1 to fix the
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
Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
index 13c347ee8be9..3d094d83e975 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
@@ -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 ((le32_to_cpu(p->des0) == 0xffffffff) &&
+ (le32_to_cpu(p->des1) == 0xffffffff))
return -EINVAL;
return 0;
}
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: stmmac: use le32_to_cpu for p->des0 and p->des1
2023-05-19 0:25 [PATCH] net: stmmac: use le32_to_cpu for p->des0 and p->des1 Min-Hua Chen
@ 2023-05-19 8:01 ` Simon Horman
2023-05-19 10:53 ` Min-Hua Chen
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2023-05-19 8:01 UTC (permalink / raw)
To: Min-Hua Chen
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Fri, May 19, 2023 at 08:25:21AM +0800, Min-Hua Chen wrote:
> Use le32_to_cpu for p->des0 and p->des1 to fix the
> 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
>
> Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> index 13c347ee8be9..3d094d83e975 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> @@ -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 ((le32_to_cpu(p->des0) == 0xffffffff) &&
> + (le32_to_cpu(p->des1) == 0xffffffff))
Hi Min-Hua Chen,
I'm not sure if it makes a meaningful difference in practice - and
certainly it won't on LE systems. But I wonder if it's nicer to do the
conversion on the constant rather than the variable part of the comparison.
if ((p->des0 == cpu_to_le32(0xffffffff)) &&
(p->des1 == cpu_to_le32(0xffffffff)))
> return -EINVAL;
> return 0;
> }
> --
> 2.34.1
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: stmmac: use le32_to_cpu for p->des0 and p->des1
2023-05-19 8:01 ` Simon Horman
@ 2023-05-19 10:53 ` Min-Hua Chen
0 siblings, 0 replies; 3+ messages in thread
From: Min-Hua Chen @ 2023-05-19 10:53 UTC (permalink / raw)
To: simon.horman
Cc: alexandre.torgue, davem, edumazet, joabreu, kuba,
linux-arm-kernel, linux-kernel, linux-stm32, mcoquelin.stm32,
minhuadotchen, netdev, pabeni, peppe.cavallaro
Hi Simon,
>>
>> if (likely(desc_valid && ts_valid)) {
>> - if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
>> + if ((le32_to_cpu(p->des0) == 0xffffffff) &&
>> + (le32_to_cpu(p->des1) == 0xffffffff))
>
>Hi Min-Hua Chen,
>
>I'm not sure if it makes a meaningful difference in practice - and
>certainly it won't on LE systems. But I wonder if it's nicer to do the
>conversion on the constant rather than the variable part of the comparison.
>
> if ((p->des0 == cpu_to_le32(0xffffffff)) &&
> (p->des1 == cpu_to_le32(0xffffffff)))
After reading your suggestion, I think:
the 'p->des0 == cpu_to_le32(0xffffffff)' gives the readers a hint that
p->des0 is __le32 type and I think it is easier (for me) to understand
than 'le32_to_cpu(p->des0) == 0xffffffff'
I will submit v2 for this, thanks for your comment.
thanks,
Min-Hua
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-19 10:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19 0:25 [PATCH] net: stmmac: use le32_to_cpu for p->des0 and p->des1 Min-Hua Chen
2023-05-19 8:01 ` Simon Horman
2023-05-19 10:53 ` Min-Hua Chen
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).