netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 type values
@ 2023-05-19 11:25 Min-Hua Chen
  2023-05-19 11:39 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Min-Hua Chen @ 2023-05-19 11: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 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

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..eefbeea04964 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 ((p->des0 == cpu_to_le32(0xffffffff)) &&
+		    (p->des1 == cpu_to_le32(0xffffffff)))
 			return -EINVAL;
 		return 0;
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 type values
  2023-05-19 11:25 [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 type values Min-Hua Chen
@ 2023-05-19 11:39 ` Simon Horman
  2023-05-19 11:46   ` [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 Min-Hua Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2023-05-19 11:39 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 07:25:08PM +0800, Min-Hua Chen wrote:
> 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
> 
> Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>

Reviewed-by: Simon Horman <simon.horman@corigine.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..eefbeea04964 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 ((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).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32
  2023-05-19 11:39 ` Simon Horman
@ 2023-05-19 11:46   ` Min-Hua Chen
  2023-05-19 13:17     ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Min-Hua Chen @ 2023-05-19 11:46 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

>On Fri, May 19, 2023 at 07:25:08PM +0800, Min-Hua Chen wrote:
>> 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
>> 
>> Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
>
>Reviewed-by: Simon Horman <simon.horman@corigine.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..eefbeea04964 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 ((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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32
  2023-05-19 11:46   ` [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 Min-Hua Chen
@ 2023-05-19 13:17     ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-05-19 13:17 UTC (permalink / raw)
  To: Min-Hua Chen
  Cc: alexandre.torgue, davem, edumazet, joabreu, kuba,
	linux-arm-kernel, linux-kernel, linux-stm32, mcoquelin.stm32,
	netdev, pabeni, peppe.cavallaro

On Fri, May 19, 2023 at 07:46:52PM +0800, Min-Hua Chen wrote:
> [You don't often get email from minhuadotchen@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> >On Fri, May 19, 2023 at 07:25:08PM +0800, Min-Hua Chen wrote:
> >> 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
> >>
> >> Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
> >
> >Reviewed-by: Simon Horman <simon.horman@corigine.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..eefbeea04964 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 ((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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-19 13:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19 11:25 [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 type values Min-Hua Chen
2023-05-19 11:39 ` Simon Horman
2023-05-19 11:46   ` [PATCH v2] net: stmmac: compare p->des0 and p->des1 with __le32 Min-Hua Chen
2023-05-19 13:17     ` Simon Horman

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).