dect
/
linux-2.6
Archived
13
0
Fork 0

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>
This commit is contained in:
Dmitry Torokhov 2010-03-19 22:33:38 -07:00
parent 95dd3b30ce
commit 252f77698f
3 changed files with 28 additions and 47 deletions

View File

@ -120,7 +120,4 @@ extern const struct usb_device_id wacom_ids[];
void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
void wacom_setup_input_capabilities(struct input_dev *input_dev, void wacom_setup_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac); struct wacom_wac *wacom_wac);
__u16 wacom_le16_to_cpu(unsigned char *data);
__u16 wacom_be16_to_cpu(unsigned char *data);
#endif #endif

View File

@ -100,20 +100,6 @@ static void wacom_sys_irq(struct urb *urb)
__func__, retval); __func__, retval);
} }
__u16 wacom_be16_to_cpu(unsigned char *data)
{
__u16 value;
value = be16_to_cpu(*(__be16 *) data);
return value;
}
__u16 wacom_le16_to_cpu(unsigned char *data)
{
__u16 value;
value = le16_to_cpu(*(__le16 *) data);
return value;
}
static int wacom_open(struct input_dev *dev) static int wacom_open(struct input_dev *dev)
{ {
struct wacom *wacom = input_get_drvdata(dev); struct wacom *wacom = input_get_drvdata(dev);
@ -210,9 +196,9 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
features->device_type = BTN_TOOL_TRIPLETAP; features->device_type = BTN_TOOL_TRIPLETAP;
} }
features->x_max = features->x_max =
wacom_le16_to_cpu(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->x_phy = features->x_phy =
wacom_le16_to_cpu(&report[i + 6]); get_unaligned_le16(&report[i + 6]);
features->unit = report[i + 9]; features->unit = report[i + 9];
features->unitExpo = report[i + 11]; features->unitExpo = report[i + 11];
i += 12; i += 12;
@ -222,7 +208,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
features->pktlen = WACOM_PKGLEN_GRAPHIRE; features->pktlen = WACOM_PKGLEN_GRAPHIRE;
features->device_type = BTN_TOOL_PEN; features->device_type = BTN_TOOL_PEN;
features->x_max = features->x_max =
wacom_le16_to_cpu(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
i += 4; i += 4;
} }
} else if (usage == WCM_DIGITIZER) { } else if (usage == WCM_DIGITIZER) {
@ -244,15 +230,15 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
features->pktlen = WACOM_PKGLEN_TPC2FG; features->pktlen = WACOM_PKGLEN_TPC2FG;
features->device_type = BTN_TOOL_TRIPLETAP; features->device_type = BTN_TOOL_TRIPLETAP;
features->y_max = features->y_max =
wacom_le16_to_cpu(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->y_phy = features->y_phy =
wacom_le16_to_cpu(&report[i + 6]); get_unaligned_le16(&report[i + 6]);
i += 7; i += 7;
} else { } else {
features->y_max = features->y_max =
features->x_max; features->x_max;
features->y_phy = features->y_phy =
wacom_le16_to_cpu(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
i += 4; i += 4;
} }
} else if (pen) { } else if (pen) {
@ -261,7 +247,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
features->pktlen = WACOM_PKGLEN_GRAPHIRE; features->pktlen = WACOM_PKGLEN_GRAPHIRE;
features->device_type = BTN_TOOL_PEN; features->device_type = BTN_TOOL_PEN;
features->y_max = features->y_max =
wacom_le16_to_cpu(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
i += 4; i += 4;
} }
} }
@ -280,7 +266,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
case HID_USAGE_UNDEFINED: case HID_USAGE_UNDEFINED:
if (usage == WCM_DESKTOP && finger) /* capacity */ if (usage == WCM_DESKTOP && finger) /* capacity */
features->pressure_max = features->pressure_max =
wacom_le16_to_cpu(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
i += 4; i += 4;
break; break;
} }

View File

@ -27,8 +27,8 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom)
wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
input_report_key(input, wacom->tool[0], 1); input_report_key(input, wacom->tool[0], 1);
input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1])); input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3])); input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127)); input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
@ -43,8 +43,8 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom)
case 2: case 2:
input_report_key(input, BTN_TOOL_PEN, 1); input_report_key(input, BTN_TOOL_PEN, 1);
input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1])); input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3])); input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
@ -150,9 +150,9 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
wacom->id[0] = STYLUS_DEVICE_ID; wacom->id[0] = STYLUS_DEVICE_ID;
} }
input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2])); input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4])); input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
input_report_abs(input, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
input_report_key(input, BTN_STYLUS, data[1] & 0x02); input_report_key(input, BTN_STYLUS, data[1] & 0x02);
input_report_key(input, BTN_STYLUS2, data[1] & 0x10); input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
return 1; return 1;
@ -163,7 +163,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->input;
int x, y, prox; int prox;
int rw = 0; int rw = 0;
int retval = 0; int retval = 0;
@ -197,10 +197,8 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
break; break;
} }
} }
x = wacom_le16_to_cpu(&data[2]); input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
y = wacom_le16_to_cpu(&data[4]); input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
input_report_abs(input, ABS_X, x);
input_report_abs(input, ABS_Y, y);
if (wacom->tool[0] != BTN_TOOL_MOUSE) { if (wacom->tool[0] != BTN_TOOL_MOUSE) {
input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8)); input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
input_report_key(input, BTN_TOUCH, data[1] & 0x01); input_report_key(input, BTN_TOUCH, data[1] & 0x01);
@ -531,8 +529,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
} else { } else {
input_report_abs(input, ABS_X, wacom_be16_to_cpu(&data[2])); input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
input_report_abs(input, ABS_Y, wacom_be16_to_cpu(&data[4])); input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
} }
@ -661,10 +659,10 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len)
switch (data[0]) { switch (data[0]) {
case WACOM_REPORT_TPC1FG: case WACOM_REPORT_TPC1FG:
input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2])); input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4])); input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
input_report_abs(input, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
input_report_key(input, BTN_TOUCH, wacom_le16_to_cpu(&data[6])); input_report_key(input, BTN_TOUCH, le16_to_cpup((__le16 *)&data[6]));
input_report_abs(input, ABS_MISC, wacom->id[0]); input_report_abs(input, ABS_MISC, wacom->id[0]);
input_report_key(input, wacom->tool[0], 1); input_report_key(input, wacom->tool[0], 1);
break; break;
@ -700,8 +698,8 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len)
break; break;
} }
} else { } else {
input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1])); input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3])); input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
input_report_key(input, BTN_TOUCH, 1); input_report_key(input, BTN_TOUCH, 1);
input_report_abs(input, ABS_MISC, wacom->id[0]); input_report_abs(input, ABS_MISC, wacom->id[0]);
input_report_key(input, wacom->tool[0], 1); input_report_key(input, wacom->tool[0], 1);
@ -772,8 +770,8 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
} }
input_report_key(input, BTN_STYLUS, data[1] & 0x02); input_report_key(input, BTN_STYLUS, data[1] & 0x02);
input_report_key(input, BTN_STYLUS2, data[1] & 0x10); input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2])); input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4])); input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
pressure = ((data[7] & 0x01) << 8) | data[6]; pressure = ((data[7] & 0x01) << 8) | data[6];
if (pressure < 0) if (pressure < 0)
pressure = features->pressure_max + pressure + 1; pressure = features->pressure_max + pressure + 1;