2 * drivers/input/tablet/wacom_sys.c
4 * USB Wacom tablet support - system specific code
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include "wacom_wac.h"
17 /* defines to get HID report descriptor */
18 #define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
19 #define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
20 #define HID_USAGE_UNDEFINED 0x00
21 #define HID_USAGE_PAGE 0x05
22 #define HID_USAGE_PAGE_DIGITIZER 0x0d
23 #define HID_USAGE_PAGE_DESKTOP 0x01
24 #define HID_USAGE 0x09
25 #define HID_USAGE_X 0x30
26 #define HID_USAGE_Y 0x31
27 #define HID_USAGE_X_TILT 0x3d
28 #define HID_USAGE_Y_TILT 0x3e
29 #define HID_USAGE_FINGER 0x22
30 #define HID_USAGE_STYLUS 0x20
31 #define HID_COLLECTION 0xc0
39 struct hid_descriptor
{
40 struct usb_descriptor_header header
;
45 __le16 wDescriptorLength
;
46 } __attribute__ ((packed
));
48 /* defines to get/set USB message */
49 #define USB_REQ_GET_REPORT 0x01
50 #define USB_REQ_SET_REPORT 0x09
52 #define WAC_HID_FEATURE_REPORT 0x03
53 #define WAC_MSG_RETRIES 5
55 #define WAC_CMD_LED_CONTROL 0x20
56 #define WAC_CMD_ICON_START 0x21
57 #define WAC_CMD_ICON_XFER 0x23
58 #define WAC_CMD_RETRIES 10
60 static int wacom_get_report(struct usb_interface
*intf
, u8 type
, u8 id
,
61 void *buf
, size_t size
, unsigned int retries
)
63 struct usb_device
*dev
= interface_to_usbdev(intf
);
67 retval
= usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
69 USB_DIR_IN
| USB_TYPE_CLASS
|
72 intf
->altsetting
[0].desc
.bInterfaceNumber
,
74 } while ((retval
== -ETIMEDOUT
|| retval
== -EPIPE
) && --retries
);
79 static int wacom_set_report(struct usb_interface
*intf
, u8 type
, u8 id
,
80 void *buf
, size_t size
, unsigned int retries
)
82 struct usb_device
*dev
= interface_to_usbdev(intf
);
86 retval
= usb_control_msg(dev
, usb_sndctrlpipe(dev
, 0),
88 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
,
90 intf
->altsetting
[0].desc
.bInterfaceNumber
,
92 } while ((retval
== -ETIMEDOUT
|| retval
== -EPIPE
) && --retries
);
97 static void wacom_sys_irq(struct urb
*urb
)
99 struct wacom
*wacom
= urb
->context
;
102 switch (urb
->status
) {
109 /* this urb is terminated, clean up */
110 dbg("%s - urb shutting down with status: %d", __func__
, urb
->status
);
113 dbg("%s - nonzero urb status received: %d", __func__
, urb
->status
);
117 wacom_wac_irq(&wacom
->wacom_wac
, urb
->actual_length
);
120 usb_mark_last_busy(wacom
->usbdev
);
121 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
123 err ("%s - usb_submit_urb failed with result %d",
127 static int wacom_open(struct input_dev
*dev
)
129 struct wacom
*wacom
= input_get_drvdata(dev
);
132 if (usb_autopm_get_interface(wacom
->intf
) < 0)
135 mutex_lock(&wacom
->lock
);
137 if (usb_submit_urb(wacom
->irq
, GFP_KERNEL
)) {
143 wacom
->intf
->needs_remote_wakeup
= 1;
146 mutex_unlock(&wacom
->lock
);
147 usb_autopm_put_interface(wacom
->intf
);
151 static void wacom_close(struct input_dev
*dev
)
153 struct wacom
*wacom
= input_get_drvdata(dev
);
156 autopm_error
= usb_autopm_get_interface(wacom
->intf
);
158 mutex_lock(&wacom
->lock
);
159 usb_kill_urb(wacom
->irq
);
161 wacom
->intf
->needs_remote_wakeup
= 0;
162 mutex_unlock(&wacom
->lock
);
165 usb_autopm_put_interface(wacom
->intf
);
168 static int wacom_parse_hid(struct usb_interface
*intf
, struct hid_descriptor
*hid_desc
,
169 struct wacom_features
*features
)
171 struct usb_device
*dev
= interface_to_usbdev(intf
);
173 /* result has to be defined as int for some devices */
175 int i
= 0, usage
= WCM_UNDEFINED
, finger
= 0, pen
= 0;
176 unsigned char *report
;
178 report
= kzalloc(hid_desc
->wDescriptorLength
, GFP_KERNEL
);
182 /* retrive report descriptors */
184 result
= usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
185 USB_REQ_GET_DESCRIPTOR
,
186 USB_RECIP_INTERFACE
| USB_DIR_IN
,
187 HID_DEVICET_REPORT
<< 8,
188 intf
->altsetting
[0].desc
.bInterfaceNumber
, /* interface */
190 hid_desc
->wDescriptorLength
,
192 } while (result
< 0 && limit
++ < WAC_MSG_RETRIES
);
194 /* No need to parse the Descriptor. It isn't an error though */
198 for (i
= 0; i
< hid_desc
->wDescriptorLength
; i
++) {
202 switch (report
[i
+ 1]) {
203 case HID_USAGE_PAGE_DIGITIZER
:
204 usage
= WCM_DIGITIZER
;
208 case HID_USAGE_PAGE_DESKTOP
:
216 switch (report
[i
+ 1]) {
218 if (usage
== WCM_DESKTOP
) {
220 features
->device_type
= BTN_TOOL_FINGER
;
221 if (features
->type
== TABLETPC2FG
) {
222 /* need to reset back */
223 features
->pktlen
= WACOM_PKGLEN_TPC2FG
;
224 features
->device_type
= BTN_TOOL_DOUBLETAP
;
226 if (features
->type
== BAMBOO_PT
) {
227 /* need to reset back */
228 features
->pktlen
= WACOM_PKGLEN_BBTOUCH
;
229 features
->device_type
= BTN_TOOL_DOUBLETAP
;
231 get_unaligned_le16(&report
[i
+ 5]);
233 get_unaligned_le16(&report
[i
+ 8]);
237 get_unaligned_le16(&report
[i
+ 3]);
239 get_unaligned_le16(&report
[i
+ 6]);
240 features
->unit
= report
[i
+ 9];
241 features
->unitExpo
= report
[i
+ 11];
245 /* penabled only accepts exact bytes of data */
246 if (features
->type
== TABLETPC2FG
)
247 features
->pktlen
= WACOM_PKGLEN_GRAPHIRE
;
248 if (features
->type
== BAMBOO_PT
)
249 features
->pktlen
= WACOM_PKGLEN_BBFUN
;
250 features
->device_type
= BTN_TOOL_PEN
;
252 get_unaligned_le16(&report
[i
+ 3]);
255 } else if (usage
== WCM_DIGITIZER
) {
256 /* max pressure isn't reported
257 features->pressure_max = (unsigned short)
258 (report[i+4] << 8 | report[i + 3]);
260 features
->pressure_max
= 255;
266 if (usage
== WCM_DESKTOP
) {
268 features
->device_type
= BTN_TOOL_FINGER
;
269 if (features
->type
== TABLETPC2FG
) {
270 /* need to reset back */
271 features
->pktlen
= WACOM_PKGLEN_TPC2FG
;
272 features
->device_type
= BTN_TOOL_DOUBLETAP
;
274 get_unaligned_le16(&report
[i
+ 3]);
276 get_unaligned_le16(&report
[i
+ 6]);
278 } else if (features
->type
== BAMBOO_PT
) {
279 /* need to reset back */
280 features
->pktlen
= WACOM_PKGLEN_BBTOUCH
;
281 features
->device_type
= BTN_TOOL_DOUBLETAP
;
283 get_unaligned_le16(&report
[i
+ 3]);
285 get_unaligned_le16(&report
[i
+ 6]);
291 get_unaligned_le16(&report
[i
+ 3]);
295 /* penabled only accepts exact bytes of data */
296 if (features
->type
== TABLETPC2FG
)
297 features
->pktlen
= WACOM_PKGLEN_GRAPHIRE
;
298 if (features
->type
== BAMBOO_PT
)
299 features
->pktlen
= WACOM_PKGLEN_BBFUN
;
300 features
->device_type
= BTN_TOOL_PEN
;
302 get_unaligned_le16(&report
[i
+ 3]);
308 case HID_USAGE_FINGER
:
313 case HID_USAGE_STYLUS
:
318 case HID_USAGE_UNDEFINED
:
319 if (usage
== WCM_DESKTOP
&& finger
) /* capacity */
320 features
->pressure_max
=
321 get_unaligned_le16(&report
[i
+ 3]);
328 /* reset UsagePage and Finger */
340 static int wacom_query_tablet_data(struct usb_interface
*intf
, struct wacom_features
*features
)
342 unsigned char *rep_data
;
343 int limit
= 0, report_id
= 2;
346 rep_data
= kmalloc(4, GFP_KERNEL
);
350 /* ask to report tablet data if it is MT Tablet PC or
352 if (features
->type
== TABLETPC2FG
) {
359 error
= wacom_set_report(intf
, WAC_HID_FEATURE_REPORT
,
360 report_id
, rep_data
, 4, 1);
362 error
= wacom_get_report(intf
,
363 WAC_HID_FEATURE_REPORT
,
364 report_id
, rep_data
, 4, 1);
365 } while ((error
< 0 || rep_data
[1] != 4) && limit
++ < WAC_MSG_RETRIES
);
366 } else if (features
->type
!= TABLETPC
&&
367 features
->device_type
== BTN_TOOL_PEN
) {
371 error
= wacom_set_report(intf
, WAC_HID_FEATURE_REPORT
,
372 report_id
, rep_data
, 2, 1);
374 error
= wacom_get_report(intf
,
375 WAC_HID_FEATURE_REPORT
,
376 report_id
, rep_data
, 2, 1);
377 } while ((error
< 0 || rep_data
[1] != 2) && limit
++ < WAC_MSG_RETRIES
);
382 return error
< 0 ? error
: 0;
385 static int wacom_retrieve_hid_descriptor(struct usb_interface
*intf
,
386 struct wacom_features
*features
)
389 struct usb_host_interface
*interface
= intf
->cur_altsetting
;
390 struct hid_descriptor
*hid_desc
;
392 /* default features */
393 features
->device_type
= BTN_TOOL_PEN
;
394 features
->x_fuzz
= 4;
395 features
->y_fuzz
= 4;
396 features
->pressure_fuzz
= 0;
397 features
->distance_fuzz
= 0;
399 /* only Tablet PCs and Bamboo P&T need to retrieve the info */
400 if ((features
->type
!= TABLETPC
) && (features
->type
!= TABLETPC2FG
) &&
401 (features
->type
!= BAMBOO_PT
))
404 if (usb_get_extra_descriptor(interface
, HID_DEVICET_HID
, &hid_desc
)) {
405 if (usb_get_extra_descriptor(&interface
->endpoint
[0],
406 HID_DEVICET_REPORT
, &hid_desc
)) {
407 printk("wacom: can not retrieve extra class descriptor\n");
412 error
= wacom_parse_hid(intf
, hid_desc
, features
);
420 struct wacom_usbdev_data
{
421 struct list_head list
;
423 struct usb_device
*dev
;
424 struct wacom_shared shared
;
427 static LIST_HEAD(wacom_udev_list
);
428 static DEFINE_MUTEX(wacom_udev_list_lock
);
430 static struct wacom_usbdev_data
*wacom_get_usbdev_data(struct usb_device
*dev
)
432 struct wacom_usbdev_data
*data
;
434 list_for_each_entry(data
, &wacom_udev_list
, list
) {
435 if (data
->dev
== dev
) {
436 kref_get(&data
->kref
);
444 static int wacom_add_shared_data(struct wacom_wac
*wacom
,
445 struct usb_device
*dev
)
447 struct wacom_usbdev_data
*data
;
450 mutex_lock(&wacom_udev_list_lock
);
452 data
= wacom_get_usbdev_data(dev
);
454 data
= kzalloc(sizeof(struct wacom_usbdev_data
), GFP_KERNEL
);
460 kref_init(&data
->kref
);
462 list_add_tail(&data
->list
, &wacom_udev_list
);
465 wacom
->shared
= &data
->shared
;
468 mutex_unlock(&wacom_udev_list_lock
);
472 static void wacom_release_shared_data(struct kref
*kref
)
474 struct wacom_usbdev_data
*data
=
475 container_of(kref
, struct wacom_usbdev_data
, kref
);
477 mutex_lock(&wacom_udev_list_lock
);
478 list_del(&data
->list
);
479 mutex_unlock(&wacom_udev_list_lock
);
484 static void wacom_remove_shared_data(struct wacom_wac
*wacom
)
486 struct wacom_usbdev_data
*data
;
489 data
= container_of(wacom
->shared
, struct wacom_usbdev_data
, shared
);
490 kref_put(&data
->kref
, wacom_release_shared_data
);
491 wacom
->shared
= NULL
;
495 static int wacom_led_control(struct wacom
*wacom
)
500 buf
= kzalloc(9, GFP_KERNEL
);
504 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
)
505 led
= (wacom
->led
.select
[1] << 4) | 0x40;
507 led
|= wacom
->led
.select
[0] | 0x4;
509 buf
[0] = WAC_CMD_LED_CONTROL
;
511 buf
[2] = wacom
->led
.llv
;
512 buf
[3] = wacom
->led
.hlv
;
513 buf
[4] = wacom
->led
.img_lum
;
515 retval
= wacom_set_report(wacom
->intf
, 0x03, WAC_CMD_LED_CONTROL
,
516 buf
, 9, WAC_CMD_RETRIES
);
522 static int wacom_led_putimage(struct wacom
*wacom
, int button_id
, const void *img
)
527 buf
= kzalloc(259, GFP_KERNEL
);
531 /* Send 'start' command */
532 buf
[0] = WAC_CMD_ICON_START
;
534 retval
= wacom_set_report(wacom
->intf
, 0x03, WAC_CMD_ICON_START
,
535 buf
, 2, WAC_CMD_RETRIES
);
539 buf
[0] = WAC_CMD_ICON_XFER
;
540 buf
[1] = button_id
& 0x07;
541 for (i
= 0; i
< 4; i
++) {
543 memcpy(buf
+ 3, img
+ i
* 256, 256);
545 retval
= wacom_set_report(wacom
->intf
, 0x03, WAC_CMD_ICON_XFER
,
546 buf
, 259, WAC_CMD_RETRIES
);
552 buf
[0] = WAC_CMD_ICON_START
;
554 wacom_set_report(wacom
->intf
, 0x03, WAC_CMD_ICON_START
,
555 buf
, 2, WAC_CMD_RETRIES
);
562 static ssize_t
wacom_led_select_store(struct device
*dev
, int set_id
,
563 const char *buf
, size_t count
)
565 struct wacom
*wacom
= dev_get_drvdata(dev
);
569 err
= kstrtouint(buf
, 10, &id
);
573 mutex_lock(&wacom
->lock
);
575 wacom
->led
.select
[set_id
] = id
& 0x3;
576 err
= wacom_led_control(wacom
);
578 mutex_unlock(&wacom
->lock
);
580 return err
< 0 ? err
: count
;
583 #define DEVICE_LED_SELECT_ATTR(SET_ID) \
584 static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
585 struct device_attribute *attr, const char *buf, size_t count) \
587 return wacom_led_select_store(dev, SET_ID, buf, count); \
589 static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
590 struct device_attribute *attr, char *buf) \
592 struct wacom *wacom = dev_get_drvdata(dev); \
593 return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
595 static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
596 wacom_led##SET_ID##_select_show, \
597 wacom_led##SET_ID##_select_store)
599 DEVICE_LED_SELECT_ATTR(0);
600 DEVICE_LED_SELECT_ATTR(1);
602 static ssize_t
wacom_luminance_store(struct wacom
*wacom
, u8
*dest
,
603 const char *buf
, size_t count
)
608 err
= kstrtouint(buf
, 10, &value
);
612 mutex_lock(&wacom
->lock
);
614 *dest
= value
& 0x7f;
615 err
= wacom_led_control(wacom
);
617 mutex_unlock(&wacom
->lock
);
619 return err
< 0 ? err
: count
;
622 #define DEVICE_LUMINANCE_ATTR(name, field) \
623 static ssize_t wacom_##name##_luminance_store(struct device *dev, \
624 struct device_attribute *attr, const char *buf, size_t count) \
626 struct wacom *wacom = dev_get_drvdata(dev); \
628 return wacom_luminance_store(wacom, &wacom->led.field, \
631 static DEVICE_ATTR(name##_luminance, S_IWUSR, \
632 NULL, wacom_##name##_luminance_store)
634 DEVICE_LUMINANCE_ATTR(status0
, llv
);
635 DEVICE_LUMINANCE_ATTR(status1
, hlv
);
636 DEVICE_LUMINANCE_ATTR(buttons
, img_lum
);
638 static ssize_t
wacom_button_image_store(struct device
*dev
, int button_id
,
639 const char *buf
, size_t count
)
641 struct wacom
*wacom
= dev_get_drvdata(dev
);
647 mutex_lock(&wacom
->lock
);
649 err
= wacom_led_putimage(wacom
, button_id
, buf
);
651 mutex_unlock(&wacom
->lock
);
653 return err
< 0 ? err
: count
;
656 #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
657 static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
658 struct device_attribute *attr, const char *buf, size_t count) \
660 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
662 static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \
663 NULL, wacom_btnimg##BUTTON_ID##_store)
665 DEVICE_BTNIMG_ATTR(0);
666 DEVICE_BTNIMG_ATTR(1);
667 DEVICE_BTNIMG_ATTR(2);
668 DEVICE_BTNIMG_ATTR(3);
669 DEVICE_BTNIMG_ATTR(4);
670 DEVICE_BTNIMG_ATTR(5);
671 DEVICE_BTNIMG_ATTR(6);
672 DEVICE_BTNIMG_ATTR(7);
674 static struct attribute
*cintiq_led_attrs
[] = {
675 &dev_attr_status_led0_select
.attr
,
676 &dev_attr_status_led1_select
.attr
,
680 static struct attribute_group cintiq_led_attr_group
= {
682 .attrs
= cintiq_led_attrs
,
685 static struct attribute
*intuos4_led_attrs
[] = {
686 &dev_attr_status0_luminance
.attr
,
687 &dev_attr_status1_luminance
.attr
,
688 &dev_attr_status_led0_select
.attr
,
689 &dev_attr_buttons_luminance
.attr
,
690 &dev_attr_button0_rawimg
.attr
,
691 &dev_attr_button1_rawimg
.attr
,
692 &dev_attr_button2_rawimg
.attr
,
693 &dev_attr_button3_rawimg
.attr
,
694 &dev_attr_button4_rawimg
.attr
,
695 &dev_attr_button5_rawimg
.attr
,
696 &dev_attr_button6_rawimg
.attr
,
697 &dev_attr_button7_rawimg
.attr
,
701 static struct attribute_group intuos4_led_attr_group
= {
703 .attrs
= intuos4_led_attrs
,
706 static int wacom_initialize_leds(struct wacom
*wacom
)
710 /* Initialize default values */
711 switch (wacom
->wacom_wac
.features
.type
) {
714 wacom
->led
.select
[0] = 0;
715 wacom
->led
.select
[1] = 0;
718 wacom
->led
.img_lum
= 10;
719 error
= sysfs_create_group(&wacom
->intf
->dev
.kobj
,
720 &intuos4_led_attr_group
);
724 wacom
->led
.select
[0] = 0;
725 wacom
->led
.select
[1] = 0;
728 wacom
->led
.img_lum
= 0;
730 error
= sysfs_create_group(&wacom
->intf
->dev
.kobj
,
731 &cintiq_led_attr_group
);
739 dev_err(&wacom
->intf
->dev
,
740 "cannot create sysfs group err: %d\n", error
);
743 wacom_led_control(wacom
);
748 static void wacom_destroy_leds(struct wacom
*wacom
)
750 switch (wacom
->wacom_wac
.features
.type
) {
753 sysfs_remove_group(&wacom
->intf
->dev
.kobj
,
754 &intuos4_led_attr_group
);
758 sysfs_remove_group(&wacom
->intf
->dev
.kobj
,
759 &cintiq_led_attr_group
);
764 static int wacom_probe(struct usb_interface
*intf
, const struct usb_device_id
*id
)
766 struct usb_device
*dev
= interface_to_usbdev(intf
);
767 struct usb_endpoint_descriptor
*endpoint
;
769 struct wacom_wac
*wacom_wac
;
770 struct wacom_features
*features
;
771 struct input_dev
*input_dev
;
774 if (!id
->driver_info
)
777 wacom
= kzalloc(sizeof(struct wacom
), GFP_KERNEL
);
778 input_dev
= input_allocate_device();
779 if (!wacom
|| !input_dev
) {
784 wacom_wac
= &wacom
->wacom_wac
;
785 wacom_wac
->features
= *((struct wacom_features
*)id
->driver_info
);
786 features
= &wacom_wac
->features
;
787 if (features
->pktlen
> WACOM_PKGLEN_MAX
) {
792 wacom_wac
->data
= usb_alloc_coherent(dev
, WACOM_PKGLEN_MAX
,
793 GFP_KERNEL
, &wacom
->data_dma
);
794 if (!wacom_wac
->data
) {
799 wacom
->irq
= usb_alloc_urb(0, GFP_KERNEL
);
807 mutex_init(&wacom
->lock
);
808 usb_make_path(dev
, wacom
->phys
, sizeof(wacom
->phys
));
809 strlcat(wacom
->phys
, "/input0", sizeof(wacom
->phys
));
811 wacom_wac
->input
= input_dev
;
813 endpoint
= &intf
->cur_altsetting
->endpoint
[0].desc
;
815 /* Retrieve the physical and logical size for OEM devices */
816 error
= wacom_retrieve_hid_descriptor(intf
, features
);
820 wacom_setup_device_quirks(features
);
822 strlcpy(wacom_wac
->name
, features
->name
, sizeof(wacom_wac
->name
));
824 if (features
->quirks
& WACOM_QUIRK_MULTI_INPUT
) {
825 /* Append the device type to the name */
826 strlcat(wacom_wac
->name
,
827 features
->device_type
== BTN_TOOL_PEN
?
829 sizeof(wacom_wac
->name
));
831 error
= wacom_add_shared_data(wacom_wac
, dev
);
836 input_dev
->name
= wacom_wac
->name
;
837 input_dev
->dev
.parent
= &intf
->dev
;
838 input_dev
->open
= wacom_open
;
839 input_dev
->close
= wacom_close
;
840 usb_to_input_id(dev
, &input_dev
->id
);
841 input_set_drvdata(input_dev
, wacom
);
843 wacom_setup_input_capabilities(input_dev
, wacom_wac
);
845 usb_fill_int_urb(wacom
->irq
, dev
,
846 usb_rcvintpipe(dev
, endpoint
->bEndpointAddress
),
847 wacom_wac
->data
, features
->pktlen
,
848 wacom_sys_irq
, wacom
, endpoint
->bInterval
);
849 wacom
->irq
->transfer_dma
= wacom
->data_dma
;
850 wacom
->irq
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
852 error
= wacom_initialize_leds(wacom
);
856 error
= input_register_device(input_dev
);
860 /* Note that if query fails it is not a hard failure */
861 wacom_query_tablet_data(intf
, features
);
863 usb_set_intfdata(intf
, wacom
);
866 fail5
: wacom_destroy_leds(wacom
);
867 fail4
: wacom_remove_shared_data(wacom_wac
);
868 fail3
: usb_free_urb(wacom
->irq
);
869 fail2
: usb_free_coherent(dev
, WACOM_PKGLEN_MAX
, wacom_wac
->data
, wacom
->data_dma
);
870 fail1
: input_free_device(input_dev
);
875 static void wacom_disconnect(struct usb_interface
*intf
)
877 struct wacom
*wacom
= usb_get_intfdata(intf
);
879 usb_set_intfdata(intf
, NULL
);
881 usb_kill_urb(wacom
->irq
);
882 input_unregister_device(wacom
->wacom_wac
.input
);
883 wacom_destroy_leds(wacom
);
884 usb_free_urb(wacom
->irq
);
885 usb_free_coherent(interface_to_usbdev(intf
), WACOM_PKGLEN_MAX
,
886 wacom
->wacom_wac
.data
, wacom
->data_dma
);
887 wacom_remove_shared_data(&wacom
->wacom_wac
);
891 static int wacom_suspend(struct usb_interface
*intf
, pm_message_t message
)
893 struct wacom
*wacom
= usb_get_intfdata(intf
);
895 mutex_lock(&wacom
->lock
);
896 usb_kill_urb(wacom
->irq
);
897 mutex_unlock(&wacom
->lock
);
902 static int wacom_resume(struct usb_interface
*intf
)
904 struct wacom
*wacom
= usb_get_intfdata(intf
);
905 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
908 mutex_lock(&wacom
->lock
);
910 /* switch to wacom mode first */
911 wacom_query_tablet_data(intf
, features
);
912 wacom_led_control(wacom
);
914 if (wacom
->open
&& usb_submit_urb(wacom
->irq
, GFP_NOIO
) < 0)
917 mutex_unlock(&wacom
->lock
);
922 static int wacom_reset_resume(struct usb_interface
*intf
)
924 return wacom_resume(intf
);
927 static struct usb_driver wacom_driver
= {
929 .id_table
= wacom_ids
,
930 .probe
= wacom_probe
,
931 .disconnect
= wacom_disconnect
,
932 .suspend
= wacom_suspend
,
933 .resume
= wacom_resume
,
934 .reset_resume
= wacom_reset_resume
,
935 .supports_autosuspend
= 1,
938 static int __init
wacom_init(void)
942 result
= usb_register(&wacom_driver
);
944 printk(KERN_INFO KBUILD_MODNAME
": " DRIVER_VERSION
":"
949 static void __exit
wacom_exit(void)
951 usb_deregister(&wacom_driver
);
954 module_init(wacom_init
);
955 module_exit(wacom_exit
);