diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-03-20 01:33:38 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-04-14 02:24:42 -0400 |
commit | 252f77698fe37bdd784e514820852a3ea9827fd0 (patch) | |
tree | 771f676d49eef41ee1fb2a98c2d1a99171968124 /drivers/input/tablet/wacom_wac.c | |
parent | 95dd3b30ced3ee740e5dd92fc44515a5a6a350d4 (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>
Diffstat (limited to 'drivers/input/tablet/wacom_wac.c')
-rw-r--r-- | drivers/input/tablet/wacom_wac.c | 42 |
1 files changed, 20 insertions, 22 deletions
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; |