[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1364480189-15062-1-git-send-email-sebastien.royen@armadeus.com>
Date: Thu, 28 Mar 2013 15:16:29 +0100
From: Sebastien Royen <sebastien.royen@...il.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Bill Pemberton <wfp5p@...ginia.edu>
Cc: linux-kernel@...r.kernel.org, seb <sebastien.royen@...adeus.com>
Subject: [PATCH 1/1] Input: mma8450 - fix signed 12bits to 32bits conversion
From: seb <sebastien.royen@...adeus.com>
Event value is wrong. Should be in range -2048 to 2047, but is in range 0 to 4095.
Use s8 to int conversion and remove 0xfff mask.
Signed-off-by: Sebastien Royen <sebastien.royen@...adeus.com>
---
drivers/input/misc/mma8450.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c
index 480557f..f330969 100644
--- a/drivers/input/misc/mma8450.c
+++ b/drivers/input/misc/mma8450.c
@@ -123,9 +123,9 @@ static void mma8450_poll(struct input_polled_dev *dev)
if (ret < 0)
return;
- x = ((buf[1] << 4) & 0xff0) | (buf[0] & 0xf);
- y = ((buf[3] << 4) & 0xff0) | (buf[2] & 0xf);
- z = ((buf[5] << 4) & 0xff0) | (buf[4] & 0xf);
+ x = ((int)(s8)buf[1] << 4) | (buf[0] & 0xf);
+ y = ((int)(s8)buf[3] << 4) | (buf[2] & 0xf);
+ z = ((int)(s8)buf[5] << 4) | (buf[4] & 0xf);
input_report_abs(dev->input, ABS_X, x);
input_report_abs(dev->input, ABS_Y, y);
--
1.7.9.5
--
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