[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220530073341.GK2146@kadam>
Date: Mon, 30 May 2022 10:33:41 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Nam Cao <namcaov@...il.com>
Cc: gregkh@...uxfoundation.org, forest@...ttletooquiet.net,
linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev
Subject: Re: [PATCH] staging: vt6655: remove unnecessary type cast
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@...il.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
Powered by blists - more mailing lists