Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: cy8ctmg110_ts - use endian helpers when converting data on wire

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

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210603043726.3793876-5-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+5 -6
+5 -6
drivers/input/touchscreen/cy8ctmg110_ts.c
··· 16 16 #include <linux/i2c.h> 17 17 #include <linux/gpio.h> 18 18 #include <linux/input/cy8ctmg110_pdata.h> 19 + #include <asm/byteorder.h> 19 20 20 21 #define CY8CTMG110_DRIVER_NAME "cy8ctmg110" 21 22 ··· 112 111 { 113 112 struct input_dev *input = tsc->input; 114 113 unsigned char reg_p[CY8CTMG110_REG_MAX]; 115 - int x, y; 116 114 117 115 memset(reg_p, 0, CY8CTMG110_REG_MAX); 118 116 ··· 119 119 if (cy8ctmg110_read_regs(tsc, reg_p, 9, CY8CTMG110_TOUCH_X1) != 0) 120 120 return -EIO; 121 121 122 - y = reg_p[2] << 8 | reg_p[3]; 123 - x = reg_p[0] << 8 | reg_p[1]; 124 - 125 122 /* Number of touch */ 126 123 if (reg_p[8] == 0) { 127 124 input_report_key(input, BTN_TOUCH, 0); 128 125 } else { 129 126 input_report_key(input, BTN_TOUCH, 1); 130 - input_report_abs(input, ABS_X, x); 131 - input_report_abs(input, ABS_Y, y); 127 + input_report_abs(input, ABS_X, 128 + be16_to_cpup((__be16 *)(reg_p + 0))); 129 + input_report_abs(input, ABS_Y, 130 + be16_to_cpup((__be16 *)(reg_p + 2))); 132 131 } 133 132 134 133 input_sync(input);