diff options
author | Jason Gerecke <killertofu@gmail.com> | 2014-04-19 16:50:22 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-04-19 16:57:35 -0400 |
commit | 74b634178e5f0e2d8d2d26f308c440687930274b (patch) | |
tree | b3b2ce4e726d3e18c949f16ed6d29e5bec4f2d70 /drivers/input/tablet | |
parent | e9fc413f4a5ebd9f0f7bdf923c43191e99fc1970 (diff) |
Input: wacom - references to 'wacom->data' should use 'unsigned char*'
'wacom->data' contains raw binary data and can lead to unexpected behavior
if a byte under examination happens to have its MSB set.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Tested-by: Aaron Skomra <Aaron.Skomra@wacom.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/tablet')
-rw-r--r-- | drivers/input/tablet/wacom_wac.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 3d094c95851d..99710e9fdd6a 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -178,10 +178,9 @@ static int wacom_ptu_irq(struct wacom_wac *wacom) | |||
178 | 178 | ||
179 | static int wacom_dtu_irq(struct wacom_wac *wacom) | 179 | static int wacom_dtu_irq(struct wacom_wac *wacom) |
180 | { | 180 | { |
181 | struct wacom_features *features = &wacom->features; | 181 | unsigned char *data = wacom->data; |
182 | char *data = wacom->data; | ||
183 | struct input_dev *input = wacom->input; | 182 | struct input_dev *input = wacom->input; |
184 | int prox = data[1] & 0x20, pressure; | 183 | int prox = data[1] & 0x20; |
185 | 184 | ||
186 | dev_dbg(input->dev.parent, | 185 | dev_dbg(input->dev.parent, |
187 | "%s: received report #%d", __func__, data[0]); | 186 | "%s: received report #%d", __func__, data[0]); |
@@ -198,10 +197,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom) | |||
198 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | 197 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
199 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 198 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
200 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 199 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
201 | pressure = ((data[7] & 0x01) << 8) | data[6]; | 200 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]); |
202 | if (pressure < 0) | ||
203 | pressure = features->pressure_max + pressure + 1; | ||
204 | input_report_abs(input, ABS_PRESSURE, pressure); | ||
205 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); | 201 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
206 | if (!prox) /* out-prox */ | 202 | if (!prox) /* out-prox */ |
207 | wacom->id[0] = 0; | 203 | wacom->id[0] = 0; |
@@ -906,7 +902,7 @@ static int int_dist(int x1, int y1, int x2, int y2) | |||
906 | static int wacom_24hdt_irq(struct wacom_wac *wacom) | 902 | static int wacom_24hdt_irq(struct wacom_wac *wacom) |
907 | { | 903 | { |
908 | struct input_dev *input = wacom->input; | 904 | struct input_dev *input = wacom->input; |
909 | char *data = wacom->data; | 905 | unsigned char *data = wacom->data; |
910 | int i; | 906 | int i; |
911 | int current_num_contacts = data[61]; | 907 | int current_num_contacts = data[61]; |
912 | int contacts_to_send = 0; | 908 | int contacts_to_send = 0; |
@@ -959,7 +955,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom) | |||
959 | static int wacom_mt_touch(struct wacom_wac *wacom) | 955 | static int wacom_mt_touch(struct wacom_wac *wacom) |
960 | { | 956 | { |
961 | struct input_dev *input = wacom->input; | 957 | struct input_dev *input = wacom->input; |
962 | char *data = wacom->data; | 958 | unsigned char *data = wacom->data; |
963 | int i; | 959 | int i; |
964 | int current_num_contacts = data[2]; | 960 | int current_num_contacts = data[2]; |
965 | int contacts_to_send = 0; | 961 | int contacts_to_send = 0; |
@@ -1038,7 +1034,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom) | |||
1038 | 1034 | ||
1039 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) | 1035 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) |
1040 | { | 1036 | { |
1041 | char *data = wacom->data; | 1037 | unsigned char *data = wacom->data; |
1042 | struct input_dev *input = wacom->input; | 1038 | struct input_dev *input = wacom->input; |
1043 | bool prox; | 1039 | bool prox; |
1044 | int x = 0, y = 0; | 1040 | int x = 0, y = 0; |
@@ -1074,10 +1070,8 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) | |||
1074 | 1070 | ||
1075 | static int wacom_tpc_pen(struct wacom_wac *wacom) | 1071 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
1076 | { | 1072 | { |
1077 | struct wacom_features *features = &wacom->features; | 1073 | unsigned char *data = wacom->data; |
1078 | char *data = wacom->data; | ||
1079 | struct input_dev *input = wacom->input; | 1074 | struct input_dev *input = wacom->input; |
1080 | int pressure; | ||
1081 | bool prox = data[1] & 0x20; | 1075 | bool prox = data[1] & 0x20; |
1082 | 1076 | ||
1083 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ | 1077 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
@@ -1093,10 +1087,7 @@ static int wacom_tpc_pen(struct wacom_wac *wacom) | |||
1093 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | 1087 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
1094 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 1088 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
1095 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 1089 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
1096 | pressure = ((data[7] & 0x01) << 8) | data[6]; | 1090 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]); |
1097 | if (pressure < 0) | ||
1098 | pressure = features->pressure_max + pressure + 1; | ||
1099 | input_report_abs(input, ABS_PRESSURE, pressure); | ||
1100 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); | 1091 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
1101 | input_report_key(input, wacom->tool[0], prox); | 1092 | input_report_key(input, wacom->tool[0], prox); |
1102 | return 1; | 1093 | return 1; |
@@ -1107,7 +1098,7 @@ static int wacom_tpc_pen(struct wacom_wac *wacom) | |||
1107 | 1098 | ||
1108 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | 1099 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) |
1109 | { | 1100 | { |
1110 | char *data = wacom->data; | 1101 | unsigned char *data = wacom->data; |
1111 | 1102 | ||
1112 | dev_dbg(wacom->input->dev.parent, | 1103 | dev_dbg(wacom->input->dev.parent, |
1113 | "%s: received report #%d\n", __func__, data[0]); | 1104 | "%s: received report #%d\n", __func__, data[0]); |