diff mbox series

[5/7] Input: cy8ctmg110_ts - use endian helpers when converting data on wire

Message ID 20210603043726.3793876-5-dmitry.torokhov@gmail.com
State Accepted
Commit 1c68b7cfd1d4902e4e6802d18331b3ab96f124c9
Headers show
Series [1/7] Input: cy8ctmg110_ts - rely on platform code to supply interrupt | expand

Commit Message

Dmitry Torokhov June 3, 2021, 4:37 a.m. UTC
Switch to using be16_to_cpup() instead of shifting and combining data by
hand.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/cy8ctmg110_ts.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Linus Walleij June 4, 2021, 7:34 a.m. UTC | #1
On Thu, Jun 3, 2021 at 6:37 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> Switch to using be16_to_cpup() instead of shifting and combining data by

> hand.

>

> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c
index f8d7ab3b6c25..33c1360a251c 100644
--- a/drivers/input/touchscreen/cy8ctmg110_ts.c
+++ b/drivers/input/touchscreen/cy8ctmg110_ts.c
@@ -16,6 +16,7 @@ 
 #include <linux/i2c.h>
 #include <linux/gpio.h>
 #include <linux/input/cy8ctmg110_pdata.h>
+#include <asm/byteorder.h>
 
 #define CY8CTMG110_DRIVER_NAME      "cy8ctmg110"
 
@@ -111,7 +112,6 @@  static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc)
 {
 	struct input_dev *input = tsc->input;
 	unsigned char reg_p[CY8CTMG110_REG_MAX];
-	int x, y;
 
 	memset(reg_p, 0, CY8CTMG110_REG_MAX);
 
@@ -119,16 +119,15 @@  static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc)
 	if (cy8ctmg110_read_regs(tsc, reg_p, 9, CY8CTMG110_TOUCH_X1) != 0)
 		return -EIO;
 
-	y = reg_p[2] << 8 | reg_p[3];
-	x = reg_p[0] << 8 | reg_p[1];
-
 	/* Number of touch */
 	if (reg_p[8] == 0) {
 		input_report_key(input, BTN_TOUCH, 0);
 	} else  {
 		input_report_key(input, BTN_TOUCH, 1);
-		input_report_abs(input, ABS_X, x);
-		input_report_abs(input, ABS_Y, y);
+		input_report_abs(input, ABS_X,
+				 be16_to_cpup((__be16 *)(reg_p + 0)));
+		input_report_abs(input, ABS_Y,
+				 be16_to_cpup((__be16 *)(reg_p + 2)));
 	}
 
 	input_sync(input);