All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: vt6655: remove unnecessary type cast
@ 2022-05-28 20:28 Nam Cao
  2022-05-30  7:33 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Nam Cao @ 2022-05-28 20:28 UTC (permalink / raw)
  To: gregkh; +Cc: forest, linux-kernel, linux-staging

Remove le64_to_cpu(), as the type is already u64, as reported by sparse:
drivers/staging/vt6655/card.c:758:16: warning: cast to restricted __le64

Signed-off-by: Nam Cao <namcaov@gmail.com>
---
 drivers/staging/vt6655/card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index 2cde0082fc03..852300c59980 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -755,7 +755,7 @@ u64 vt6655_get_current_tsf(struct vnt_private *priv)
 		return 0;
 	low = ioread32(iobase + MAC_REG_TSFCNTR);
 	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
-	return le64_to_cpu(low + ((u64)high << 32));
+	return low + ((u64)high << 32);
 }
 
 /*
-- 
2.25.1


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

* Re: [PATCH] staging: vt6655: remove unnecessary type cast
  2022-05-28 20:28 [PATCH] staging: vt6655: remove unnecessary type cast Nam Cao
@ 2022-05-30  7:33 ` Dan Carpenter
  2022-05-30  7:40   ` Nam Cao
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2022-05-30  7:33 UTC (permalink / raw)
  To: Nam Cao; +Cc: gregkh, forest, linux-kernel, linux-staging

This is not the correct subject.  The le64_to_cpu() is not a decorative
feature which can be added or removed without affecting functionality.
This patch either fixes a bug or it introduces a bug.

On Sat, May 28, 2022 at 10:28:31PM +0200, Nam Cao wrote:
> Remove le64_to_cpu(), as the type is already u64, as reported by sparse:
> drivers/staging/vt6655/card.c:758:16: warning: cast to restricted __le64
> 
> Signed-off-by: Nam Cao <namcaov@gmail.com>
> ---
>  drivers/staging/vt6655/card.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
> index 2cde0082fc03..852300c59980 100644
> --- a/drivers/staging/vt6655/card.c
> +++ b/drivers/staging/vt6655/card.c
> @@ -755,7 +755,7 @@ u64 vt6655_get_current_tsf(struct vnt_private *priv)
>  		return 0;
>  	low = ioread32(iobase + MAC_REG_TSFCNTR);
>  	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
> -	return le64_to_cpu(low + ((u64)high << 32));
> +	return low + ((u64)high << 32);

I fee like the original code would have been more readable if it were
written as:

	return le64_to_cpu(((u64)high << 32) | low);

This seems like a correct way to combine two halves of a le64 value.  So
the original code looks correct and the patch introduces a bug.

regards,
dan carpenter


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

* Re: [PATCH] staging: vt6655: remove unnecessary type cast
  2022-05-30  7:33 ` Dan Carpenter
@ 2022-05-30  7:40   ` Nam Cao
  0 siblings, 0 replies; 3+ messages in thread
From: Nam Cao @ 2022-05-30  7:40 UTC (permalink / raw)
  To: dan.carpenter; +Cc: forest, gregkh, linux-kernel, linux-staging, namcaov

Yes, this patch is a mistake. I clarified that but I think my email
got blocked because it's html.

Sorry for wasting your time.

Best regards,
Nam

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

end of thread, other threads:[~2022-05-30  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 20:28 [PATCH] staging: vt6655: remove unnecessary type cast Nam Cao
2022-05-30  7:33 ` Dan Carpenter
2022-05-30  7:40   ` Nam Cao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.