linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Nam Cao <namcaov@gmail.com>
Cc: gregkh@linuxfoundation.org, forest@alittletooquiet.net,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: vt6655: remove unnecessary type cast
Date: Mon, 30 May 2022 10:33:41 +0300	[thread overview]
Message-ID: <20220530073341.GK2146@kadam> (raw)
In-Reply-To: <20220528202831.GA129473@nam-dell>

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


  reply	other threads:[~2022-05-30  7:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28 20:28 [PATCH] staging: vt6655: remove unnecessary type cast Nam Cao
2022-05-30  7:33 ` Dan Carpenter [this message]
2022-05-30  7:40   ` Nam Cao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220530073341.GK2146@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=namcaov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).