Re: [PATCH 1/5] staging: iio: ad7816: fix sparse warning cast to restricted __be16

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

 



On 28/07/14 12:18, Teodora Baluta wrote:
> Fix following sparse endianness problems:
> 
>   CHECK   drivers/staging/iio/adc/ad7816.c
> drivers/staging/iio/adc/ad7816.c:93:17: warning: cast to restricted
> __be16
> drivers/staging/iio/adc/ad7816.c:93:17: warning: cast to restricted
> __be16
> drivers/staging/iio/adc/ad7816.c:93:17: warning: cast to restricted
> __be16
> drivers/staging/iio/adc/ad7816.c:93:17: warning: cast to restricted
> __be16
> 
> Signed-off-by: Teodora Baluta <teodora.baluta@xxxxxxxxx>
Hi Teodora,

There's actually a nastier problem hiding in here.  SPI requires that
the buffers passed to spi_read are in their own cache lines.
Here they are on the stack and hence this is unlikely to be true.
Cc'd Lars for info.

Also, in cases like this I'd prefer to introduce a local __be16 to
hold the value whilst it is big endian, rather than using it for both
big endian and cpu endian in different places in the code.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/adc/ad7816.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
> index 158d770..6686eac 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -90,7 +90,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)
>  		return ret;
>  	}
>  
> -	*data = be16_to_cpu(*data);
> +	be16_to_cpus(data);
>  
>  	return ret;
>  }
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux