[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 05 May 2015 02:16:39 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org, "Lars-Peter Clausen" <lars@...afoo.de>,
"Jonathan Cameron" <jic23@...nel.org>,
"Rasmus Villemoes" <linux@...musvillemoes.dk>
Subject: [PATCH 3.2 017/221] iio: imu: adis16400: Fix sign extension
3.2.69-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rasmus Villemoes <linux@...musvillemoes.dk>
commit 19e353f2b344ad86cea6ebbc0002e5f903480a90 upstream.
The intention is obviously to sign-extend a 12 bit quantity. But
because of C's promotion rules, the assignment is equivalent to "val16
&= 0xfff;". Use the proper API for this.
Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
Acked-by: Lars-Peter Clausen <lars@...afoo.de>
Signed-off-by: Jonathan Cameron <jic23@...nel.org>
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
drivers/staging/iio/imu/adis16400_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -25,6 +25,7 @@
#include <linux/sysfs.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/bitops.h>
#include "../iio.h"
#include "../sysfs.h"
@@ -541,7 +542,7 @@ static int adis16400_read_raw(struct iio
mutex_unlock(&indio_dev->mlock);
if (ret)
return ret;
- val16 = ((val16 & 0xFFF) << 4) >> 4;
+ val16 = sign_extend32(val16, 11);
*val = val16;
return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists