diff options
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r-- | drivers/input/tablet/wacom_sys.c | 316 |
1 files changed, 109 insertions, 207 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index f46502589e4e..d90f4e00e51d 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -11,8 +11,8 @@ | |||
11 | * (at your option) any later version. | 11 | * (at your option) any later version. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "wacom.h" | ||
15 | #include "wacom_wac.h" | 14 | #include "wacom_wac.h" |
15 | #include "wacom.h" | ||
16 | 16 | ||
17 | /* defines to get HID report descriptor */ | 17 | /* defines to get HID report descriptor */ |
18 | #define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01) | 18 | #define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01) |
@@ -70,15 +70,9 @@ static int usb_set_report(struct usb_interface *intf, unsigned char type, | |||
70 | buf, size, 1000); | 70 | buf, size, 1000); |
71 | } | 71 | } |
72 | 72 | ||
73 | static struct input_dev * get_input_dev(struct wacom_combo *wcombo) | ||
74 | { | ||
75 | return wcombo->wacom->dev; | ||
76 | } | ||
77 | |||
78 | static void wacom_sys_irq(struct urb *urb) | 73 | static void wacom_sys_irq(struct urb *urb) |
79 | { | 74 | { |
80 | struct wacom *wacom = urb->context; | 75 | struct wacom *wacom = urb->context; |
81 | struct wacom_combo wcombo; | ||
82 | int retval; | 76 | int retval; |
83 | 77 | ||
84 | switch (urb->status) { | 78 | switch (urb->status) { |
@@ -96,59 +90,16 @@ static void wacom_sys_irq(struct urb *urb) | |||
96 | goto exit; | 90 | goto exit; |
97 | } | 91 | } |
98 | 92 | ||
99 | wcombo.wacom = wacom; | 93 | wacom_wac_irq(&wacom->wacom_wac, urb->actual_length); |
100 | wcombo.urb = urb; | ||
101 | |||
102 | if (wacom_wac_irq(wacom->wacom_wac, (void *)&wcombo)) | ||
103 | input_sync(get_input_dev(&wcombo)); | ||
104 | 94 | ||
105 | exit: | 95 | exit: |
106 | usb_mark_last_busy(wacom->usbdev); | 96 | usb_mark_last_busy(wacom->usbdev); |
107 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 97 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
108 | if (retval) | 98 | if (retval) |
109 | err ("%s - usb_submit_urb failed with result %d", | 99 | err ("%s - usb_submit_urb failed with result %d", |
110 | __func__, retval); | 100 | __func__, retval); |
111 | } | 101 | } |
112 | 102 | ||
113 | void wacom_report_key(void *wcombo, unsigned int key_type, int key_data) | ||
114 | { | ||
115 | input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data); | ||
116 | } | ||
117 | |||
118 | void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data) | ||
119 | { | ||
120 | input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data); | ||
121 | } | ||
122 | |||
123 | void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data) | ||
124 | { | ||
125 | input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data); | ||
126 | } | ||
127 | |||
128 | void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value) | ||
129 | { | ||
130 | input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value); | ||
131 | } | ||
132 | |||
133 | __u16 wacom_be16_to_cpu(unsigned char *data) | ||
134 | { | ||
135 | __u16 value; | ||
136 | value = be16_to_cpu(*(__be16 *) data); | ||
137 | return value; | ||
138 | } | ||
139 | |||
140 | __u16 wacom_le16_to_cpu(unsigned char *data) | ||
141 | { | ||
142 | __u16 value; | ||
143 | value = le16_to_cpu(*(__le16 *) data); | ||
144 | return value; | ||
145 | } | ||
146 | |||
147 | void wacom_input_sync(void *wcombo) | ||
148 | { | ||
149 | input_sync(get_input_dev((struct wacom_combo *)wcombo)); | ||
150 | } | ||
151 | |||
152 | static int wacom_open(struct input_dev *dev) | 103 | static int wacom_open(struct input_dev *dev) |
153 | { | 104 | { |
154 | struct wacom *wacom = input_get_drvdata(dev); | 105 | struct wacom *wacom = input_get_drvdata(dev); |
@@ -168,7 +119,7 @@ static int wacom_open(struct input_dev *dev) | |||
168 | return -EIO; | 119 | return -EIO; |
169 | } | 120 | } |
170 | 121 | ||
171 | wacom->open = 1; | 122 | wacom->open = true; |
172 | wacom->intf->needs_remote_wakeup = 1; | 123 | wacom->intf->needs_remote_wakeup = 1; |
173 | 124 | ||
174 | mutex_unlock(&wacom->lock); | 125 | mutex_unlock(&wacom->lock); |
@@ -181,128 +132,11 @@ static void wacom_close(struct input_dev *dev) | |||
181 | 132 | ||
182 | mutex_lock(&wacom->lock); | 133 | mutex_lock(&wacom->lock); |
183 | usb_kill_urb(wacom->irq); | 134 | usb_kill_urb(wacom->irq); |
184 | wacom->open = 0; | 135 | wacom->open = false; |
185 | wacom->intf->needs_remote_wakeup = 0; | 136 | wacom->intf->needs_remote_wakeup = 0; |
186 | mutex_unlock(&wacom->lock); | 137 | mutex_unlock(&wacom->lock); |
187 | } | 138 | } |
188 | 139 | ||
189 | void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
190 | { | ||
191 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_1) | | ||
192 | BIT_MASK(BTN_5); | ||
193 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); | ||
194 | } | ||
195 | |||
196 | void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
197 | { | ||
198 | input_dev->evbit[0] |= BIT_MASK(EV_MSC); | ||
199 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); | ||
200 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); | ||
201 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | | ||
202 | BIT_MASK(BTN_4); | ||
203 | } | ||
204 | |||
205 | void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
206 | { | ||
207 | input_dev->evbit[0] |= BIT_MASK(EV_REL); | ||
208 | input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); | ||
209 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) | | ||
210 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); | ||
211 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | | ||
212 | BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | | ||
213 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); | ||
214 | input_set_abs_params(input_dev, ABS_DISTANCE, | ||
215 | 0, wacom_wac->features.distance_max, 0, 0); | ||
216 | } | ||
217 | |||
218 | void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
219 | { | ||
220 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); | ||
221 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | | ||
222 | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3); | ||
223 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); | ||
224 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); | ||
225 | } | ||
226 | |||
227 | void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
228 | { | ||
229 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) | | ||
230 | BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7); | ||
231 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); | ||
232 | } | ||
233 | |||
234 | void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
235 | { | ||
236 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); | ||
237 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3); | ||
238 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) | BIT_MASK(BTN_5) | BIT_MASK(BTN_6); | ||
239 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); | ||
240 | } | ||
241 | |||
242 | void input_dev_i4(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
243 | { | ||
244 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_7) | BIT_MASK(BTN_8); | ||
245 | } | ||
246 | |||
247 | void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
248 | { | ||
249 | input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9); | ||
250 | } | ||
251 | |||
252 | void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
253 | { | ||
254 | input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL); | ||
255 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); | ||
256 | input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); | ||
257 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) | | ||
258 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) | | ||
259 | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); | ||
260 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | | ||
261 | BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | | ||
262 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | | ||
263 | BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | | ||
264 | BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); | ||
265 | input_set_abs_params(input_dev, ABS_DISTANCE, | ||
266 | 0, wacom_wac->features.distance_max, 0, 0); | ||
267 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | ||
268 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | ||
269 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); | ||
270 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); | ||
271 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); | ||
272 | } | ||
273 | |||
274 | void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
275 | { | ||
276 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | | ||
277 | BIT_MASK(BTN_STYLUS) | BIT_MASK(BTN_STYLUS2); | ||
278 | } | ||
279 | |||
280 | void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
281 | { | ||
282 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER); | ||
283 | } | ||
284 | |||
285 | void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
286 | { | ||
287 | struct wacom_features *features = &wacom_wac->features; | ||
288 | |||
289 | if (features->device_type == BTN_TOOL_DOUBLETAP || | ||
290 | features->device_type == BTN_TOOL_TRIPLETAP) { | ||
291 | input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0); | ||
292 | input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0); | ||
293 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
294 | } | ||
295 | } | ||
296 | |||
297 | void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
298 | { | ||
299 | if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) { | ||
300 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); | ||
301 | input_dev->evbit[0] |= BIT_MASK(EV_MSC); | ||
302 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, | 140 | static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, |
307 | struct wacom_features *features) | 141 | struct wacom_features *features) |
308 | { | 142 | { |
@@ -362,9 +196,9 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
362 | features->device_type = BTN_TOOL_TRIPLETAP; | 196 | features->device_type = BTN_TOOL_TRIPLETAP; |
363 | } | 197 | } |
364 | features->x_max = | 198 | features->x_max = |
365 | wacom_le16_to_cpu(&report[i + 3]); | 199 | get_unaligned_le16(&report[i + 3]); |
366 | features->x_phy = | 200 | features->x_phy = |
367 | wacom_le16_to_cpu(&report[i + 6]); | 201 | get_unaligned_le16(&report[i + 6]); |
368 | features->unit = report[i + 9]; | 202 | features->unit = report[i + 9]; |
369 | features->unitExpo = report[i + 11]; | 203 | features->unitExpo = report[i + 11]; |
370 | i += 12; | 204 | i += 12; |
@@ -374,7 +208,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
374 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | 208 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; |
375 | features->device_type = BTN_TOOL_PEN; | 209 | features->device_type = BTN_TOOL_PEN; |
376 | features->x_max = | 210 | features->x_max = |
377 | wacom_le16_to_cpu(&report[i + 3]); | 211 | get_unaligned_le16(&report[i + 3]); |
378 | i += 4; | 212 | i += 4; |
379 | } | 213 | } |
380 | } else if (usage == WCM_DIGITIZER) { | 214 | } else if (usage == WCM_DIGITIZER) { |
@@ -396,15 +230,15 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
396 | features->pktlen = WACOM_PKGLEN_TPC2FG; | 230 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
397 | features->device_type = BTN_TOOL_TRIPLETAP; | 231 | features->device_type = BTN_TOOL_TRIPLETAP; |
398 | features->y_max = | 232 | features->y_max = |
399 | wacom_le16_to_cpu(&report[i + 3]); | 233 | get_unaligned_le16(&report[i + 3]); |
400 | features->y_phy = | 234 | features->y_phy = |
401 | wacom_le16_to_cpu(&report[i + 6]); | 235 | get_unaligned_le16(&report[i + 6]); |
402 | i += 7; | 236 | i += 7; |
403 | } else { | 237 | } else { |
404 | features->y_max = | 238 | features->y_max = |
405 | features->x_max; | 239 | features->x_max; |
406 | features->y_phy = | 240 | features->y_phy = |
407 | wacom_le16_to_cpu(&report[i + 3]); | 241 | get_unaligned_le16(&report[i + 3]); |
408 | i += 4; | 242 | i += 4; |
409 | } | 243 | } |
410 | } else if (pen) { | 244 | } else if (pen) { |
@@ -413,7 +247,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
413 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | 247 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; |
414 | features->device_type = BTN_TOOL_PEN; | 248 | features->device_type = BTN_TOOL_PEN; |
415 | features->y_max = | 249 | features->y_max = |
416 | wacom_le16_to_cpu(&report[i + 3]); | 250 | get_unaligned_le16(&report[i + 3]); |
417 | i += 4; | 251 | i += 4; |
418 | } | 252 | } |
419 | } | 253 | } |
@@ -432,7 +266,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
432 | case HID_USAGE_UNDEFINED: | 266 | case HID_USAGE_UNDEFINED: |
433 | if (usage == WCM_DESKTOP && finger) /* capacity */ | 267 | if (usage == WCM_DESKTOP && finger) /* capacity */ |
434 | features->pressure_max = | 268 | features->pressure_max = |
435 | wacom_le16_to_cpu(&report[i + 3]); | 269 | get_unaligned_le16(&report[i + 3]); |
436 | i += 4; | 270 | i += 4; |
437 | break; | 271 | break; |
438 | } | 272 | } |
@@ -528,6 +362,81 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, | |||
528 | return error; | 362 | return error; |
529 | } | 363 | } |
530 | 364 | ||
365 | struct wacom_usbdev_data { | ||
366 | struct list_head list; | ||
367 | struct kref kref; | ||
368 | struct usb_device *dev; | ||
369 | struct wacom_shared shared; | ||
370 | }; | ||
371 | |||
372 | static LIST_HEAD(wacom_udev_list); | ||
373 | static DEFINE_MUTEX(wacom_udev_list_lock); | ||
374 | |||
375 | static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev) | ||
376 | { | ||
377 | struct wacom_usbdev_data *data; | ||
378 | |||
379 | list_for_each_entry(data, &wacom_udev_list, list) { | ||
380 | if (data->dev == dev) { | ||
381 | kref_get(&data->kref); | ||
382 | return data; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | return NULL; | ||
387 | } | ||
388 | |||
389 | static int wacom_add_shared_data(struct wacom_wac *wacom, | ||
390 | struct usb_device *dev) | ||
391 | { | ||
392 | struct wacom_usbdev_data *data; | ||
393 | int retval = 0; | ||
394 | |||
395 | mutex_lock(&wacom_udev_list_lock); | ||
396 | |||
397 | data = wacom_get_usbdev_data(dev); | ||
398 | if (!data) { | ||
399 | data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL); | ||
400 | if (!data) { | ||
401 | retval = -ENOMEM; | ||
402 | goto out; | ||
403 | } | ||
404 | |||
405 | kref_init(&data->kref); | ||
406 | data->dev = dev; | ||
407 | list_add_tail(&data->list, &wacom_udev_list); | ||
408 | } | ||
409 | |||
410 | wacom->shared = &data->shared; | ||
411 | |||
412 | out: | ||
413 | mutex_unlock(&wacom_udev_list_lock); | ||
414 | return retval; | ||
415 | } | ||
416 | |||
417 | static void wacom_release_shared_data(struct kref *kref) | ||
418 | { | ||
419 | struct wacom_usbdev_data *data = | ||
420 | container_of(kref, struct wacom_usbdev_data, kref); | ||
421 | |||
422 | mutex_lock(&wacom_udev_list_lock); | ||
423 | list_del(&data->list); | ||
424 | mutex_unlock(&wacom_udev_list_lock); | ||
425 | |||
426 | kfree(data); | ||
427 | } | ||
428 | |||
429 | static void wacom_remove_shared_data(struct wacom_wac *wacom) | ||
430 | { | ||
431 | struct wacom_usbdev_data *data; | ||
432 | |||
433 | if (wacom->shared) { | ||
434 | data = container_of(wacom->shared, struct wacom_usbdev_data, shared); | ||
435 | kref_put(&data->kref, wacom_release_shared_data); | ||
436 | wacom->shared = NULL; | ||
437 | } | ||
438 | } | ||
439 | |||
531 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) | 440 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) |
532 | { | 441 | { |
533 | struct usb_device *dev = interface_to_usbdev(intf); | 442 | struct usb_device *dev = interface_to_usbdev(intf); |
@@ -542,13 +451,13 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
542 | return -EINVAL; | 451 | return -EINVAL; |
543 | 452 | ||
544 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); | 453 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
545 | wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); | ||
546 | input_dev = input_allocate_device(); | 454 | input_dev = input_allocate_device(); |
547 | if (!wacom || !input_dev || !wacom_wac) { | 455 | if (!wacom || !input_dev) { |
548 | error = -ENOMEM; | 456 | error = -ENOMEM; |
549 | goto fail1; | 457 | goto fail1; |
550 | } | 458 | } |
551 | 459 | ||
460 | wacom_wac = &wacom->wacom_wac; | ||
552 | wacom_wac->features = *((struct wacom_features *)id->driver_info); | 461 | wacom_wac->features = *((struct wacom_features *)id->driver_info); |
553 | features = &wacom_wac->features; | 462 | features = &wacom_wac->features; |
554 | if (features->pktlen > WACOM_PKGLEN_MAX) { | 463 | if (features->pktlen > WACOM_PKGLEN_MAX) { |
@@ -570,20 +479,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
570 | } | 479 | } |
571 | 480 | ||
572 | wacom->usbdev = dev; | 481 | wacom->usbdev = dev; |
573 | wacom->dev = input_dev; | ||
574 | wacom->intf = intf; | 482 | wacom->intf = intf; |
575 | mutex_init(&wacom->lock); | 483 | mutex_init(&wacom->lock); |
576 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | 484 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); |
577 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | 485 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); |
578 | 486 | ||
579 | usb_to_input_id(dev, &input_dev->id); | 487 | wacom_wac->input = input_dev; |
580 | |||
581 | input_dev->dev.parent = &intf->dev; | ||
582 | |||
583 | input_set_drvdata(input_dev, wacom); | ||
584 | |||
585 | input_dev->open = wacom_open; | ||
586 | input_dev->close = wacom_close; | ||
587 | 488 | ||
588 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 489 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
589 | 490 | ||
@@ -600,20 +501,21 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
600 | features->device_type == BTN_TOOL_PEN ? | 501 | features->device_type == BTN_TOOL_PEN ? |
601 | " Pen" : " Finger", | 502 | " Pen" : " Finger", |
602 | sizeof(wacom_wac->name)); | 503 | sizeof(wacom_wac->name)); |
504 | |||
505 | error = wacom_add_shared_data(wacom_wac, dev); | ||
506 | if (error) | ||
507 | goto fail3; | ||
603 | } | 508 | } |
604 | 509 | ||
605 | input_dev->name = wacom_wac->name; | 510 | input_dev->name = wacom_wac->name; |
606 | wacom->wacom_wac = wacom_wac; | 511 | input_dev->name = wacom_wac->name; |
607 | 512 | input_dev->dev.parent = &intf->dev; | |
608 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 513 | input_dev->open = wacom_open; |
609 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); | 514 | input_dev->close = wacom_close; |
610 | 515 | usb_to_input_id(dev, &input_dev->id); | |
611 | input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0); | 516 | input_set_drvdata(input_dev, wacom); |
612 | input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0); | ||
613 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0); | ||
614 | input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); | ||
615 | 517 | ||
616 | wacom_init_input_dev(input_dev, wacom_wac); | 518 | wacom_setup_input_capabilities(input_dev, wacom_wac); |
617 | 519 | ||
618 | usb_fill_int_urb(wacom->irq, dev, | 520 | usb_fill_int_urb(wacom->irq, dev, |
619 | usb_rcvintpipe(dev, endpoint->bEndpointAddress), | 521 | usb_rcvintpipe(dev, endpoint->bEndpointAddress), |
@@ -622,9 +524,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
622 | wacom->irq->transfer_dma = wacom->data_dma; | 524 | wacom->irq->transfer_dma = wacom->data_dma; |
623 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 525 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
624 | 526 | ||
625 | error = input_register_device(wacom->dev); | 527 | error = input_register_device(input_dev); |
626 | if (error) | 528 | if (error) |
627 | goto fail3; | 529 | goto fail4; |
628 | 530 | ||
629 | /* Note that if query fails it is not a hard failure */ | 531 | /* Note that if query fails it is not a hard failure */ |
630 | wacom_query_tablet_data(intf, features); | 532 | wacom_query_tablet_data(intf, features); |
@@ -632,11 +534,11 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
632 | usb_set_intfdata(intf, wacom); | 534 | usb_set_intfdata(intf, wacom); |
633 | return 0; | 535 | return 0; |
634 | 536 | ||
537 | fail4: wacom_remove_shared_data(wacom_wac); | ||
635 | fail3: usb_free_urb(wacom->irq); | 538 | fail3: usb_free_urb(wacom->irq); |
636 | fail2: usb_buffer_free(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); | 539 | fail2: usb_buffer_free(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); |
637 | fail1: input_free_device(input_dev); | 540 | fail1: input_free_device(input_dev); |
638 | kfree(wacom); | 541 | kfree(wacom); |
639 | kfree(wacom_wac); | ||
640 | return error; | 542 | return error; |
641 | } | 543 | } |
642 | 544 | ||
@@ -647,11 +549,11 @@ static void wacom_disconnect(struct usb_interface *intf) | |||
647 | usb_set_intfdata(intf, NULL); | 549 | usb_set_intfdata(intf, NULL); |
648 | 550 | ||
649 | usb_kill_urb(wacom->irq); | 551 | usb_kill_urb(wacom->irq); |
650 | input_unregister_device(wacom->dev); | 552 | input_unregister_device(wacom->wacom_wac.input); |
651 | usb_free_urb(wacom->irq); | 553 | usb_free_urb(wacom->irq); |
652 | usb_buffer_free(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, | 554 | usb_buffer_free(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, |
653 | wacom->wacom_wac->data, wacom->data_dma); | 555 | wacom->wacom_wac.data, wacom->data_dma); |
654 | kfree(wacom->wacom_wac); | 556 | wacom_remove_shared_data(&wacom->wacom_wac); |
655 | kfree(wacom); | 557 | kfree(wacom); |
656 | } | 558 | } |
657 | 559 | ||
@@ -669,7 +571,7 @@ static int wacom_suspend(struct usb_interface *intf, pm_message_t message) | |||
669 | static int wacom_resume(struct usb_interface *intf) | 571 | static int wacom_resume(struct usb_interface *intf) |
670 | { | 572 | { |
671 | struct wacom *wacom = usb_get_intfdata(intf); | 573 | struct wacom *wacom = usb_get_intfdata(intf); |
672 | struct wacom_features *features = &wacom->wacom_wac->features; | 574 | struct wacom_features *features = &wacom->wacom_wac.features; |
673 | int rv; | 575 | int rv; |
674 | 576 | ||
675 | mutex_lock(&wacom->lock); | 577 | mutex_lock(&wacom->lock); |