Re: [PATCH] staging: vt6655: remove unnecessary type cast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux