Re: [PATCH v2] staging: gdm724x: use different endian converters to fix sparse warnings

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

 



On Wed, Jan 04, 2017 at 12:25:55AM -0800, Eric S. Stone wrote:
> These functions require non __bitwise annotated types for both input
> and output. Changing the endian converters used from ones that operate
> on __bitwise annotated types, to those that operate on u16/u32, fixes
> these sparse warnings:
> 
> CHECK   drivers/staging/gdm724x/gdm_endian.c
> drivers/staging/gdm724x/gdm_endian.c:28:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:28:24:    expected unsigned short
> drivers/staging/gdm724x/gdm_endian.c:28:24:    got restricted __le16 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:30:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:30:24:    expected unsigned short
> drivers/staging/gdm724x/gdm_endian.c:30:24:    got restricted __be16 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:36:24: warning: cast to restricted __le16
> drivers/staging/gdm724x/gdm_endian.c:38:24: warning: cast to restricted __be16
> drivers/staging/gdm724x/gdm_endian.c:44:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:44:24:    expected unsigned int
> drivers/staging/gdm724x/gdm_endian.c:44:24:    got restricted __le32 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:46:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:46:24:    expected unsigned int
> drivers/staging/gdm724x/gdm_endian.c:46:24:    got restricted __be32 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:52:24: warning: cast to restricted __le32
> drivers/staging/gdm724x/gdm_endian.c:54:24: warning: cast to restricted __be32
> 
> Signed-off-by: Eric S. Stone <esstone@xxxxxxxxx>
> ---
> 
> Notes:
>     v1 of this patch was titled differently:
>     staging: gdm724x: add forced casts in endian converters to fix sparse warnings
> 
>  drivers/staging/gdm724x/gdm_endian.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c
> index d7144e7..db25a93 100644
> --- a/drivers/staging/gdm724x/gdm_endian.c
> +++ b/drivers/staging/gdm724x/gdm_endian.c
> @@ -25,31 +25,35 @@ void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian)
>  u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x)
>  {
>  	if (ed->dev_ed == ENDIANNESS_LITTLE)
> -		return cpu_to_le16(x);
> +		cpu_to_le16s(&x);
>  	else
> -		return cpu_to_be16(x);
> +		cpu_to_be16s(&x);
> +	return x;
>  }
>  
>  u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x)
>  {
>  	if (ed->dev_ed == ENDIANNESS_LITTLE)
> -		return le16_to_cpu(x);
> +		le16_to_cpus(&x);
>  	else
> -		return be16_to_cpu(x);
> +		be16_to_cpus(&x);
> +	return x;
>  }
>  
>  u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x)
>  {
>  	if (ed->dev_ed == ENDIANNESS_LITTLE)
> -		return cpu_to_le32(x);
> +		cpu_to_le32s(&x);
>  	else
> -		return cpu_to_be32(x);
> +		cpu_to_be32s(&x);
> +	return x;
>  }
>  
>  u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x)
>  {
>  	if (ed->dev_ed == ENDIANNESS_LITTLE)
> -		return le32_to_cpu(x);
> +		le32_to_cpus(&x);
>  	else
> -		return be32_to_cpu(x);
> +		be32_to_cpus(&x);
> +	return x;
>  }

Nah, see my response to your first version of this patch as to what
would be a bit better change here.  Although, maybe this is the better
version, no forcing involved, these functions are only called very
infrequently, and the end result you want in native cpu format.

Ugh, I don't know anymore, I need some more coffee...

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [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