From: Irina Tirdea Date: Fri, 24 Jul 2015 13:28:05 +0000 (+0300) Subject: tools: iio: fix mask for 32 bit sensor data X-Git-Tag: firefly_0821_release~176^2~1221^2~139^2~45 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ae067cb68d2ef42d4a84eeaf07411fe2936f48c4;p=firefly-linux-kernel-4.4.55.git tools: iio: fix mask for 32 bit sensor data When the the sensor data uses 32 bits out of 32, generic_buffer prints the value 0 for all data read. In this case, the mask is shifted 32 bits, which is beyond the size of an integer. This will lead to the mask always being 0. Before printing, the mask is applied to the raw value, thus generating a final value of 0. Fix the mask by shifting a 64 bit value instead of an integer. Signed-off-by: Irina Tirdea Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 1dcdf03955cb..a95270f33353 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -168,7 +168,7 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used, if (*bits_used == 64) *mask = ~0; else - *mask = (1 << *bits_used) - 1; + *mask = (1ULL << *bits_used) - 1; *is_signed = (signchar == 's'); if (fclose(sysfsfp)) {