aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-20 01:33:38 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-04-14 02:24:42 -0400
commit252f77698fe37bdd784e514820852a3ea9827fd0 (patch)
tree771f676d49eef41ee1fb2a98c2d1a99171968124
parent95dd3b30ced3ee740e5dd92fc44515a5a6a350d4 (diff)
Input: wacom - use get_unaligned to access unaligned data
Also get rid of wacom_le16_to_cpu() and wacom_be16_to_cpu() helpers and ise le16_to_cpup() and be16_to_cpup() directly. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/tablet/wacom.h3
-rw-r--r--drivers/input/tablet/wacom_sys.c30
-rw-r--r--drivers/input/tablet/wacom_wac.c42
3 files changed, 28 insertions, 47 deletions
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 56a37074e0dd..284dfaab6b8c 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -120,7 +120,4 @@ extern const struct usb_device_id wacom_ids[];
120void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); 120void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
121void wacom_setup_input_capabilities(struct input_dev *input_dev, 121void wacom_setup_input_capabilities(struct input_dev *input_dev,
122 struct wacom_wac *wacom_wac); 122 struct wacom_wac *wacom_wac);
123__u16 wacom_le16_to_cpu(unsigned char *data);
124__u16 wacom_be16_to_cpu(unsigned char *data);
125
126#endif 123#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index c37e22b968d9..d90f4e00e51d 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -100,20 +100,6 @@ static void wacom_sys_irq(struct urb *urb)
100 __func__, retval); 100 __func__, retval);
101} 101}
102 102
103__u16 wacom_be16_to_cpu(unsigned char *data)
104{
105 __u16 value;
106 value = be16_to_cpu(*(__be16 *) data);
107 return value;
108}
109
110__u16 wacom_le16_to_cpu(unsigned char *data)
111{
112 __u16 value;
113 value = le16_to_cpu(*(__le16 *) data);
114 return value;
115}
116
117static int wacom_open(struct input_dev *dev) 103static int wacom_open(struct input_dev *dev)
118{ 104{
119 struct wacom *wacom = input_get_drvdata(dev); 105 struct wacom *wacom = input_get_drvdata(dev);
@@ -210,9 +196,9 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
210 features->device_type = BTN_TOOL_TRIPLETAP; 196 features->device_type = BTN_TOOL_TRIPLETAP;
211 } 197 }
212 features->x_max = 198 features->x_max =
213 wacom_le16_to_cpu(&report[i + 3]); 199 get_unaligned_le16(&report[i + 3]);
214 features->x_phy = 200 features->x_phy =
215 wacom_le16_to_cpu(&report[i + 6]); 201 get_unaligned_le16(&report[i + 6]);
216 features->unit = report[i + 9]; 202 features->unit = report[i + 9];
217 features->unitExpo = report[i + 11]; 203 features->unitExpo = report[i + 11];
218 i += 12; 204 i += 12;
@@ -222,7 +208,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
222 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 208 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
223 features->device_type = BTN_TOOL_PEN; 209 features->device_type = BTN_TOOL_PEN;
224 features->x_max = 210 features->x_max =
225 wacom_le16_to_cpu(&report[i + 3]); 211 get_unaligned_le16(&report[i + 3]);
226 i += 4; 212 i += 4;
227 } 213 }
228 } else if (usage == WCM_DIGITIZER) { 214 } else if (usage == WCM_DIGITIZER) {
@@ -244,15 +230,15 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
244 features->pktlen = WACOM_PKGLEN_TPC2FG; 230 features->pktlen = WACOM_PKGLEN_TPC2FG;
245 features->device_type = BTN_TOOL_TRIPLETAP; 231 features->device_type = BTN_TOOL_TRIPLETAP;
246 features->y_max = 232 features->y_max =
247 wacom_le16_to_cpu(&report[i + 3]); 233 get_unaligned_le16(&report[i + 3]);
248 features->y_phy = 234 features->y_phy =
249 wacom_le16_to_cpu(&report[i + 6]); 235 get_unaligned_le16(&report[i + 6]);
250 i += 7; 236 i += 7;
251 } else { 237 } else {
252 features->y_max = 238 features->y_max =
253 features->x_max; 239 features->x_max;
254 features->y_phy = 240 features->y_phy =
255 wacom_le16_to_cpu(&report[i + 3]); 241 get_unaligned_le16(&report[i + 3]);
256 i += 4; 242 i += 4;
257 } 243 }
258 } else if (pen) { 244 } else if (pen) {
@@ -261,7 +247,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
261 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 247 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
262 features->device_type = BTN_TOOL_PEN; 248 features->device_type = BTN_TOOL_PEN;
263 features->y_max = 249 features->y_max =
264 wacom_le16_to_cpu(&report[i + 3]); 250 get_unaligned_le16(&report[i + 3]);
265 i += 4; 251 i += 4;
266 } 252 }
267 } 253 }
@@ -280,7 +266,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
280 case HID_USAGE_UNDEFINED: 266 case HID_USAGE_UNDEFINED:
281 if (usage == WCM_DESKTOP && finger) /* capacity */ 267 if (usage == WCM_DESKTOP && finger) /* capacity */
282 features->pressure_max = 268 features->pressure_max =
283 wacom_le16_to_cpu(&report[i + 3]); 269 get_unaligned_le16(&report[i + 3]);
284 i += 4; 270 i += 4;
285 break; 271 break;
286 } 272 }
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 8163e8f06f29..950a81d7a67c 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -27,8 +27,8 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom)
27 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; 27 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
28 input_report_key(input, wacom->tool[0], 1); 28 input_report_key(input, wacom->tool[0], 1);
29 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ 29 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
30 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1])); 30 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
31 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3])); 31 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
32 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); 32 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
33 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127)); 33 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
34 input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); 34 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
@@ -43,8 +43,8 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom)
43 case 2: 43 case 2:
44 input_report_key(input, BTN_TOOL_PEN, 1); 44 input_report_key(input, BTN_TOOL_PEN, 1);
45 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ 45 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
46 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1])); 46 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
47 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3])); 47 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
48 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); 48 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
49 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); 49 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
50 input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); 50 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
@@ -150,9 +150,9 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
150 wacom->id[0] = STYLUS_DEVICE_ID; 150 wacom->id[0] = STYLUS_DEVICE_ID;
151 } 151 }
152 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ 152 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
153 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2])); 153 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
154 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4])); 154 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
155 input_report_abs(input, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); 155 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
156 input_report_key(input, BTN_STYLUS, data[1] & 0x02); 156 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
157 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 157 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
158 return 1; 158 return 1;
@@ -163,7 +163,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
163 struct wacom_features *features = &wacom->features; 163 struct wacom_features *features = &wacom->features;
164 unsigned char *data = wacom->data; 164 unsigned char *data = wacom->data;
165 struct input_dev *input = wacom->input; 165 struct input_dev *input = wacom->input;
166 int x, y, prox; 166 int prox;
167 int rw = 0; 167 int rw = 0;
168 int retval = 0; 168 int retval = 0;
169 169
@@ -197,10 +197,8 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
197 break; 197 break;
198 } 198 }
199 } 199 }
200 x = wacom_le16_to_cpu(&data[2]); 200 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
201 y = wacom_le16_to_cpu(&data[4]); 201 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
202 input_report_abs(input, ABS_X, x);
203 input_report_abs(input, ABS_Y, y);
204 if (wacom->tool[0] != BTN_TOOL_MOUSE) { 202 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
205 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8)); 203 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
206 input_report_key(input, BTN_TOUCH, data[1] & 0x01); 204 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
@@ -531,8 +529,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
531 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 529 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
532 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 530 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
533 } else { 531 } else {
534 input_report_abs(input, ABS_X, wacom_be16_to_cpu(&data[2])); 532 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
535 input_report_abs(input, ABS_Y, wacom_be16_to_cpu(&data[4])); 533 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
536 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); 534 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
537 } 535 }
538 536
@@ -661,10 +659,10 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len)
661 switch (data[0]) { 659 switch (data[0]) {
662 660
663 case WACOM_REPORT_TPC1FG: 661 case WACOM_REPORT_TPC1FG:
664 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2])); 662 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
665 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4])); 663 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
666 input_report_abs(input, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); 664 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
667 input_report_key(input, BTN_TOUCH, wacom_le16_to_cpu(&data[6])); 665 input_report_key(input, BTN_TOUCH, le16_to_cpup((__le16 *)&data[6]));
668 input_report_abs(input, ABS_MISC, wacom->id[0]); 666 input_report_abs(input, ABS_MISC, wacom->id[0]);
669 input_report_key(input, wacom->tool[0], 1); 667 input_report_key(input, wacom->tool[0], 1);
670 break; 668 break;
@@ -700,8 +698,8 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len)
700 break; 698 break;
701 } 699 }
702 } else { 700 } else {
703 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1])); 701 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
704 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3])); 702 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
705 input_report_key(input, BTN_TOUCH, 1); 703 input_report_key(input, BTN_TOUCH, 1);
706 input_report_abs(input, ABS_MISC, wacom->id[0]); 704 input_report_abs(input, ABS_MISC, wacom->id[0]);
707 input_report_key(input, wacom->tool[0], 1); 705 input_report_key(input, wacom->tool[0], 1);
@@ -772,8 +770,8 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
772 } 770 }
773 input_report_key(input, BTN_STYLUS, data[1] & 0x02); 771 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
774 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 772 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
775 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2])); 773 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
776 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4])); 774 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
777 pressure = ((data[7] & 0x01) << 8) | data[6]; 775 pressure = ((data[7] & 0x01) << 8) | data[6];
778 if (pressure < 0) 776 if (pressure < 0)
779 pressure = features->pressure_max + pressure + 1; 777 pressure = features->pressure_max + pressure + 1;