diff options
author | Paul Mackerras <paulus@samba.org> | 2007-05-07 23:37:51 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-05-07 23:37:51 -0400 |
commit | 02bbc0f09c90cefdb2837605c96a66c5ce4ba2e1 (patch) | |
tree | 04ef573cd4de095c500c9fc3477f4278c0b36300 /drivers/usb | |
parent | 7487a2245b8841c77ba9db406cf99a483b9334e9 (diff) | |
parent | 5b94f675f57e4ff16c8fda09088d7480a84dcd91 (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/pxa2xx_udc.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/ehci-ps3.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/ohci-ps3.c | 8 | ||||
-rw-r--r-- | drivers/usb/host/ohci-pxa27x.c | 4 | ||||
-rw-r--r-- | drivers/usb/input/Makefile | 5 | ||||
-rw-r--r-- | drivers/usb/input/acecad.c | 28 | ||||
-rw-r--r-- | drivers/usb/input/aiptek.c | 38 | ||||
-rw-r--r-- | drivers/usb/input/appletouch.c | 29 | ||||
-rw-r--r-- | drivers/usb/input/ati_remote.c | 42 | ||||
-rw-r--r-- | drivers/usb/input/ati_remote2.c | 16 | ||||
-rw-r--r-- | drivers/usb/input/gtco.c | 634 | ||||
-rw-r--r-- | drivers/usb/input/itmtouch.c | 271 | ||||
-rw-r--r-- | drivers/usb/input/kbtab.c | 22 | ||||
-rw-r--r-- | drivers/usb/input/keyspan_remote.c | 29 | ||||
-rw-r--r-- | drivers/usb/input/mtouchusb.c | 332 | ||||
-rw-r--r-- | drivers/usb/input/powermate.c | 27 | ||||
-rw-r--r-- | drivers/usb/input/touchkitusb.c | 392 | ||||
-rw-r--r-- | drivers/usb/input/usbtouchscreen.c | 10 | ||||
-rw-r--r-- | drivers/usb/input/wacom_sys.c | 22 | ||||
-rw-r--r-- | drivers/usb/input/xpad.c | 22 | ||||
-rw-r--r-- | drivers/usb/input/yealink.c | 13 | ||||
-rw-r--r-- | drivers/usb/net/kaweth.c | 1 |
22 files changed, 480 insertions, 1476 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 2c043a1ea156..84392e835d5f 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -1483,7 +1483,7 @@ static void udc_disable(struct pxa2xx_udc *dev) | |||
1483 | 1483 | ||
1484 | #ifdef CONFIG_ARCH_PXA | 1484 | #ifdef CONFIG_ARCH_PXA |
1485 | /* Disable clock for USB device */ | 1485 | /* Disable clock for USB device */ |
1486 | pxa_set_cken(CKEN11_USB, 0); | 1486 | pxa_set_cken(CKEN_USB, 0); |
1487 | #endif | 1487 | #endif |
1488 | 1488 | ||
1489 | ep0_idle (dev); | 1489 | ep0_idle (dev); |
@@ -1529,7 +1529,7 @@ static void udc_enable (struct pxa2xx_udc *dev) | |||
1529 | 1529 | ||
1530 | #ifdef CONFIG_ARCH_PXA | 1530 | #ifdef CONFIG_ARCH_PXA |
1531 | /* Enable clock for USB device */ | 1531 | /* Enable clock for USB device */ |
1532 | pxa_set_cken(CKEN11_USB, 1); | 1532 | pxa_set_cken(CKEN_USB, 1); |
1533 | udelay(5); | 1533 | udelay(5); |
1534 | #endif | 1534 | #endif |
1535 | 1535 | ||
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index 29dcd27b55de..37b83ba09969 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
@@ -73,13 +73,6 @@ static const struct hc_driver ps3_ehci_hc_driver = { | |||
73 | #endif | 73 | #endif |
74 | }; | 74 | }; |
75 | 75 | ||
76 | #if !defined(DEBUG) | ||
77 | #undef dev_dbg | ||
78 | static inline int __attribute__ ((format (printf, 2, 3))) dev_dbg( | ||
79 | const struct device *_dev, const char *fmt, ...) {return 0;} | ||
80 | #endif | ||
81 | |||
82 | |||
83 | static int ps3_ehci_sb_probe(struct ps3_system_bus_device *dev) | 76 | static int ps3_ehci_sb_probe(struct ps3_system_bus_device *dev) |
84 | { | 77 | { |
85 | int result; | 78 | int result; |
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c index 93a6eb0de2d1..d7cf07288b0b 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c | |||
@@ -75,14 +75,6 @@ static const struct hc_driver ps3_ohci_hc_driver = { | |||
75 | #endif | 75 | #endif |
76 | }; | 76 | }; |
77 | 77 | ||
78 | /* redefine dev_dbg to do a syntax check */ | ||
79 | |||
80 | #if !defined(DEBUG) | ||
81 | #undef dev_dbg | ||
82 | static inline int __attribute__ ((format (printf, 2, 3))) dev_dbg( | ||
83 | const struct device *_dev, const char *fmt, ...) {return 0;} | ||
84 | #endif | ||
85 | |||
86 | static int ps3_ohci_sb_probe(struct ps3_system_bus_device *dev) | 78 | static int ps3_ohci_sb_probe(struct ps3_system_bus_device *dev) |
87 | { | 79 | { |
88 | int result; | 80 | int result; |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index f1563dc319d3..23d2fe5a62f4 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -80,7 +80,7 @@ static int pxa27x_start_hc(struct device *dev) | |||
80 | 80 | ||
81 | inf = dev->platform_data; | 81 | inf = dev->platform_data; |
82 | 82 | ||
83 | pxa_set_cken(CKEN10_USBHOST, 1); | 83 | pxa_set_cken(CKEN_USBHOST, 1); |
84 | 84 | ||
85 | UHCHR |= UHCHR_FHR; | 85 | UHCHR |= UHCHR_FHR; |
86 | udelay(11); | 86 | udelay(11); |
@@ -123,7 +123,7 @@ static void pxa27x_stop_hc(struct device *dev) | |||
123 | UHCCOMS |= 1; | 123 | UHCCOMS |= 1; |
124 | udelay(10); | 124 | udelay(10); |
125 | 125 | ||
126 | pxa_set_cken(CKEN10_USBHOST, 0); | 126 | pxa_set_cken(CKEN_USBHOST, 0); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index 9bf420eef77f..284a0734e0cd 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile | |||
@@ -10,9 +10,6 @@ obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o | |||
10 | obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o | 10 | obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o |
11 | obj-$(CONFIG_USB_KBTAB) += kbtab.o | 11 | obj-$(CONFIG_USB_KBTAB) += kbtab.o |
12 | obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o | 12 | obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o |
13 | obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o | ||
14 | obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o | ||
15 | obj-$(CONFIG_USB_EGALAX) += touchkitusb.o | ||
16 | obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o | 13 | obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o |
17 | obj-$(CONFIG_USB_POWERMATE) += powermate.o | 14 | obj-$(CONFIG_USB_POWERMATE) += powermate.o |
18 | obj-$(CONFIG_USB_WACOM) += wacom.o | 15 | obj-$(CONFIG_USB_WACOM) += wacom.o |
@@ -20,7 +17,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o | |||
20 | obj-$(CONFIG_USB_YEALINK) += yealink.o | 17 | obj-$(CONFIG_USB_YEALINK) += yealink.o |
21 | obj-$(CONFIG_USB_XPAD) += xpad.o | 18 | obj-$(CONFIG_USB_XPAD) += xpad.o |
22 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o | 19 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o |
23 | obj-$(CONFIG_USB_GTCO) += gtco.o | 20 | obj-$(CONFIG_USB_GTCO) += gtco.o |
24 | 21 | ||
25 | ifeq ($(CONFIG_USB_DEBUG),y) | 22 | ifeq ($(CONFIG_USB_DEBUG),y) |
26 | EXTRA_CFLAGS += -DDEBUG | 23 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c index 909138e5aa04..be8e9243c062 100644 --- a/drivers/usb/input/acecad.c +++ b/drivers/usb/input/acecad.c | |||
@@ -111,7 +111,7 @@ resubmit: | |||
111 | 111 | ||
112 | static int usb_acecad_open(struct input_dev *dev) | 112 | static int usb_acecad_open(struct input_dev *dev) |
113 | { | 113 | { |
114 | struct usb_acecad *acecad = dev->private; | 114 | struct usb_acecad *acecad = input_get_drvdata(dev); |
115 | 115 | ||
116 | acecad->irq->dev = acecad->usbdev; | 116 | acecad->irq->dev = acecad->usbdev; |
117 | if (usb_submit_urb(acecad->irq, GFP_KERNEL)) | 117 | if (usb_submit_urb(acecad->irq, GFP_KERNEL)) |
@@ -122,7 +122,7 @@ static int usb_acecad_open(struct input_dev *dev) | |||
122 | 122 | ||
123 | static void usb_acecad_close(struct input_dev *dev) | 123 | static void usb_acecad_close(struct input_dev *dev) |
124 | { | 124 | { |
125 | struct usb_acecad *acecad = dev->private; | 125 | struct usb_acecad *acecad = input_get_drvdata(dev); |
126 | 126 | ||
127 | usb_kill_urb(acecad->irq); | 127 | usb_kill_urb(acecad->irq); |
128 | } | 128 | } |
@@ -135,6 +135,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
135 | struct usb_acecad *acecad; | 135 | struct usb_acecad *acecad; |
136 | struct input_dev *input_dev; | 136 | struct input_dev *input_dev; |
137 | int pipe, maxp; | 137 | int pipe, maxp; |
138 | int err = -ENOMEM; | ||
138 | 139 | ||
139 | if (interface->desc.bNumEndpoints != 1) | 140 | if (interface->desc.bNumEndpoints != 1) |
140 | return -ENODEV; | 141 | return -ENODEV; |
@@ -149,16 +150,22 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
149 | 150 | ||
150 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); | 151 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); |
151 | input_dev = input_allocate_device(); | 152 | input_dev = input_allocate_device(); |
152 | if (!acecad || !input_dev) | 153 | if (!acecad || !input_dev) { |
154 | err = -ENOMEM; | ||
153 | goto fail1; | 155 | goto fail1; |
156 | } | ||
154 | 157 | ||
155 | acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma); | 158 | acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma); |
156 | if (!acecad->data) | 159 | if (!acecad->data) { |
160 | err= -ENOMEM; | ||
157 | goto fail1; | 161 | goto fail1; |
162 | } | ||
158 | 163 | ||
159 | acecad->irq = usb_alloc_urb(0, GFP_KERNEL); | 164 | acecad->irq = usb_alloc_urb(0, GFP_KERNEL); |
160 | if (!acecad->irq) | 165 | if (!acecad->irq) { |
166 | err = -ENOMEM; | ||
161 | goto fail2; | 167 | goto fail2; |
168 | } | ||
162 | 169 | ||
163 | acecad->usbdev = dev; | 170 | acecad->usbdev = dev; |
164 | acecad->input = input_dev; | 171 | acecad->input = input_dev; |
@@ -178,8 +185,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
178 | input_dev->name = acecad->name; | 185 | input_dev->name = acecad->name; |
179 | input_dev->phys = acecad->phys; | 186 | input_dev->phys = acecad->phys; |
180 | usb_to_input_id(dev, &input_dev->id); | 187 | usb_to_input_id(dev, &input_dev->id); |
181 | input_dev->cdev.dev = &intf->dev; | 188 | input_dev->dev.parent = &intf->dev; |
182 | input_dev->private = acecad; | 189 | |
190 | input_set_drvdata(input_dev, acecad); | ||
183 | 191 | ||
184 | input_dev->open = usb_acecad_open; | 192 | input_dev->open = usb_acecad_open; |
185 | input_dev->close = usb_acecad_close; | 193 | input_dev->close = usb_acecad_close; |
@@ -221,7 +229,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
221 | acecad->irq->transfer_dma = acecad->data_dma; | 229 | acecad->irq->transfer_dma = acecad->data_dma; |
222 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 230 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
223 | 231 | ||
224 | input_register_device(acecad->input); | 232 | err = input_register_device(acecad->input); |
233 | if (err) | ||
234 | goto fail2; | ||
225 | 235 | ||
226 | usb_set_intfdata(intf, acecad); | 236 | usb_set_intfdata(intf, acecad); |
227 | 237 | ||
@@ -230,7 +240,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
230 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); | 240 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); |
231 | fail1: input_free_device(input_dev); | 241 | fail1: input_free_device(input_dev); |
232 | kfree(acecad); | 242 | kfree(acecad); |
233 | return -ENOMEM; | 243 | return err; |
234 | } | 244 | } |
235 | 245 | ||
236 | static void usb_acecad_disconnect(struct usb_interface *intf) | 246 | static void usb_acecad_disconnect(struct usb_interface *intf) |
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index f857935e615c..cc0a498763d8 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
@@ -798,7 +798,7 @@ MODULE_DEVICE_TABLE(usb, aiptek_ids); | |||
798 | */ | 798 | */ |
799 | static int aiptek_open(struct input_dev *inputdev) | 799 | static int aiptek_open(struct input_dev *inputdev) |
800 | { | 800 | { |
801 | struct aiptek *aiptek = inputdev->private; | 801 | struct aiptek *aiptek = input_get_drvdata(inputdev); |
802 | 802 | ||
803 | aiptek->urb->dev = aiptek->usbdev; | 803 | aiptek->urb->dev = aiptek->usbdev; |
804 | if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) | 804 | if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) |
@@ -812,7 +812,7 @@ static int aiptek_open(struct input_dev *inputdev) | |||
812 | */ | 812 | */ |
813 | static void aiptek_close(struct input_dev *inputdev) | 813 | static void aiptek_close(struct input_dev *inputdev) |
814 | { | 814 | { |
815 | struct aiptek *aiptek = inputdev->private; | 815 | struct aiptek *aiptek = input_get_drvdata(inputdev); |
816 | 816 | ||
817 | usb_kill_urb(aiptek->urb); | 817 | usb_kill_urb(aiptek->urb); |
818 | } | 818 | } |
@@ -1972,6 +1972,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1972 | AIPTEK_PROGRAMMABLE_DELAY_200, | 1972 | AIPTEK_PROGRAMMABLE_DELAY_200, |
1973 | AIPTEK_PROGRAMMABLE_DELAY_300 | 1973 | AIPTEK_PROGRAMMABLE_DELAY_300 |
1974 | }; | 1974 | }; |
1975 | int err = -ENOMEM; | ||
1975 | 1976 | ||
1976 | /* programmableDelay is where the command-line specified | 1977 | /* programmableDelay is where the command-line specified |
1977 | * delay is kept. We make it the first element of speeds[], | 1978 | * delay is kept. We make it the first element of speeds[], |
@@ -2043,8 +2044,10 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2043 | inputdev->name = "Aiptek"; | 2044 | inputdev->name = "Aiptek"; |
2044 | inputdev->phys = aiptek->features.usbPath; | 2045 | inputdev->phys = aiptek->features.usbPath; |
2045 | usb_to_input_id(usbdev, &inputdev->id); | 2046 | usb_to_input_id(usbdev, &inputdev->id); |
2046 | inputdev->cdev.dev = &intf->dev; | 2047 | inputdev->dev.parent = &intf->dev; |
2047 | inputdev->private = aiptek; | 2048 | |
2049 | input_set_drvdata(inputdev, aiptek); | ||
2050 | |||
2048 | inputdev->open = aiptek_open; | 2051 | inputdev->open = aiptek_open; |
2049 | inputdev->close = aiptek_close; | 2052 | inputdev->close = aiptek_close; |
2050 | 2053 | ||
@@ -2133,7 +2136,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2133 | 2136 | ||
2134 | /* Register the tablet as an Input Device | 2137 | /* Register the tablet as an Input Device |
2135 | */ | 2138 | */ |
2136 | input_register_device(aiptek->inputdev); | 2139 | err = input_register_device(aiptek->inputdev); |
2140 | if (err) | ||
2141 | goto fail2; | ||
2137 | 2142 | ||
2138 | /* We now will look for the evdev device which is mapped to | 2143 | /* We now will look for the evdev device which is mapped to |
2139 | * the tablet. The partial name is kept in the link list of | 2144 | * the tablet. The partial name is kept in the link list of |
@@ -2165,23 +2170,13 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2165 | 2170 | ||
2166 | return 0; | 2171 | return 0; |
2167 | 2172 | ||
2168 | fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | 2173 | fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, |
2169 | aiptek->data_dma); | 2174 | aiptek->data_dma); |
2170 | fail1: input_free_device(inputdev); | 2175 | fail1: input_free_device(inputdev); |
2171 | kfree(aiptek); | 2176 | kfree(aiptek); |
2172 | return -ENOMEM; | 2177 | return err; |
2173 | } | 2178 | } |
2174 | 2179 | ||
2175 | /* Forward declaration */ | ||
2176 | static void aiptek_disconnect(struct usb_interface *intf); | ||
2177 | |||
2178 | static struct usb_driver aiptek_driver = { | ||
2179 | .name = "aiptek", | ||
2180 | .probe = aiptek_probe, | ||
2181 | .disconnect = aiptek_disconnect, | ||
2182 | .id_table = aiptek_ids, | ||
2183 | }; | ||
2184 | |||
2185 | /*********************************************************************** | 2180 | /*********************************************************************** |
2186 | * Deal with tablet disconnecting from the system. | 2181 | * Deal with tablet disconnecting from the system. |
2187 | */ | 2182 | */ |
@@ -2206,6 +2201,13 @@ static void aiptek_disconnect(struct usb_interface *intf) | |||
2206 | } | 2201 | } |
2207 | } | 2202 | } |
2208 | 2203 | ||
2204 | static struct usb_driver aiptek_driver = { | ||
2205 | .name = "aiptek", | ||
2206 | .probe = aiptek_probe, | ||
2207 | .disconnect = aiptek_disconnect, | ||
2208 | .id_table = aiptek_ids, | ||
2209 | }; | ||
2210 | |||
2209 | static int __init aiptek_init(void) | 2211 | static int __init aiptek_init(void) |
2210 | { | 2212 | { |
2211 | int result = usb_register(&aiptek_driver); | 2213 | int result = usb_register(&aiptek_driver); |
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c index c77291d3d063..e3215267db11 100644 --- a/drivers/usb/input/appletouch.c +++ b/drivers/usb/input/appletouch.c | |||
@@ -466,7 +466,7 @@ exit: | |||
466 | 466 | ||
467 | static int atp_open(struct input_dev *input) | 467 | static int atp_open(struct input_dev *input) |
468 | { | 468 | { |
469 | struct atp *dev = input->private; | 469 | struct atp *dev = input_get_drvdata(input); |
470 | 470 | ||
471 | if (usb_submit_urb(dev->urb, GFP_ATOMIC)) | 471 | if (usb_submit_urb(dev->urb, GFP_ATOMIC)) |
472 | return -EIO; | 472 | return -EIO; |
@@ -477,7 +477,7 @@ static int atp_open(struct input_dev *input) | |||
477 | 477 | ||
478 | static void atp_close(struct input_dev *input) | 478 | static void atp_close(struct input_dev *input) |
479 | { | 479 | { |
480 | struct atp *dev = input->private; | 480 | struct atp *dev = input_get_drvdata(input); |
481 | 481 | ||
482 | usb_kill_urb(dev->urb); | 482 | usb_kill_urb(dev->urb); |
483 | dev->open = 0; | 483 | dev->open = 0; |
@@ -491,8 +491,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
491 | struct usb_host_interface *iface_desc; | 491 | struct usb_host_interface *iface_desc; |
492 | struct usb_endpoint_descriptor *endpoint; | 492 | struct usb_endpoint_descriptor *endpoint; |
493 | int int_in_endpointAddr = 0; | 493 | int int_in_endpointAddr = 0; |
494 | int i, retval = -ENOMEM; | 494 | int i, error = -ENOMEM; |
495 | |||
496 | 495 | ||
497 | /* set up the endpoint information */ | 496 | /* set up the endpoint information */ |
498 | /* use only the first interrupt-in endpoint */ | 497 | /* use only the first interrupt-in endpoint */ |
@@ -567,17 +566,13 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
567 | } | 566 | } |
568 | 567 | ||
569 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | 568 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
570 | if (!dev->urb) { | 569 | if (!dev->urb) |
571 | retval = -ENOMEM; | ||
572 | goto err_free_devs; | 570 | goto err_free_devs; |
573 | } | ||
574 | 571 | ||
575 | dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL, | 572 | dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL, |
576 | &dev->urb->transfer_dma); | 573 | &dev->urb->transfer_dma); |
577 | if (!dev->data) { | 574 | if (!dev->data) |
578 | retval = -ENOMEM; | ||
579 | goto err_free_urb; | 575 | goto err_free_urb; |
580 | } | ||
581 | 576 | ||
582 | usb_fill_int_urb(dev->urb, udev, | 577 | usb_fill_int_urb(dev->urb, udev, |
583 | usb_rcvintpipe(udev, int_in_endpointAddr), | 578 | usb_rcvintpipe(udev, int_in_endpointAddr), |
@@ -589,9 +584,10 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
589 | input_dev->name = "appletouch"; | 584 | input_dev->name = "appletouch"; |
590 | input_dev->phys = dev->phys; | 585 | input_dev->phys = dev->phys; |
591 | usb_to_input_id(dev->udev, &input_dev->id); | 586 | usb_to_input_id(dev->udev, &input_dev->id); |
592 | input_dev->cdev.dev = &iface->dev; | 587 | input_dev->dev.parent = &iface->dev; |
588 | |||
589 | input_set_drvdata(input_dev, dev); | ||
593 | 590 | ||
594 | input_dev->private = dev; | ||
595 | input_dev->open = atp_open; | 591 | input_dev->open = atp_open; |
596 | input_dev->close = atp_close; | 592 | input_dev->close = atp_close; |
597 | 593 | ||
@@ -633,20 +629,25 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
633 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | 629 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
634 | set_bit(BTN_LEFT, input_dev->keybit); | 630 | set_bit(BTN_LEFT, input_dev->keybit); |
635 | 631 | ||
636 | input_register_device(dev->input); | 632 | error = input_register_device(dev->input); |
633 | if (error) | ||
634 | goto err_free_buffer; | ||
637 | 635 | ||
638 | /* save our data pointer in this interface device */ | 636 | /* save our data pointer in this interface device */ |
639 | usb_set_intfdata(iface, dev); | 637 | usb_set_intfdata(iface, dev); |
640 | 638 | ||
641 | return 0; | 639 | return 0; |
642 | 640 | ||
641 | err_free_buffer: | ||
642 | usb_buffer_free(dev->udev, dev->datalen, | ||
643 | dev->data, dev->urb->transfer_dma); | ||
643 | err_free_urb: | 644 | err_free_urb: |
644 | usb_free_urb(dev->urb); | 645 | usb_free_urb(dev->urb); |
645 | err_free_devs: | 646 | err_free_devs: |
646 | usb_set_intfdata(iface, NULL); | 647 | usb_set_intfdata(iface, NULL); |
647 | kfree(dev); | 648 | kfree(dev); |
648 | input_free_device(input_dev); | 649 | input_free_device(input_dev); |
649 | return retval; | 650 | return error; |
650 | } | 651 | } |
651 | 652 | ||
652 | static void atp_disconnect(struct usb_interface *iface) | 653 | static void atp_disconnect(struct usb_interface *iface) |
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index b724e36f7b92..471aab206443 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -120,6 +120,7 @@ | |||
120 | * behaviour. | 120 | * behaviour. |
121 | */ | 121 | */ |
122 | #define FILTER_TIME 60 /* msec */ | 122 | #define FILTER_TIME 60 /* msec */ |
123 | #define REPEAT_DELAY 500 /* msec */ | ||
123 | 124 | ||
124 | static unsigned long channel_mask; | 125 | static unsigned long channel_mask; |
125 | module_param(channel_mask, ulong, 0644); | 126 | module_param(channel_mask, ulong, 0644); |
@@ -133,6 +134,10 @@ static int repeat_filter = FILTER_TIME; | |||
133 | module_param(repeat_filter, int, 0644); | 134 | module_param(repeat_filter, int, 0644); |
134 | MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec"); | 135 | MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec"); |
135 | 136 | ||
137 | static int repeat_delay = REPEAT_DELAY; | ||
138 | module_param(repeat_delay, int, 0644); | ||
139 | MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec"); | ||
140 | |||
136 | #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) | 141 | #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) |
137 | #undef err | 142 | #undef err |
138 | #define err(format, arg...) printk(KERN_ERR format , ## arg) | 143 | #define err(format, arg...) printk(KERN_ERR format , ## arg) |
@@ -174,6 +179,8 @@ struct ati_remote { | |||
174 | unsigned char old_data[2]; /* Detect duplicate events */ | 179 | unsigned char old_data[2]; /* Detect duplicate events */ |
175 | unsigned long old_jiffies; | 180 | unsigned long old_jiffies; |
176 | unsigned long acc_jiffies; /* handle acceleration */ | 181 | unsigned long acc_jiffies; /* handle acceleration */ |
182 | unsigned long first_jiffies; | ||
183 | |||
177 | unsigned int repeat_count; | 184 | unsigned int repeat_count; |
178 | 185 | ||
179 | char name[NAME_BUFSIZE]; | 186 | char name[NAME_BUFSIZE]; |
@@ -318,7 +325,7 @@ static void ati_remote_dump(unsigned char *data, unsigned int len) | |||
318 | */ | 325 | */ |
319 | static int ati_remote_open(struct input_dev *inputdev) | 326 | static int ati_remote_open(struct input_dev *inputdev) |
320 | { | 327 | { |
321 | struct ati_remote *ati_remote = inputdev->private; | 328 | struct ati_remote *ati_remote = input_get_drvdata(inputdev); |
322 | 329 | ||
323 | /* On first open, submit the read urb which was set up previously. */ | 330 | /* On first open, submit the read urb which was set up previously. */ |
324 | ati_remote->irq_urb->dev = ati_remote->udev; | 331 | ati_remote->irq_urb->dev = ati_remote->udev; |
@@ -336,7 +343,7 @@ static int ati_remote_open(struct input_dev *inputdev) | |||
336 | */ | 343 | */ |
337 | static void ati_remote_close(struct input_dev *inputdev) | 344 | static void ati_remote_close(struct input_dev *inputdev) |
338 | { | 345 | { |
339 | struct ati_remote *ati_remote = inputdev->private; | 346 | struct ati_remote *ati_remote = input_get_drvdata(inputdev); |
340 | 347 | ||
341 | usb_kill_urb(ati_remote->irq_urb); | 348 | usb_kill_urb(ati_remote->irq_urb); |
342 | } | 349 | } |
@@ -501,21 +508,31 @@ static void ati_remote_input_report(struct urb *urb) | |||
501 | } | 508 | } |
502 | 509 | ||
503 | if (ati_remote_tbl[index].kind == KIND_FILTERED) { | 510 | if (ati_remote_tbl[index].kind == KIND_FILTERED) { |
511 | unsigned long now = jiffies; | ||
512 | |||
504 | /* Filter duplicate events which happen "too close" together. */ | 513 | /* Filter duplicate events which happen "too close" together. */ |
505 | if (ati_remote->old_data[0] == data[1] && | 514 | if (ati_remote->old_data[0] == data[1] && |
506 | ati_remote->old_data[1] == data[2] && | 515 | ati_remote->old_data[1] == data[2] && |
507 | time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) { | 516 | time_before(now, ati_remote->old_jiffies + |
517 | msecs_to_jiffies(repeat_filter))) { | ||
508 | ati_remote->repeat_count++; | 518 | ati_remote->repeat_count++; |
509 | } else { | 519 | } else { |
510 | ati_remote->repeat_count = 0; | 520 | ati_remote->repeat_count = 0; |
521 | ati_remote->first_jiffies = now; | ||
511 | } | 522 | } |
512 | 523 | ||
513 | ati_remote->old_data[0] = data[1]; | 524 | ati_remote->old_data[0] = data[1]; |
514 | ati_remote->old_data[1] = data[2]; | 525 | ati_remote->old_data[1] = data[2]; |
515 | ati_remote->old_jiffies = jiffies; | 526 | ati_remote->old_jiffies = now; |
516 | 527 | ||
528 | /* Ensure we skip at least the 4 first duplicate events (generated | ||
529 | * by a single keypress), and continue skipping until repeat_delay | ||
530 | * msecs have passed | ||
531 | */ | ||
517 | if (ati_remote->repeat_count > 0 && | 532 | if (ati_remote->repeat_count > 0 && |
518 | ati_remote->repeat_count < 5) | 533 | (ati_remote->repeat_count < 5 || |
534 | time_before(now, ati_remote->first_jiffies + | ||
535 | msecs_to_jiffies(repeat_delay)))) | ||
519 | return; | 536 | return; |
520 | 537 | ||
521 | 538 | ||
@@ -653,7 +670,8 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
653 | if (ati_remote_tbl[i].type == EV_KEY) | 670 | if (ati_remote_tbl[i].type == EV_KEY) |
654 | set_bit(ati_remote_tbl[i].code, idev->keybit); | 671 | set_bit(ati_remote_tbl[i].code, idev->keybit); |
655 | 672 | ||
656 | idev->private = ati_remote; | 673 | input_set_drvdata(idev, ati_remote); |
674 | |||
657 | idev->open = ati_remote_open; | 675 | idev->open = ati_remote_open; |
658 | idev->close = ati_remote_close; | 676 | idev->close = ati_remote_close; |
659 | 677 | ||
@@ -661,7 +679,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
661 | idev->phys = ati_remote->phys; | 679 | idev->phys = ati_remote->phys; |
662 | 680 | ||
663 | usb_to_input_id(ati_remote->udev, &idev->id); | 681 | usb_to_input_id(ati_remote->udev, &idev->id); |
664 | idev->cdev.dev = &ati_remote->udev->dev; | 682 | idev->dev.parent = &ati_remote->udev->dev; |
665 | } | 683 | } |
666 | 684 | ||
667 | static int ati_remote_initialize(struct ati_remote *ati_remote) | 685 | static int ati_remote_initialize(struct ati_remote *ati_remote) |
@@ -772,15 +790,17 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de | |||
772 | goto fail3; | 790 | goto fail3; |
773 | 791 | ||
774 | /* Set up and register input device */ | 792 | /* Set up and register input device */ |
775 | input_register_device(ati_remote->idev); | 793 | err = input_register_device(ati_remote->idev); |
794 | if (err) | ||
795 | goto fail3; | ||
776 | 796 | ||
777 | usb_set_intfdata(interface, ati_remote); | 797 | usb_set_intfdata(interface, ati_remote); |
778 | return 0; | 798 | return 0; |
779 | 799 | ||
780 | fail3: usb_kill_urb(ati_remote->irq_urb); | 800 | fail3: usb_kill_urb(ati_remote->irq_urb); |
781 | usb_kill_urb(ati_remote->out_urb); | 801 | usb_kill_urb(ati_remote->out_urb); |
782 | fail2: ati_remote_free_buffers(ati_remote); | 802 | fail2: ati_remote_free_buffers(ati_remote); |
783 | fail1: input_free_device(input_dev); | 803 | fail1: input_free_device(input_dev); |
784 | kfree(ati_remote); | 804 | kfree(ati_remote); |
785 | return err; | 805 | return err; |
786 | } | 806 | } |
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c index 6459be90599c..a9032aa3465f 100644 --- a/drivers/usb/input/ati_remote2.c +++ b/drivers/usb/input/ati_remote2.c | |||
@@ -131,7 +131,7 @@ static struct usb_driver ati_remote2_driver = { | |||
131 | 131 | ||
132 | static int ati_remote2_open(struct input_dev *idev) | 132 | static int ati_remote2_open(struct input_dev *idev) |
133 | { | 133 | { |
134 | struct ati_remote2 *ar2 = idev->private; | 134 | struct ati_remote2 *ar2 = input_get_drvdata(idev); |
135 | int r; | 135 | int r; |
136 | 136 | ||
137 | r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); | 137 | r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); |
@@ -153,7 +153,7 @@ static int ati_remote2_open(struct input_dev *idev) | |||
153 | 153 | ||
154 | static void ati_remote2_close(struct input_dev *idev) | 154 | static void ati_remote2_close(struct input_dev *idev) |
155 | { | 155 | { |
156 | struct ati_remote2 *ar2 = idev->private; | 156 | struct ati_remote2 *ar2 = input_get_drvdata(idev); |
157 | 157 | ||
158 | usb_kill_urb(ar2->urb[0]); | 158 | usb_kill_urb(ar2->urb[0]); |
159 | usb_kill_urb(ar2->urb[1]); | 159 | usb_kill_urb(ar2->urb[1]); |
@@ -337,14 +337,14 @@ static void ati_remote2_complete_key(struct urb *urb) | |||
337 | static int ati_remote2_input_init(struct ati_remote2 *ar2) | 337 | static int ati_remote2_input_init(struct ati_remote2 *ar2) |
338 | { | 338 | { |
339 | struct input_dev *idev; | 339 | struct input_dev *idev; |
340 | int i; | 340 | int i, retval; |
341 | 341 | ||
342 | idev = input_allocate_device(); | 342 | idev = input_allocate_device(); |
343 | if (!idev) | 343 | if (!idev) |
344 | return -ENOMEM; | 344 | return -ENOMEM; |
345 | 345 | ||
346 | ar2->idev = idev; | 346 | ar2->idev = idev; |
347 | idev->private = ar2; | 347 | input_set_drvdata(idev, ar2); |
348 | 348 | ||
349 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL); | 349 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL); |
350 | idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); | 350 | idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); |
@@ -362,13 +362,13 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2) | |||
362 | idev->phys = ar2->phys; | 362 | idev->phys = ar2->phys; |
363 | 363 | ||
364 | usb_to_input_id(ar2->udev, &idev->id); | 364 | usb_to_input_id(ar2->udev, &idev->id); |
365 | idev->cdev.dev = &ar2->udev->dev; | 365 | idev->dev.parent = &ar2->udev->dev; |
366 | 366 | ||
367 | i = input_register_device(idev); | 367 | retval = input_register_device(idev); |
368 | if (i) | 368 | if (retval) |
369 | input_free_device(idev); | 369 | input_free_device(idev); |
370 | 370 | ||
371 | return i; | 371 | return retval; |
372 | } | 372 | } |
373 | 373 | ||
374 | static int ati_remote2_urb_init(struct ati_remote2 *ar2) | 374 | static int ati_remote2_urb_init(struct ati_remote2 *ar2) |
diff --git a/drivers/usb/input/gtco.c b/drivers/usb/input/gtco.c index ae756e0afc99..b2ca10f2fe0e 100644 --- a/drivers/usb/input/gtco.c +++ b/drivers/usb/input/gtco.c | |||
@@ -187,7 +187,6 @@ struct hid_descriptor | |||
187 | 187 | ||
188 | 188 | ||
189 | /* | 189 | /* |
190 | * | ||
191 | * This is an abbreviated parser for the HID Report Descriptor. We | 190 | * This is an abbreviated parser for the HID Report Descriptor. We |
192 | * know what devices we are talking to, so this is by no means meant | 191 | * know what devices we are talking to, so this is by no means meant |
193 | * to be generic. We can make some safe assumptions: | 192 | * to be generic. We can make some safe assumptions: |
@@ -204,7 +203,7 @@ struct hid_descriptor | |||
204 | static void parse_hid_report_descriptor(struct gtco *device, char * report, | 203 | static void parse_hid_report_descriptor(struct gtco *device, char * report, |
205 | int length) | 204 | int length) |
206 | { | 205 | { |
207 | int x,i=0; | 206 | int x, i = 0; |
208 | 207 | ||
209 | /* Tag primitive vars */ | 208 | /* Tag primitive vars */ |
210 | __u8 prefix; | 209 | __u8 prefix; |
@@ -215,7 +214,6 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report, | |||
215 | __u16 data16 = 0; | 214 | __u16 data16 = 0; |
216 | __u32 data32 = 0; | 215 | __u32 data32 = 0; |
217 | 216 | ||
218 | |||
219 | /* For parsing logic */ | 217 | /* For parsing logic */ |
220 | int inputnum = 0; | 218 | int inputnum = 0; |
221 | __u32 usage = 0; | 219 | __u32 usage = 0; |
@@ -225,46 +223,46 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report, | |||
225 | __u32 oldval[TAG_GLOB_MAX]; | 223 | __u32 oldval[TAG_GLOB_MAX]; |
226 | 224 | ||
227 | /* Debug stuff */ | 225 | /* Debug stuff */ |
228 | char maintype='x'; | 226 | char maintype = 'x'; |
229 | char globtype[12]; | 227 | char globtype[12]; |
230 | int indent=0; | 228 | int indent = 0; |
231 | char indentstr[10]=""; | 229 | char indentstr[10] = ""; |
232 | |||
233 | 230 | ||
234 | 231 | ||
235 | dbg("======>>>>>>PARSE<<<<<<======"); | 232 | dbg("======>>>>>>PARSE<<<<<<======"); |
236 | 233 | ||
237 | /* Walk this report and pull out the info we need */ | 234 | /* Walk this report and pull out the info we need */ |
238 | while (i<length){ | 235 | while (i < length) { |
239 | prefix=report[i]; | 236 | prefix = report[i]; |
240 | 237 | ||
241 | /* Skip over prefix */ | 238 | /* Skip over prefix */ |
242 | i++; | 239 | i++; |
243 | 240 | ||
244 | /* Determine data size and save the data in the proper variable */ | 241 | /* Determine data size and save the data in the proper variable */ |
245 | size = PREF_SIZE(prefix); | 242 | size = PREF_SIZE(prefix); |
246 | switch(size){ | 243 | switch (size) { |
247 | case 1: | 244 | case 1: |
248 | data = report[i]; | 245 | data = report[i]; |
249 | break; | 246 | break; |
250 | case 2: | 247 | case 2: |
251 | data16 = le16_to_cpu(get_unaligned((__le16*)(&(report[i])))); | 248 | data16 = le16_to_cpu(get_unaligned((__le16 *)&report[i])); |
252 | break; | 249 | break; |
253 | case 3: | 250 | case 3: |
254 | size = 4; | 251 | size = 4; |
255 | data32 = le32_to_cpu(get_unaligned((__le32*)(&(report[i])))); | 252 | data32 = le32_to_cpu(get_unaligned((__le32 *)&report[i])); |
253 | break; | ||
256 | } | 254 | } |
257 | 255 | ||
258 | /* Skip size of data */ | 256 | /* Skip size of data */ |
259 | i+=size; | 257 | i += size; |
260 | 258 | ||
261 | /* What we do depends on the tag type */ | 259 | /* What we do depends on the tag type */ |
262 | tag = PREF_TAG(prefix); | 260 | tag = PREF_TAG(prefix); |
263 | type = PREF_TYPE(prefix); | 261 | type = PREF_TYPE(prefix); |
264 | switch(type){ | 262 | switch (type) { |
265 | case TYPE_MAIN: | 263 | case TYPE_MAIN: |
266 | strcpy(globtype,""); | 264 | strcpy(globtype, ""); |
267 | switch(tag){ | 265 | switch (tag) { |
268 | 266 | ||
269 | case TAG_MAIN_INPUT: | 267 | case TAG_MAIN_INPUT: |
270 | /* | 268 | /* |
@@ -274,19 +272,17 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report, | |||
274 | * min/max values | 272 | * min/max values |
275 | */ | 273 | */ |
276 | 274 | ||
277 | maintype='I'; | 275 | maintype = 'I'; |
278 | if (data==2){ | 276 | if (data == 2) |
279 | strcpy(globtype,"Variable"); | 277 | strcpy(globtype, "Variable"); |
280 | } | 278 | else if (data == 3) |
281 | if (data==3){ | 279 | strcpy(globtype, "Var|Const"); |
282 | strcpy(globtype,"Var|Const"); | ||
283 | } | ||
284 | 280 | ||
285 | dbg("::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits", | 281 | dbg("::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits", |
286 | globalval[TAG_GLOB_REPORT_ID],inputnum, | 282 | globalval[TAG_GLOB_REPORT_ID], inputnum, |
287 | globalval[TAG_GLOB_LOG_MAX],globalval[TAG_GLOB_LOG_MAX], | 283 | globalval[TAG_GLOB_LOG_MAX], globalval[TAG_GLOB_LOG_MAX], |
288 | globalval[TAG_GLOB_LOG_MIN],globalval[TAG_GLOB_LOG_MIN], | 284 | globalval[TAG_GLOB_LOG_MIN], globalval[TAG_GLOB_LOG_MIN], |
289 | (globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT])); | 285 | globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT]); |
290 | 286 | ||
291 | 287 | ||
292 | /* | 288 | /* |
@@ -295,43 +291,43 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report, | |||
295 | that, we look for everything else by | 291 | that, we look for everything else by |
296 | local usage value | 292 | local usage value |
297 | */ | 293 | */ |
298 | switch (inputnum){ | 294 | switch (inputnum) { |
299 | case 0: /* X coord */ | 295 | case 0: /* X coord */ |
300 | dbg("GER: X Usage: 0x%x",usage); | 296 | dbg("GER: X Usage: 0x%x", usage); |
301 | if (device->max_X == 0){ | 297 | if (device->max_X == 0) { |
302 | device->max_X = globalval[TAG_GLOB_LOG_MAX]; | 298 | device->max_X = globalval[TAG_GLOB_LOG_MAX]; |
303 | device->min_X = globalval[TAG_GLOB_LOG_MIN]; | 299 | device->min_X = globalval[TAG_GLOB_LOG_MIN]; |
304 | } | 300 | } |
305 | |||
306 | break; | 301 | break; |
302 | |||
307 | case 1: /* Y coord */ | 303 | case 1: /* Y coord */ |
308 | dbg("GER: Y Usage: 0x%x",usage); | 304 | dbg("GER: Y Usage: 0x%x", usage); |
309 | if (device->max_Y == 0){ | 305 | if (device->max_Y == 0) { |
310 | device->max_Y = globalval[TAG_GLOB_LOG_MAX]; | 306 | device->max_Y = globalval[TAG_GLOB_LOG_MAX]; |
311 | device->min_Y = globalval[TAG_GLOB_LOG_MIN]; | 307 | device->min_Y = globalval[TAG_GLOB_LOG_MIN]; |
312 | } | 308 | } |
313 | break; | 309 | break; |
310 | |||
314 | default: | 311 | default: |
315 | /* Tilt X */ | 312 | /* Tilt X */ |
316 | if (usage == DIGITIZER_USAGE_TILT_X){ | 313 | if (usage == DIGITIZER_USAGE_TILT_X) { |
317 | if (device->maxtilt_X == 0){ | 314 | if (device->maxtilt_X == 0) { |
318 | device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX]; | 315 | device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX]; |
319 | device->mintilt_X = globalval[TAG_GLOB_LOG_MIN]; | 316 | device->mintilt_X = globalval[TAG_GLOB_LOG_MIN]; |
320 | } | 317 | } |
321 | } | 318 | } |
322 | 319 | ||
323 | /* Tilt Y */ | 320 | /* Tilt Y */ |
324 | if (usage == DIGITIZER_USAGE_TILT_Y){ | 321 | if (usage == DIGITIZER_USAGE_TILT_Y) { |
325 | if (device->maxtilt_Y == 0){ | 322 | if (device->maxtilt_Y == 0) { |
326 | device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX]; | 323 | device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX]; |
327 | device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN]; | 324 | device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN]; |
328 | } | 325 | } |
329 | } | 326 | } |
330 | 327 | ||
331 | |||
332 | /* Pressure */ | 328 | /* Pressure */ |
333 | if (usage == DIGITIZER_USAGE_TIP_PRESSURE){ | 329 | if (usage == DIGITIZER_USAGE_TIP_PRESSURE) { |
334 | if (device->maxpressure == 0){ | 330 | if (device->maxpressure == 0) { |
335 | device->maxpressure = globalval[TAG_GLOB_LOG_MAX]; | 331 | device->maxpressure = globalval[TAG_GLOB_LOG_MAX]; |
336 | device->minpressure = globalval[TAG_GLOB_LOG_MIN]; | 332 | device->minpressure = globalval[TAG_GLOB_LOG_MIN]; |
337 | } | 333 | } |
@@ -341,214 +337,226 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report, | |||
341 | } | 337 | } |
342 | 338 | ||
343 | inputnum++; | 339 | inputnum++; |
344 | |||
345 | |||
346 | break; | 340 | break; |
341 | |||
347 | case TAG_MAIN_OUTPUT: | 342 | case TAG_MAIN_OUTPUT: |
348 | maintype='O'; | 343 | maintype = 'O'; |
349 | break; | 344 | break; |
345 | |||
350 | case TAG_MAIN_FEATURE: | 346 | case TAG_MAIN_FEATURE: |
351 | maintype='F'; | 347 | maintype = 'F'; |
352 | break; | 348 | break; |
349 | |||
353 | case TAG_MAIN_COL_START: | 350 | case TAG_MAIN_COL_START: |
354 | maintype='S'; | 351 | maintype = 'S'; |
355 | 352 | ||
356 | if (data==0){ | 353 | if (data == 0) { |
357 | dbg("======>>>>>> Physical"); | 354 | dbg("======>>>>>> Physical"); |
358 | strcpy(globtype,"Physical"); | 355 | strcpy(globtype, "Physical"); |
359 | }else{ | 356 | } else |
360 | dbg("======>>>>>>"); | 357 | dbg("======>>>>>>"); |
361 | } | ||
362 | 358 | ||
363 | /* Indent the debug output */ | 359 | /* Indent the debug output */ |
364 | indent++; | 360 | indent++; |
365 | for (x=0;x<indent;x++){ | 361 | for (x = 0; x < indent; x++) |
366 | indentstr[x]='-'; | 362 | indentstr[x] = '-'; |
367 | } | 363 | indentstr[x] = 0; |
368 | indentstr[x]=0; | ||
369 | 364 | ||
370 | /* Save global tags */ | 365 | /* Save global tags */ |
371 | for (x=0;x<TAG_GLOB_MAX;x++){ | 366 | for (x = 0; x < TAG_GLOB_MAX; x++) |
372 | oldval[x] = globalval[x]; | 367 | oldval[x] = globalval[x]; |
373 | } | ||
374 | 368 | ||
375 | break; | 369 | break; |
370 | |||
376 | case TAG_MAIN_COL_END: | 371 | case TAG_MAIN_COL_END: |
377 | dbg("<<<<<<======"); | 372 | dbg("<<<<<<======"); |
378 | maintype='E'; | 373 | maintype = 'E'; |
379 | indent--; | 374 | indent--; |
380 | for (x=0;x<indent;x++){ | 375 | for (x = 0; x < indent; x++) |
381 | indentstr[x]='-'; | 376 | indentstr[x] = '-'; |
382 | } | 377 | indentstr[x] = 0; |
383 | indentstr[x]=0; | ||
384 | 378 | ||
385 | /* Copy global tags back */ | 379 | /* Copy global tags back */ |
386 | for (x=0;x<TAG_GLOB_MAX;x++){ | 380 | for (x = 0; x < TAG_GLOB_MAX; x++) |
387 | globalval[x] = oldval[x]; | 381 | globalval[x] = oldval[x]; |
388 | } | ||
389 | 382 | ||
390 | break; | 383 | break; |
391 | } | 384 | } |
392 | 385 | ||
393 | switch (size){ | 386 | switch (size) { |
394 | case 1: | 387 | case 1: |
395 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", | 388 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", |
396 | indentstr,tag,maintype,size,globtype,data); | 389 | indentstr, tag, maintype, size, globtype, data); |
397 | break; | 390 | break; |
391 | |||
398 | case 2: | 392 | case 2: |
399 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", | 393 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", |
400 | indentstr,tag,maintype,size,globtype, data16); | 394 | indentstr, tag, maintype, size, globtype, data16); |
401 | break; | 395 | break; |
396 | |||
402 | case 4: | 397 | case 4: |
403 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", | 398 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", |
404 | indentstr,tag,maintype,size,globtype,data32); | 399 | indentstr, tag, maintype, size, globtype, data32); |
405 | break; | 400 | break; |
406 | } | 401 | } |
407 | break; | 402 | break; |
403 | |||
408 | case TYPE_GLOBAL: | 404 | case TYPE_GLOBAL: |
409 | switch(tag){ | 405 | switch (tag) { |
410 | case TAG_GLOB_USAGE: | 406 | case TAG_GLOB_USAGE: |
411 | /* | 407 | /* |
412 | * First time we hit the global usage tag, | 408 | * First time we hit the global usage tag, |
413 | * it should tell us the type of device | 409 | * it should tell us the type of device |
414 | */ | 410 | */ |
415 | if (device->usage == 0){ | 411 | if (device->usage == 0) |
416 | device->usage = data; | 412 | device->usage = data; |
417 | } | 413 | |
418 | strcpy(globtype,"USAGE"); | 414 | strcpy(globtype, "USAGE"); |
419 | break; | 415 | break; |
420 | case TAG_GLOB_LOG_MIN : | 416 | |
421 | strcpy(globtype,"LOG_MIN"); | 417 | case TAG_GLOB_LOG_MIN: |
418 | strcpy(globtype, "LOG_MIN"); | ||
422 | break; | 419 | break; |
423 | case TAG_GLOB_LOG_MAX : | 420 | |
424 | strcpy(globtype,"LOG_MAX"); | 421 | case TAG_GLOB_LOG_MAX: |
422 | strcpy(globtype, "LOG_MAX"); | ||
425 | break; | 423 | break; |
426 | case TAG_GLOB_PHYS_MIN : | 424 | |
427 | strcpy(globtype,"PHYS_MIN"); | 425 | case TAG_GLOB_PHYS_MIN: |
426 | strcpy(globtype, "PHYS_MIN"); | ||
428 | break; | 427 | break; |
429 | case TAG_GLOB_PHYS_MAX : | 428 | |
430 | strcpy(globtype,"PHYS_MAX"); | 429 | case TAG_GLOB_PHYS_MAX: |
430 | strcpy(globtype, "PHYS_MAX"); | ||
431 | break; | 431 | break; |
432 | case TAG_GLOB_UNIT_EXP : | 432 | |
433 | strcpy(globtype,"EXP"); | 433 | case TAG_GLOB_UNIT_EXP: |
434 | strcpy(globtype, "EXP"); | ||
434 | break; | 435 | break; |
435 | case TAG_GLOB_UNIT : | 436 | |
436 | strcpy(globtype,"UNIT"); | 437 | case TAG_GLOB_UNIT: |
438 | strcpy(globtype, "UNIT"); | ||
437 | break; | 439 | break; |
438 | case TAG_GLOB_REPORT_SZ : | 440 | |
439 | strcpy(globtype,"REPORT_SZ"); | 441 | case TAG_GLOB_REPORT_SZ: |
442 | strcpy(globtype, "REPORT_SZ"); | ||
440 | break; | 443 | break; |
441 | case TAG_GLOB_REPORT_ID : | 444 | |
442 | strcpy(globtype,"REPORT_ID"); | 445 | case TAG_GLOB_REPORT_ID: |
446 | strcpy(globtype, "REPORT_ID"); | ||
443 | /* New report, restart numbering */ | 447 | /* New report, restart numbering */ |
444 | inputnum=0; | 448 | inputnum = 0; |
445 | break; | 449 | break; |
450 | |||
446 | case TAG_GLOB_REPORT_CNT: | 451 | case TAG_GLOB_REPORT_CNT: |
447 | strcpy(globtype,"REPORT_CNT"); | 452 | strcpy(globtype, "REPORT_CNT"); |
448 | break; | 453 | break; |
449 | case TAG_GLOB_PUSH : | 454 | |
450 | strcpy(globtype,"PUSH"); | 455 | case TAG_GLOB_PUSH: |
456 | strcpy(globtype, "PUSH"); | ||
451 | break; | 457 | break; |
458 | |||
452 | case TAG_GLOB_POP: | 459 | case TAG_GLOB_POP: |
453 | strcpy(globtype,"POP"); | 460 | strcpy(globtype, "POP"); |
454 | break; | 461 | break; |
455 | } | 462 | } |
456 | 463 | ||
457 | |||
458 | /* Check to make sure we have a good tag number | 464 | /* Check to make sure we have a good tag number |
459 | so we don't overflow array */ | 465 | so we don't overflow array */ |
460 | if (tag < TAG_GLOB_MAX){ | 466 | if (tag < TAG_GLOB_MAX) { |
461 | switch (size){ | 467 | switch (size) { |
462 | case 1: | 468 | case 1: |
463 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data); | 469 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x", |
464 | globalval[tag]=data; | 470 | indentstr, globtype, tag, size, data); |
471 | globalval[tag] = data; | ||
465 | break; | 472 | break; |
473 | |||
466 | case 2: | 474 | case 2: |
467 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data16); | 475 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x", |
468 | globalval[tag]=data16; | 476 | indentstr, globtype, tag, size, data16); |
477 | globalval[tag] = data16; | ||
469 | break; | 478 | break; |
479 | |||
470 | case 4: | 480 | case 4: |
471 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data32); | 481 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x", |
472 | globalval[tag]=data32; | 482 | indentstr, globtype, tag, size, data32); |
483 | globalval[tag] = data32; | ||
473 | break; | 484 | break; |
474 | } | 485 | } |
475 | }else{ | 486 | } else { |
476 | dbg("%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d ", | 487 | dbg("%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d ", |
477 | indentstr,tag,size); | 488 | indentstr, tag, size); |
478 | } | 489 | } |
479 | |||
480 | |||
481 | break; | 490 | break; |
482 | 491 | ||
483 | case TYPE_LOCAL: | 492 | case TYPE_LOCAL: |
484 | switch(tag){ | 493 | switch (tag) { |
485 | case TAG_GLOB_USAGE: | 494 | case TAG_GLOB_USAGE: |
486 | strcpy(globtype,"USAGE"); | 495 | strcpy(globtype, "USAGE"); |
487 | /* Always 1 byte */ | 496 | /* Always 1 byte */ |
488 | usage = data; | 497 | usage = data; |
489 | break; | 498 | break; |
490 | case TAG_GLOB_LOG_MIN : | 499 | |
491 | strcpy(globtype,"MIN"); | 500 | case TAG_GLOB_LOG_MIN: |
501 | strcpy(globtype, "MIN"); | ||
492 | break; | 502 | break; |
493 | case TAG_GLOB_LOG_MAX : | 503 | |
494 | strcpy(globtype,"MAX"); | 504 | case TAG_GLOB_LOG_MAX: |
505 | strcpy(globtype, "MAX"); | ||
495 | break; | 506 | break; |
507 | |||
496 | default: | 508 | default: |
497 | strcpy(globtype,"UNKNOWN"); | 509 | strcpy(globtype, "UNKNOWN"); |
510 | break; | ||
498 | } | 511 | } |
499 | 512 | ||
500 | switch (size){ | 513 | switch (size) { |
501 | case 1: | 514 | case 1: |
502 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", | 515 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", |
503 | indentstr,tag,globtype,size,data); | 516 | indentstr, tag, globtype, size, data); |
504 | break; | 517 | break; |
518 | |||
505 | case 2: | 519 | case 2: |
506 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", | 520 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", |
507 | indentstr,tag,globtype,size,data16); | 521 | indentstr, tag, globtype, size, data16); |
508 | break; | 522 | break; |
523 | |||
509 | case 4: | 524 | case 4: |
510 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", | 525 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", |
511 | indentstr,tag,globtype,size,data32); | 526 | indentstr, tag, globtype, size, data32); |
512 | break; | 527 | break; |
513 | } | 528 | } |
514 | 529 | ||
515 | break; | 530 | break; |
516 | } | 531 | } |
517 | |||
518 | } | 532 | } |
519 | |||
520 | } | 533 | } |
521 | 534 | ||
522 | |||
523 | |||
524 | /* INPUT DRIVER Routines */ | 535 | /* INPUT DRIVER Routines */ |
525 | 536 | ||
526 | |||
527 | /* | 537 | /* |
528 | * Called when opening the input device. This will submit the URB to | 538 | * Called when opening the input device. This will submit the URB to |
529 | * the usb system so we start getting reports | 539 | * the usb system so we start getting reports |
530 | */ | 540 | */ |
531 | static int gtco_input_open(struct input_dev *inputdev) | 541 | static int gtco_input_open(struct input_dev *inputdev) |
532 | { | 542 | { |
533 | struct gtco *device; | 543 | struct gtco *device = input_get_drvdata(inputdev); |
534 | device = inputdev->private; | ||
535 | 544 | ||
536 | device->urbinfo->dev = device->usbdev; | 545 | device->urbinfo->dev = device->usbdev; |
537 | if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) { | 546 | if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) |
538 | return -EIO; | 547 | return -EIO; |
539 | } | 548 | |
540 | return 0; | 549 | return 0; |
541 | } | 550 | } |
542 | 551 | ||
543 | /** | 552 | /* |
544 | Called when closing the input device. This will unlink the URB | 553 | * Called when closing the input device. This will unlink the URB |
545 | */ | 554 | */ |
546 | static void gtco_input_close(struct input_dev *inputdev) | 555 | static void gtco_input_close(struct input_dev *inputdev) |
547 | { | 556 | { |
548 | struct gtco *device = inputdev->private; | 557 | struct gtco *device = input_get_drvdata(inputdev); |
549 | 558 | ||
550 | usb_kill_urb(device->urbinfo); | 559 | usb_kill_urb(device->urbinfo); |
551 | |||
552 | } | 560 | } |
553 | 561 | ||
554 | 562 | ||
@@ -560,19 +568,16 @@ static void gtco_input_close(struct input_dev *inputdev) | |||
560 | * placed in the struct gtco structure | 568 | * placed in the struct gtco structure |
561 | * | 569 | * |
562 | */ | 570 | */ |
563 | static void gtco_setup_caps(struct input_dev *inputdev) | 571 | static void gtco_setup_caps(struct input_dev *inputdev) |
564 | { | 572 | { |
565 | struct gtco *device = inputdev->private; | 573 | struct gtco *device = input_get_drvdata(inputdev); |
566 | |||
567 | 574 | ||
568 | /* Which events */ | 575 | /* Which events */ |
569 | inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | 576 | inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); |
570 | 577 | ||
571 | |||
572 | /* Misc event menu block */ | 578 | /* Misc event menu block */ |
573 | inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ; | 579 | inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ; |
574 | 580 | ||
575 | |||
576 | /* Absolute values based on HID report info */ | 581 | /* Absolute values based on HID report info */ |
577 | input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, | 582 | input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, |
578 | 0, 0); | 583 | 0, 0); |
@@ -590,17 +595,12 @@ static void gtco_setup_caps(struct input_dev *inputdev) | |||
590 | input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure, | 595 | input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure, |
591 | device->maxpressure, 0, 0); | 596 | device->maxpressure, 0, 0); |
592 | 597 | ||
593 | |||
594 | /* Transducer */ | 598 | /* Transducer */ |
595 | input_set_abs_params(inputdev, ABS_MISC, 0,0xFF, 0, 0); | 599 | input_set_abs_params(inputdev, ABS_MISC, 0, 0xFF, 0, 0); |
596 | |||
597 | } | 600 | } |
598 | 601 | ||
599 | |||
600 | |||
601 | /* USB Routines */ | 602 | /* USB Routines */ |
602 | 603 | ||
603 | |||
604 | /* | 604 | /* |
605 | * URB callback routine. Called when we get IRQ reports from the | 605 | * URB callback routine. Called when we get IRQ reports from the |
606 | * digitizer. | 606 | * digitizer. |
@@ -610,9 +610,7 @@ static void gtco_setup_caps(struct input_dev *inputdev) | |||
610 | */ | 610 | */ |
611 | static void gtco_urb_callback(struct urb *urbinfo) | 611 | static void gtco_urb_callback(struct urb *urbinfo) |
612 | { | 612 | { |
613 | 613 | struct gtco *device = urbinfo->context; | |
614 | |||
615 | struct gtco *device = urbinfo->context; | ||
616 | struct input_dev *inputdev; | 614 | struct input_dev *inputdev; |
617 | int rc; | 615 | int rc; |
618 | u32 val = 0; | 616 | u32 val = 0; |
@@ -621,19 +619,20 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
621 | 619 | ||
622 | inputdev = device->inputdevice; | 620 | inputdev = device->inputdevice; |
623 | 621 | ||
624 | |||
625 | /* Was callback OK? */ | 622 | /* Was callback OK? */ |
626 | if ((urbinfo->status == -ECONNRESET ) || | 623 | if (urbinfo->status == -ECONNRESET || |
627 | (urbinfo->status == -ENOENT ) || | 624 | urbinfo->status == -ENOENT || |
628 | (urbinfo->status == -ESHUTDOWN )){ | 625 | urbinfo->status == -ESHUTDOWN) { |
629 | 626 | ||
630 | /* Shutdown is occurring. Return and don't queue up any more */ | 627 | /* Shutdown is occurring. Return and don't queue up any more */ |
631 | return; | 628 | return; |
632 | } | 629 | } |
633 | 630 | ||
634 | if (urbinfo->status != 0 ) { | 631 | if (urbinfo->status != 0) { |
635 | /* Some unknown error. Hopefully temporary. Just go and */ | 632 | /* |
636 | /* requeue an URB */ | 633 | * Some unknown error. Hopefully temporary. Just go and |
634 | * requeue an URB | ||
635 | */ | ||
637 | goto resubmit; | 636 | goto resubmit; |
638 | } | 637 | } |
639 | 638 | ||
@@ -642,10 +641,9 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
642 | */ | 641 | */ |
643 | 642 | ||
644 | /* PID dependent when we interpret the report */ | 643 | /* PID dependent when we interpret the report */ |
645 | if ((inputdev->id.product == PID_1000 )|| | 644 | if (inputdev->id.product == PID_1000 || |
646 | (inputdev->id.product == PID_1001 )|| | 645 | inputdev->id.product == PID_1001 || |
647 | (inputdev->id.product == PID_1002 )) | 646 | inputdev->id.product == PID_1002) { |
648 | { | ||
649 | 647 | ||
650 | /* | 648 | /* |
651 | * Switch on the report ID | 649 | * Switch on the report ID |
@@ -653,10 +651,10 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
653 | * the report number. We can just fall through the case | 651 | * the report number. We can just fall through the case |
654 | * statements if we start with the highest number report | 652 | * statements if we start with the highest number report |
655 | */ | 653 | */ |
656 | switch(device->buffer[0]){ | 654 | switch (device->buffer[0]) { |
657 | case 5: | 655 | case 5: |
658 | /* Pressure is 9 bits */ | 656 | /* Pressure is 9 bits */ |
659 | val = ((u16)(device->buffer[8]) << 1); | 657 | val = ((u16)(device->buffer[8]) << 1); |
660 | val |= (u16)(device->buffer[7] >> 7); | 658 | val |= (u16)(device->buffer[7] >> 7); |
661 | input_report_abs(inputdev, ABS_PRESSURE, | 659 | input_report_abs(inputdev, ABS_PRESSURE, |
662 | device->buffer[8]); | 660 | device->buffer[8]); |
@@ -664,7 +662,6 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
664 | /* Mask out the Y tilt value used for pressure */ | 662 | /* Mask out the Y tilt value used for pressure */ |
665 | device->buffer[7] = (u8)((device->buffer[7]) & 0x7F); | 663 | device->buffer[7] = (u8)((device->buffer[7]) & 0x7F); |
666 | 664 | ||
667 | |||
668 | /* Fall thru */ | 665 | /* Fall thru */ |
669 | case 4: | 666 | case 4: |
670 | /* Tilt */ | 667 | /* Tilt */ |
@@ -684,11 +681,10 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
684 | input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned); | 681 | input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned); |
685 | 682 | ||
686 | /* Fall thru */ | 683 | /* Fall thru */ |
687 | |||
688 | case 2: | 684 | case 2: |
689 | case 3: | 685 | case 3: |
690 | /* Convert buttons, only 5 bits possible */ | 686 | /* Convert buttons, only 5 bits possible */ |
691 | val = (device->buffer[5])&MASK_BUTTON; | 687 | val = (device->buffer[5]) & MASK_BUTTON; |
692 | 688 | ||
693 | /* We don't apply any meaning to the bitmask, | 689 | /* We don't apply any meaning to the bitmask, |
694 | just report */ | 690 | just report */ |
@@ -696,132 +692,109 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
696 | 692 | ||
697 | /* Fall thru */ | 693 | /* Fall thru */ |
698 | case 1: | 694 | case 1: |
699 | |||
700 | /* All reports have X and Y coords in the same place */ | 695 | /* All reports have X and Y coords in the same place */ |
701 | val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[1]))); | 696 | val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1])); |
702 | input_report_abs(inputdev, ABS_X, val); | 697 | input_report_abs(inputdev, ABS_X, val); |
703 | 698 | ||
704 | val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[3]))); | 699 | val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3])); |
705 | input_report_abs(inputdev, ABS_Y, val); | 700 | input_report_abs(inputdev, ABS_Y, val); |
706 | 701 | ||
707 | |||
708 | /* Ditto for proximity bit */ | 702 | /* Ditto for proximity bit */ |
709 | if (device->buffer[5]& MASK_INRANGE){ | 703 | val = device->buffer[5] & MASK_INRANGE ? 1 : 0; |
710 | val = 1; | ||
711 | }else{ | ||
712 | val=0; | ||
713 | } | ||
714 | input_report_abs(inputdev, ABS_DISTANCE, val); | 704 | input_report_abs(inputdev, ABS_DISTANCE, val); |
715 | 705 | ||
716 | |||
717 | /* Report 1 is an exception to how we handle buttons */ | 706 | /* Report 1 is an exception to how we handle buttons */ |
718 | /* Buttons are an index, not a bitmask */ | 707 | /* Buttons are an index, not a bitmask */ |
719 | if (device->buffer[0] == 1){ | 708 | if (device->buffer[0] == 1) { |
720 | 709 | ||
721 | /* Convert buttons, 5 bit index */ | 710 | /* |
722 | /* Report value of index set as one, | 711 | * Convert buttons, 5 bit index |
723 | the rest as 0 */ | 712 | * Report value of index set as one, |
724 | val = device->buffer[5]& MASK_BUTTON; | 713 | * the rest as 0 |
714 | */ | ||
715 | val = device->buffer[5] & MASK_BUTTON; | ||
725 | dbg("======>>>>>>REPORT 1: val 0x%X(%d)", | 716 | dbg("======>>>>>>REPORT 1: val 0x%X(%d)", |
726 | val,val); | 717 | val, val); |
727 | 718 | ||
728 | /* | 719 | /* |
729 | * We don't apply any meaning to the button | 720 | * We don't apply any meaning to the button |
730 | * index, just report it | 721 | * index, just report it |
731 | */ | 722 | */ |
732 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); | 723 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); |
733 | |||
734 | |||
735 | } | 724 | } |
736 | |||
737 | break; | 725 | break; |
726 | |||
738 | case 7: | 727 | case 7: |
739 | /* Menu blocks */ | 728 | /* Menu blocks */ |
740 | input_event(inputdev, EV_MSC, MSC_SCAN, | 729 | input_event(inputdev, EV_MSC, MSC_SCAN, |
741 | device->buffer[1]); | 730 | device->buffer[1]); |
742 | |||
743 | |||
744 | break; | 731 | break; |
745 | |||
746 | } | 732 | } |
747 | |||
748 | |||
749 | } | 733 | } |
734 | |||
750 | /* Other pid class */ | 735 | /* Other pid class */ |
751 | if ((inputdev->id.product == PID_400 )|| | 736 | if (inputdev->id.product == PID_400 || |
752 | (inputdev->id.product == PID_401 )) | 737 | inputdev->id.product == PID_401) { |
753 | { | ||
754 | 738 | ||
755 | /* Report 2 */ | 739 | /* Report 2 */ |
756 | if (device->buffer[0] == 2){ | 740 | if (device->buffer[0] == 2) { |
757 | /* Menu blocks */ | 741 | /* Menu blocks */ |
758 | input_event(inputdev, EV_MSC, MSC_SCAN, | 742 | input_event(inputdev, EV_MSC, MSC_SCAN, device->buffer[1]); |
759 | device->buffer[1]); | ||
760 | } | 743 | } |
761 | 744 | ||
762 | /* Report 1 */ | 745 | /* Report 1 */ |
763 | if (device->buffer[0] == 1){ | 746 | if (device->buffer[0] == 1) { |
764 | char buttonbyte; | 747 | char buttonbyte; |
765 | 748 | ||
766 | |||
767 | /* IF X max > 64K, we still a bit from the y report */ | 749 | /* IF X max > 64K, we still a bit from the y report */ |
768 | if (device->max_X > 0x10000){ | 750 | if (device->max_X > 0x10000) { |
769 | 751 | ||
770 | val = (u16)(((u16)(device->buffer[2]<<8))|((u8)(device->buffer[1]))); | 752 | val = (u16)(((u16)(device->buffer[2] << 8)) | (u8)device->buffer[1]); |
771 | val |= (u32)(((u8)device->buffer[3]&0x1)<< 16); | 753 | val |= (u32)(((u8)device->buffer[3] & 0x1) << 16); |
772 | 754 | ||
773 | input_report_abs(inputdev, ABS_X, val); | 755 | input_report_abs(inputdev, ABS_X, val); |
774 | 756 | ||
775 | le_buffer[0] = (u8)((u8)(device->buffer[3])>>1); | 757 | le_buffer[0] = (u8)((u8)(device->buffer[3]) >> 1); |
776 | le_buffer[0] |= (u8)((device->buffer[3]&0x1)<<7); | 758 | le_buffer[0] |= (u8)((device->buffer[3] & 0x1) << 7); |
777 | |||
778 | le_buffer[1] = (u8)(device->buffer[4]>>1); | ||
779 | le_buffer[1] |= (u8)((device->buffer[5]&0x1)<<7); | ||
780 | 759 | ||
781 | val = le16_to_cpu(get_unaligned((__le16 *)(le_buffer))); | 760 | le_buffer[1] = (u8)(device->buffer[4] >> 1); |
761 | le_buffer[1] |= (u8)((device->buffer[5] & 0x1) << 7); | ||
782 | 762 | ||
763 | val = le16_to_cpu(get_unaligned((__le16 *)le_buffer)); | ||
783 | input_report_abs(inputdev, ABS_Y, val); | 764 | input_report_abs(inputdev, ABS_Y, val); |
784 | 765 | ||
785 | |||
786 | /* | 766 | /* |
787 | * Shift the button byte right by one to | 767 | * Shift the button byte right by one to |
788 | * make it look like the standard report | 768 | * make it look like the standard report |
789 | */ | 769 | */ |
790 | buttonbyte = (device->buffer[5])>>1; | 770 | buttonbyte = device->buffer[5] >> 1; |
791 | }else{ | 771 | } else { |
792 | 772 | ||
793 | val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[1])))); | 773 | val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1])); |
794 | input_report_abs(inputdev, ABS_X, val); | 774 | input_report_abs(inputdev, ABS_X, val); |
795 | 775 | ||
796 | val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[3])))); | 776 | val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3])); |
797 | input_report_abs(inputdev, ABS_Y, val); | 777 | input_report_abs(inputdev, ABS_Y, val); |
798 | 778 | ||
799 | buttonbyte = device->buffer[5]; | 779 | buttonbyte = device->buffer[5]; |
800 | |||
801 | } | 780 | } |
802 | 781 | ||
803 | |||
804 | /* BUTTONS and PROXIMITY */ | 782 | /* BUTTONS and PROXIMITY */ |
805 | if (buttonbyte& MASK_INRANGE){ | 783 | val = buttonbyte & MASK_INRANGE ? 1 : 0; |
806 | val = 1; | ||
807 | }else{ | ||
808 | val=0; | ||
809 | } | ||
810 | input_report_abs(inputdev, ABS_DISTANCE, val); | 784 | input_report_abs(inputdev, ABS_DISTANCE, val); |
811 | 785 | ||
812 | /* Convert buttons, only 4 bits possible */ | 786 | /* Convert buttons, only 4 bits possible */ |
813 | val = buttonbyte&0x0F; | 787 | val = buttonbyte & 0x0F; |
814 | #ifdef USE_BUTTONS | 788 | #ifdef USE_BUTTONS |
815 | for ( i=0;i<5;i++){ | 789 | for (i = 0; i < 5; i++) |
816 | input_report_key(inputdev, BTN_DIGI+i,val&(1<<i)); | 790 | input_report_key(inputdev, BTN_DIGI + i, val & (1 << i)); |
817 | } | ||
818 | #else | 791 | #else |
819 | /* We don't apply any meaning to the bitmask, just report */ | 792 | /* We don't apply any meaning to the bitmask, just report */ |
820 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); | 793 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); |
821 | #endif | 794 | #endif |
795 | |||
822 | /* TRANSDUCER */ | 796 | /* TRANSDUCER */ |
823 | input_report_abs(inputdev, ABS_MISC, device->buffer[6]); | 797 | input_report_abs(inputdev, ABS_MISC, device->buffer[6]); |
824 | |||
825 | } | 798 | } |
826 | } | 799 | } |
827 | 800 | ||
@@ -833,10 +806,8 @@ static void gtco_urb_callback(struct urb *urbinfo) | |||
833 | 806 | ||
834 | resubmit: | 807 | resubmit: |
835 | rc = usb_submit_urb(urbinfo, GFP_ATOMIC); | 808 | rc = usb_submit_urb(urbinfo, GFP_ATOMIC); |
836 | if (rc != 0) { | 809 | if (rc != 0) |
837 | err("usb_submit_urb failed rc=0x%x",rc); | 810 | err("usb_submit_urb failed rc=0x%x", rc); |
838 | } | ||
839 | |||
840 | } | 811 | } |
841 | 812 | ||
842 | /* | 813 | /* |
@@ -854,58 +825,46 @@ static int gtco_probe(struct usb_interface *usbinterface, | |||
854 | const struct usb_device_id *id) | 825 | const struct usb_device_id *id) |
855 | { | 826 | { |
856 | 827 | ||
857 | struct gtco *device = NULL; | 828 | struct gtco *gtco; |
858 | char path[PATHLENGTH]; | 829 | struct input_dev *input_dev; |
859 | struct input_dev *inputdev; | ||
860 | struct hid_descriptor *hid_desc; | 830 | struct hid_descriptor *hid_desc; |
861 | char *report; | 831 | char *report = NULL; |
862 | int result=0, retry; | 832 | int result = 0, retry; |
833 | int error; | ||
863 | struct usb_endpoint_descriptor *endpoint; | 834 | struct usb_endpoint_descriptor *endpoint; |
864 | 835 | ||
865 | /* Allocate memory for device structure */ | 836 | /* Allocate memory for device structure */ |
866 | device = kzalloc(sizeof(struct gtco), GFP_KERNEL); | 837 | gtco = kzalloc(sizeof(struct gtco), GFP_KERNEL); |
867 | if (device == NULL) { | 838 | input_dev = input_allocate_device(); |
839 | if (!gtco || !input_dev) { | ||
868 | err("No more memory"); | 840 | err("No more memory"); |
869 | return -ENOMEM; | 841 | error = -ENOMEM; |
842 | goto err_free_devs; | ||
870 | } | 843 | } |
871 | 844 | ||
872 | 845 | /* Set pointer to the input device */ | |
873 | device->inputdevice = input_allocate_device(); | 846 | gtco->inputdevice = input_dev; |
874 | if (!device->inputdevice){ | ||
875 | kfree(device); | ||
876 | err("No more memory"); | ||
877 | return -ENOMEM; | ||
878 | } | ||
879 | |||
880 | /* Get pointer to the input device */ | ||
881 | inputdev = device->inputdevice; | ||
882 | 847 | ||
883 | /* Save interface information */ | 848 | /* Save interface information */ |
884 | device->usbdev = usb_get_dev(interface_to_usbdev(usbinterface)); | 849 | gtco->usbdev = usb_get_dev(interface_to_usbdev(usbinterface)); |
885 | |||
886 | 850 | ||
887 | /* Allocate some data for incoming reports */ | 851 | /* Allocate some data for incoming reports */ |
888 | device->buffer = usb_buffer_alloc(device->usbdev, REPORT_MAX_SIZE, | 852 | gtco->buffer = usb_buffer_alloc(gtco->usbdev, REPORT_MAX_SIZE, |
889 | GFP_KERNEL, &(device->buf_dma)); | 853 | GFP_KERNEL, >co->buf_dma); |
890 | if (!device->buffer){ | 854 | if (!gtco->buffer) { |
891 | input_free_device(device->inputdevice); | 855 | err("No more memory for us buffers"); |
892 | kfree(device); | 856 | error = -ENOMEM; |
893 | err("No more memory"); | 857 | goto err_free_devs; |
894 | return -ENOMEM; | ||
895 | } | 858 | } |
896 | 859 | ||
897 | /* Allocate URB for reports */ | 860 | /* Allocate URB for reports */ |
898 | device->urbinfo = usb_alloc_urb(0, GFP_KERNEL); | 861 | gtco->urbinfo = usb_alloc_urb(0, GFP_KERNEL); |
899 | if (!device->urbinfo) { | 862 | if (!gtco->urbinfo) { |
900 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | 863 | err("Failed to allocate URB"); |
901 | device->buffer, device->buf_dma); | ||
902 | input_free_device(device->inputdevice); | ||
903 | kfree(device); | ||
904 | err("No more memory"); | ||
905 | return -ENOMEM; | 864 | return -ENOMEM; |
865 | goto err_free_buf; | ||
906 | } | 866 | } |
907 | 867 | ||
908 | |||
909 | /* | 868 | /* |
910 | * The endpoint is always altsetting 0, we know this since we know | 869 | * The endpoint is always altsetting 0, we know this since we know |
911 | * this device only has one interrupt endpoint | 870 | * this device only has one interrupt endpoint |
@@ -913,51 +872,43 @@ static int gtco_probe(struct usb_interface *usbinterface, | |||
913 | endpoint = &usbinterface->altsetting[0].endpoint[0].desc; | 872 | endpoint = &usbinterface->altsetting[0].endpoint[0].desc; |
914 | 873 | ||
915 | /* Some debug */ | 874 | /* Some debug */ |
916 | dbg("gtco # interfaces: %d",usbinterface->num_altsetting); | 875 | dbg("gtco # interfaces: %d", usbinterface->num_altsetting); |
917 | dbg("num endpoints: %d",usbinterface->cur_altsetting->desc.bNumEndpoints); | 876 | dbg("num endpoints: %d", usbinterface->cur_altsetting->desc.bNumEndpoints); |
918 | dbg("interface class: %d",usbinterface->cur_altsetting->desc.bInterfaceClass); | 877 | dbg("interface class: %d", usbinterface->cur_altsetting->desc.bInterfaceClass); |
919 | dbg("endpoint: attribute:0x%x type:0x%x",endpoint->bmAttributes,endpoint->bDescriptorType); | 878 | dbg("endpoint: attribute:0x%x type:0x%x", endpoint->bmAttributes, endpoint->bDescriptorType); |
920 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) | 879 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) |
921 | dbg("endpoint: we have interrupt endpoint\n"); | 880 | dbg("endpoint: we have interrupt endpoint\n"); |
922 | 881 | ||
923 | dbg("endpoint extra len:%d ",usbinterface->altsetting[0].extralen); | 882 | dbg("endpoint extra len:%d ", usbinterface->altsetting[0].extralen); |
924 | |||
925 | |||
926 | 883 | ||
927 | /* | 884 | /* |
928 | * Find the HID descriptor so we can find out the size of the | 885 | * Find the HID descriptor so we can find out the size of the |
929 | * HID report descriptor | 886 | * HID report descriptor |
930 | */ | 887 | */ |
931 | if (usb_get_extra_descriptor(usbinterface->cur_altsetting, | 888 | if (usb_get_extra_descriptor(usbinterface->cur_altsetting, |
932 | HID_DEVICE_TYPE,&hid_desc) != 0){ | 889 | HID_DEVICE_TYPE, &hid_desc) != 0){ |
933 | err("Can't retrieve exta USB descriptor to get hid report descriptor length"); | 890 | err("Can't retrieve exta USB descriptor to get hid report descriptor length"); |
934 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | 891 | error = -EIO; |
935 | device->buffer, device->buf_dma); | 892 | goto err_free_urb; |
936 | input_free_device(device->inputdevice); | ||
937 | kfree(device); | ||
938 | return -EIO; | ||
939 | } | 893 | } |
940 | 894 | ||
941 | dbg("Extra descriptor success: type:%d len:%d", | 895 | dbg("Extra descriptor success: type:%d len:%d", |
942 | hid_desc->bDescriptorType, hid_desc->wDescriptorLength); | 896 | hid_desc->bDescriptorType, hid_desc->wDescriptorLength); |
943 | 897 | ||
944 | if (!(report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL))) { | 898 | report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); |
945 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | 899 | if (!report) { |
946 | device->buffer, device->buf_dma); | 900 | err("No more memory for report"); |
947 | 901 | error = -ENOMEM; | |
948 | input_free_device(device->inputdevice); | 902 | goto err_free_urb; |
949 | kfree(device); | ||
950 | err("No more memory"); | ||
951 | return -ENOMEM; | ||
952 | } | 903 | } |
953 | 904 | ||
954 | /* Couple of tries to get reply */ | 905 | /* Couple of tries to get reply */ |
955 | for (retry=0;retry<3;retry++) { | 906 | for (retry = 0; retry < 3; retry++) { |
956 | result = usb_control_msg(device->usbdev, | 907 | result = usb_control_msg(gtco->usbdev, |
957 | usb_rcvctrlpipe(device->usbdev, 0), | 908 | usb_rcvctrlpipe(gtco->usbdev, 0), |
958 | USB_REQ_GET_DESCRIPTOR, | 909 | USB_REQ_GET_DESCRIPTOR, |
959 | USB_RECIP_INTERFACE | USB_DIR_IN, | 910 | USB_RECIP_INTERFACE | USB_DIR_IN, |
960 | (REPORT_DEVICE_TYPE << 8), | 911 | REPORT_DEVICE_TYPE << 8, |
961 | 0, /* interface */ | 912 | 0, /* interface */ |
962 | report, | 913 | report, |
963 | hid_desc->wDescriptorLength, | 914 | hid_desc->wDescriptorLength, |
@@ -969,72 +920,76 @@ static int gtco_probe(struct usb_interface *usbinterface, | |||
969 | 920 | ||
970 | /* If we didn't get the report, fail */ | 921 | /* If we didn't get the report, fail */ |
971 | dbg("usb_control_msg result: :%d", result); | 922 | dbg("usb_control_msg result: :%d", result); |
972 | if (result != hid_desc->wDescriptorLength){ | 923 | if (result != hid_desc->wDescriptorLength) { |
973 | kfree(report); | ||
974 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | ||
975 | device->buffer, device->buf_dma); | ||
976 | input_free_device(device->inputdevice); | ||
977 | kfree(device); | ||
978 | err("Failed to get HID Report Descriptor of size: %d", | 924 | err("Failed to get HID Report Descriptor of size: %d", |
979 | hid_desc->wDescriptorLength); | 925 | hid_desc->wDescriptorLength); |
980 | return -EIO; | 926 | error = -EIO; |
927 | goto err_free_urb; | ||
981 | } | 928 | } |
982 | 929 | ||
983 | |||
984 | /* Now we parse the report */ | 930 | /* Now we parse the report */ |
985 | parse_hid_report_descriptor(device,report,result); | 931 | parse_hid_report_descriptor(gtco, report, result); |
986 | 932 | ||
987 | /* Now we delete it */ | 933 | /* Now we delete it */ |
988 | kfree(report); | 934 | kfree(report); |
989 | 935 | ||
990 | /* Create a device file node */ | 936 | /* Create a device file node */ |
991 | usb_make_path(device->usbdev, path, PATHLENGTH); | 937 | usb_make_path(gtco->usbdev, gtco->usbpath, sizeof(gtco->usbpath)); |
992 | sprintf(device->usbpath, "%s/input0", path); | 938 | strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath)); |
993 | |||
994 | 939 | ||
995 | /* Set Input device functions */ | 940 | /* Set Input device functions */ |
996 | inputdev->open = gtco_input_open; | 941 | input_dev->open = gtco_input_open; |
997 | inputdev->close = gtco_input_close; | 942 | input_dev->close = gtco_input_close; |
998 | 943 | ||
999 | /* Set input device information */ | 944 | /* Set input device information */ |
1000 | inputdev->name = "GTCO_CalComp"; | 945 | input_dev->name = "GTCO_CalComp"; |
1001 | inputdev->phys = device->usbpath; | 946 | input_dev->phys = gtco->usbpath; |
1002 | inputdev->private = device; | ||
1003 | 947 | ||
948 | input_set_drvdata(input_dev, gtco); | ||
1004 | 949 | ||
1005 | /* Now set up all the input device capabilities */ | 950 | /* Now set up all the input device capabilities */ |
1006 | gtco_setup_caps(inputdev); | 951 | gtco_setup_caps(input_dev); |
1007 | 952 | ||
1008 | /* Set input device required ID information */ | 953 | /* Set input device required ID information */ |
1009 | usb_to_input_id(device->usbdev, &device->inputdevice->id); | 954 | usb_to_input_id(gtco->usbdev, &input_dev->id); |
1010 | inputdev->cdev.dev = &usbinterface->dev; | 955 | input_dev->dev.parent = &usbinterface->dev; |
1011 | 956 | ||
1012 | /* Setup the URB, it will be posted later on open of input device */ | 957 | /* Setup the URB, it will be posted later on open of input device */ |
1013 | endpoint = &usbinterface->altsetting[0].endpoint[0].desc; | 958 | endpoint = &usbinterface->altsetting[0].endpoint[0].desc; |
1014 | 959 | ||
1015 | usb_fill_int_urb(device->urbinfo, | 960 | usb_fill_int_urb(gtco->urbinfo, |
1016 | device->usbdev, | 961 | gtco->usbdev, |
1017 | usb_rcvintpipe(device->usbdev, | 962 | usb_rcvintpipe(gtco->usbdev, |
1018 | endpoint->bEndpointAddress), | 963 | endpoint->bEndpointAddress), |
1019 | device->buffer, | 964 | gtco->buffer, |
1020 | REPORT_MAX_SIZE, | 965 | REPORT_MAX_SIZE, |
1021 | gtco_urb_callback, | 966 | gtco_urb_callback, |
1022 | device, | 967 | gtco, |
1023 | endpoint->bInterval); | 968 | endpoint->bInterval); |
1024 | 969 | ||
1025 | device->urbinfo->transfer_dma = device->buf_dma; | 970 | gtco->urbinfo->transfer_dma = gtco->buf_dma; |
1026 | device->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 971 | gtco->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
1027 | |||
1028 | 972 | ||
1029 | /* Save device pointer in USB interface device */ | 973 | /* Save gtco pointer in USB interface gtco */ |
1030 | usb_set_intfdata(usbinterface, device); | 974 | usb_set_intfdata(usbinterface, gtco); |
1031 | 975 | ||
1032 | /* All done, now register the input device */ | 976 | /* All done, now register the input device */ |
1033 | input_register_device(inputdev); | 977 | error = input_register_device(input_dev); |
978 | if (error) | ||
979 | goto err_free_urb; | ||
1034 | 980 | ||
1035 | info( "gtco driver created usb: %s\n", path); | ||
1036 | return 0; | 981 | return 0; |
1037 | 982 | ||
983 | err_free_urb: | ||
984 | usb_free_urb(gtco->urbinfo); | ||
985 | err_free_buf: | ||
986 | usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE, | ||
987 | gtco->buffer, gtco->buf_dma); | ||
988 | err_free_devs: | ||
989 | kfree(report); | ||
990 | input_free_device(input_dev); | ||
991 | kfree(gtco); | ||
992 | return error; | ||
1038 | } | 993 | } |
1039 | 994 | ||
1040 | /* | 995 | /* |
@@ -1044,47 +999,46 @@ static int gtco_probe(struct usb_interface *usbinterface, | |||
1044 | */ | 999 | */ |
1045 | static void gtco_disconnect(struct usb_interface *interface) | 1000 | static void gtco_disconnect(struct usb_interface *interface) |
1046 | { | 1001 | { |
1047 | |||
1048 | /* Grab private device ptr */ | 1002 | /* Grab private device ptr */ |
1049 | struct gtco *device = usb_get_intfdata (interface); | 1003 | struct gtco *gtco = usb_get_intfdata(interface); |
1050 | 1004 | ||
1051 | /* Now reverse all the registration stuff */ | 1005 | /* Now reverse all the registration stuff */ |
1052 | if (device) { | 1006 | if (gtco) { |
1053 | input_unregister_device(device->inputdevice); | 1007 | input_unregister_device(gtco->inputdevice); |
1054 | usb_kill_urb(device->urbinfo); | 1008 | usb_kill_urb(gtco->urbinfo); |
1055 | usb_free_urb(device->urbinfo); | 1009 | usb_free_urb(gtco->urbinfo); |
1056 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | 1010 | usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE, |
1057 | device->buffer, device->buf_dma); | 1011 | gtco->buffer, gtco->buf_dma); |
1058 | kfree(device); | 1012 | kfree(gtco); |
1059 | } | 1013 | } |
1060 | 1014 | ||
1061 | info("gtco driver disconnected"); | 1015 | info("gtco driver disconnected"); |
1062 | } | 1016 | } |
1063 | 1017 | ||
1064 | |||
1065 | /* STANDARD MODULE LOAD ROUTINES */ | 1018 | /* STANDARD MODULE LOAD ROUTINES */ |
1066 | 1019 | ||
1067 | static struct usb_driver gtco_driverinfo_table = { | 1020 | static struct usb_driver gtco_driverinfo_table = { |
1068 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) | 1021 | .name = "gtco", |
1069 | .owner = THIS_MODULE, | 1022 | .id_table = gtco_usbid_table, |
1070 | #endif | 1023 | .probe = gtco_probe, |
1071 | .name = "gtco", | 1024 | .disconnect = gtco_disconnect, |
1072 | .id_table = gtco_usbid_table, | ||
1073 | .probe = gtco_probe, | ||
1074 | .disconnect = gtco_disconnect, | ||
1075 | }; | 1025 | }; |
1026 | |||
1076 | /* | 1027 | /* |
1077 | * Register this module with the USB subsystem | 1028 | * Register this module with the USB subsystem |
1078 | */ | 1029 | */ |
1079 | static int __init gtco_init(void) | 1030 | static int __init gtco_init(void) |
1080 | { | 1031 | { |
1081 | int rc; | 1032 | int error; |
1082 | rc = usb_register(>co_driverinfo_table); | 1033 | |
1083 | if (rc) { | 1034 | error = usb_register(>co_driverinfo_table); |
1084 | err("usb_register() failed rc=0x%x", rc); | 1035 | if (error) { |
1036 | err("usb_register() failed rc=0x%x", error); | ||
1037 | return error; | ||
1085 | } | 1038 | } |
1086 | printk("GTCO usb driver version: %s",GTCO_VERSION); | 1039 | |
1087 | return rc; | 1040 | printk("GTCO usb driver version: %s", GTCO_VERSION); |
1041 | return 0; | ||
1088 | } | 1042 | } |
1089 | 1043 | ||
1090 | /* | 1044 | /* |
@@ -1095,7 +1049,7 @@ static void __exit gtco_exit(void) | |||
1095 | usb_deregister(>co_driverinfo_table); | 1049 | usb_deregister(>co_driverinfo_table); |
1096 | } | 1050 | } |
1097 | 1051 | ||
1098 | module_init (gtco_init); | 1052 | module_init(gtco_init); |
1099 | module_exit (gtco_exit); | 1053 | module_exit(gtco_exit); |
1100 | 1054 | ||
1101 | MODULE_LICENSE("GPL"); | 1055 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c deleted file mode 100644 index aac968aab860..000000000000 --- a/drivers/usb/input/itmtouch.c +++ /dev/null | |||
@@ -1,271 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * itmtouch.c -- Driver for ITM touchscreen panel | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation; either version 2 of the | ||
7 | * License, or (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | * | ||
18 | * Based upon original work by Chris Collins <xfire-itmtouch@xware.cx>. | ||
19 | * | ||
20 | * Kudos to ITM for providing me with the datasheet for the panel, | ||
21 | * even though it was a day later than I had finished writing this | ||
22 | * driver. | ||
23 | * | ||
24 | * It has meant that I've been able to correct my interpretation of the | ||
25 | * protocol packets however. | ||
26 | * | ||
27 | * CC -- 2003/9/29 | ||
28 | * | ||
29 | * History | ||
30 | * 1.0 & 1.1 2003 (CC) vojtech@suse.cz | ||
31 | * Original version for 2.4.x kernels | ||
32 | * | ||
33 | * 1.2 02/03/2005 (HCE) hc@mivu.no | ||
34 | * Complete rewrite to support Linux 2.6.10, thanks to mtouchusb.c for hints. | ||
35 | * Unfortunately no calibration support at this time. | ||
36 | * | ||
37 | * 1.2.1 09/03/2005 (HCE) hc@mivu.no | ||
38 | * Code cleanup and adjusting syntax to start matching kernel standards | ||
39 | * | ||
40 | * 1.2.2 10/05/2006 (MJA) massad@gmail.com | ||
41 | * Flag for detecting if the screen was being touch was incorrectly | ||
42 | * inverted, so no touch events were being detected. | ||
43 | * | ||
44 | *****************************************************************************/ | ||
45 | |||
46 | #include <linux/kernel.h> | ||
47 | #include <linux/slab.h> | ||
48 | #include <linux/module.h> | ||
49 | #include <linux/init.h> | ||
50 | #include <linux/usb/input.h> | ||
51 | |||
52 | /* only an 8 byte buffer necessary for a single packet */ | ||
53 | #define ITM_BUFSIZE 8 | ||
54 | #define PATH_SIZE 64 | ||
55 | |||
56 | #define USB_VENDOR_ID_ITMINC 0x0403 | ||
57 | #define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9 | ||
58 | |||
59 | #define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>" | ||
60 | #define DRIVER_VERSION "v1.2.2" | ||
61 | #define DRIVER_DESC "USB ITM Inc Touch Panel Driver" | ||
62 | #define DRIVER_LICENSE "GPL" | ||
63 | |||
64 | MODULE_AUTHOR( DRIVER_AUTHOR ); | ||
65 | MODULE_DESCRIPTION( DRIVER_DESC ); | ||
66 | MODULE_LICENSE( DRIVER_LICENSE ); | ||
67 | |||
68 | struct itmtouch_dev { | ||
69 | struct usb_device *usbdev; /* usb device */ | ||
70 | struct input_dev *inputdev; /* input device */ | ||
71 | struct urb *readurb; /* urb */ | ||
72 | char rbuf[ITM_BUFSIZE]; /* data */ | ||
73 | int users; | ||
74 | char name[128]; | ||
75 | char phys[64]; | ||
76 | }; | ||
77 | |||
78 | static struct usb_device_id itmtouch_ids [] = { | ||
79 | { USB_DEVICE(USB_VENDOR_ID_ITMINC, USB_PRODUCT_ID_TOUCHPANEL) }, | ||
80 | { } | ||
81 | }; | ||
82 | |||
83 | static void itmtouch_irq(struct urb *urb) | ||
84 | { | ||
85 | struct itmtouch_dev *itmtouch = urb->context; | ||
86 | unsigned char *data = urb->transfer_buffer; | ||
87 | struct input_dev *dev = itmtouch->inputdev; | ||
88 | int retval; | ||
89 | |||
90 | switch (urb->status) { | ||
91 | case 0: | ||
92 | /* success */ | ||
93 | break; | ||
94 | case -ETIME: | ||
95 | /* this urb is timing out */ | ||
96 | dbg("%s - urb timed out - was the device unplugged?", | ||
97 | __FUNCTION__); | ||
98 | return; | ||
99 | case -ECONNRESET: | ||
100 | case -ENOENT: | ||
101 | case -ESHUTDOWN: | ||
102 | /* this urb is terminated, clean up */ | ||
103 | dbg("%s - urb shutting down with status: %d", | ||
104 | __FUNCTION__, urb->status); | ||
105 | return; | ||
106 | default: | ||
107 | dbg("%s - nonzero urb status received: %d", | ||
108 | __FUNCTION__, urb->status); | ||
109 | goto exit; | ||
110 | } | ||
111 | |||
112 | /* if pressure has been released, then don't report X/Y */ | ||
113 | if (!(data[7] & 0x20)) { | ||
114 | input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F)); | ||
115 | input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F)); | ||
116 | } | ||
117 | |||
118 | input_report_abs(dev, ABS_PRESSURE, (data[2] & 1) << 7 | (data[5] & 0x7F)); | ||
119 | input_report_key(dev, BTN_TOUCH, ~data[7] & 0x20); | ||
120 | input_sync(dev); | ||
121 | |||
122 | exit: | ||
123 | retval = usb_submit_urb (urb, GFP_ATOMIC); | ||
124 | if (retval) | ||
125 | printk(KERN_ERR "%s - usb_submit_urb failed with result: %d", | ||
126 | __FUNCTION__, retval); | ||
127 | } | ||
128 | |||
129 | static int itmtouch_open(struct input_dev *input) | ||
130 | { | ||
131 | struct itmtouch_dev *itmtouch = input->private; | ||
132 | |||
133 | itmtouch->readurb->dev = itmtouch->usbdev; | ||
134 | |||
135 | if (usb_submit_urb(itmtouch->readurb, GFP_KERNEL)) | ||
136 | return -EIO; | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static void itmtouch_close(struct input_dev *input) | ||
142 | { | ||
143 | struct itmtouch_dev *itmtouch = input->private; | ||
144 | |||
145 | usb_kill_urb(itmtouch->readurb); | ||
146 | } | ||
147 | |||
148 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
149 | { | ||
150 | struct itmtouch_dev *itmtouch; | ||
151 | struct input_dev *input_dev; | ||
152 | struct usb_host_interface *interface; | ||
153 | struct usb_endpoint_descriptor *endpoint; | ||
154 | struct usb_device *udev = interface_to_usbdev(intf); | ||
155 | unsigned int pipe; | ||
156 | unsigned int maxp; | ||
157 | |||
158 | interface = intf->cur_altsetting; | ||
159 | endpoint = &interface->endpoint[0].desc; | ||
160 | |||
161 | itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL); | ||
162 | input_dev = input_allocate_device(); | ||
163 | if (!itmtouch || !input_dev) { | ||
164 | err("%s - Out of memory.", __FUNCTION__); | ||
165 | goto fail; | ||
166 | } | ||
167 | |||
168 | itmtouch->usbdev = udev; | ||
169 | itmtouch->inputdev = input_dev; | ||
170 | |||
171 | if (udev->manufacturer) | ||
172 | strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name)); | ||
173 | |||
174 | if (udev->product) { | ||
175 | if (udev->manufacturer) | ||
176 | strlcat(itmtouch->name, " ", sizeof(itmtouch->name)); | ||
177 | strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name)); | ||
178 | } | ||
179 | |||
180 | if (!strlen(itmtouch->name)) | ||
181 | sprintf(itmtouch->name, "USB ITM touchscreen"); | ||
182 | |||
183 | usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys)); | ||
184 | strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys)); | ||
185 | |||
186 | input_dev->name = itmtouch->name; | ||
187 | input_dev->phys = itmtouch->phys; | ||
188 | usb_to_input_id(udev, &input_dev->id); | ||
189 | input_dev->cdev.dev = &intf->dev; | ||
190 | input_dev->private = itmtouch; | ||
191 | |||
192 | input_dev->open = itmtouch_open; | ||
193 | input_dev->close = itmtouch_close; | ||
194 | |||
195 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
196 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
197 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
198 | |||
199 | /* device limits */ | ||
200 | /* as specified by the ITM datasheet, X and Y are 12bit, | ||
201 | * Z (pressure) is 8 bit. However, the fields are defined up | ||
202 | * to 14 bits for future possible expansion. | ||
203 | */ | ||
204 | input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0); | ||
205 | input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0); | ||
206 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0); | ||
207 | |||
208 | /* initialise the URB so we can read from the transport stream */ | ||
209 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); | ||
210 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | ||
211 | |||
212 | if (maxp > ITM_BUFSIZE) | ||
213 | maxp = ITM_BUFSIZE; | ||
214 | |||
215 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); | ||
216 | if (!itmtouch->readurb) { | ||
217 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); | ||
218 | goto fail; | ||
219 | } | ||
220 | |||
221 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, | ||
222 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); | ||
223 | |||
224 | input_register_device(itmtouch->inputdev); | ||
225 | |||
226 | usb_set_intfdata(intf, itmtouch); | ||
227 | |||
228 | return 0; | ||
229 | |||
230 | fail: input_free_device(input_dev); | ||
231 | kfree(itmtouch); | ||
232 | return -ENOMEM; | ||
233 | } | ||
234 | |||
235 | static void itmtouch_disconnect(struct usb_interface *intf) | ||
236 | { | ||
237 | struct itmtouch_dev *itmtouch = usb_get_intfdata(intf); | ||
238 | |||
239 | usb_set_intfdata(intf, NULL); | ||
240 | |||
241 | if (itmtouch) { | ||
242 | input_unregister_device(itmtouch->inputdev); | ||
243 | usb_kill_urb(itmtouch->readurb); | ||
244 | usb_free_urb(itmtouch->readurb); | ||
245 | kfree(itmtouch); | ||
246 | } | ||
247 | } | ||
248 | |||
249 | MODULE_DEVICE_TABLE(usb, itmtouch_ids); | ||
250 | |||
251 | static struct usb_driver itmtouch_driver = { | ||
252 | .name = "itmtouch", | ||
253 | .probe = itmtouch_probe, | ||
254 | .disconnect = itmtouch_disconnect, | ||
255 | .id_table = itmtouch_ids, | ||
256 | }; | ||
257 | |||
258 | static int __init itmtouch_init(void) | ||
259 | { | ||
260 | info(DRIVER_DESC " " DRIVER_VERSION); | ||
261 | info(DRIVER_AUTHOR); | ||
262 | return usb_register(&itmtouch_driver); | ||
263 | } | ||
264 | |||
265 | static void __exit itmtouch_exit(void) | ||
266 | { | ||
267 | usb_deregister(&itmtouch_driver); | ||
268 | } | ||
269 | |||
270 | module_init(itmtouch_init); | ||
271 | module_exit(itmtouch_exit); | ||
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index fedbcb127c21..c4781b9d1297 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -100,7 +100,7 @@ MODULE_DEVICE_TABLE(usb, kbtab_ids); | |||
100 | 100 | ||
101 | static int kbtab_open(struct input_dev *dev) | 101 | static int kbtab_open(struct input_dev *dev) |
102 | { | 102 | { |
103 | struct kbtab *kbtab = dev->private; | 103 | struct kbtab *kbtab = input_get_drvdata(dev); |
104 | 104 | ||
105 | kbtab->irq->dev = kbtab->usbdev; | 105 | kbtab->irq->dev = kbtab->usbdev; |
106 | if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) | 106 | if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) |
@@ -111,7 +111,7 @@ static int kbtab_open(struct input_dev *dev) | |||
111 | 111 | ||
112 | static void kbtab_close(struct input_dev *dev) | 112 | static void kbtab_close(struct input_dev *dev) |
113 | { | 113 | { |
114 | struct kbtab *kbtab = dev->private; | 114 | struct kbtab *kbtab = input_get_drvdata(dev); |
115 | 115 | ||
116 | usb_kill_urb(kbtab->irq); | 116 | usb_kill_urb(kbtab->irq); |
117 | } | 117 | } |
@@ -122,6 +122,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
122 | struct usb_endpoint_descriptor *endpoint; | 122 | struct usb_endpoint_descriptor *endpoint; |
123 | struct kbtab *kbtab; | 123 | struct kbtab *kbtab; |
124 | struct input_dev *input_dev; | 124 | struct input_dev *input_dev; |
125 | int error = -ENOMEM; | ||
125 | 126 | ||
126 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); | 127 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
127 | input_dev = input_allocate_device(); | 128 | input_dev = input_allocate_device(); |
@@ -145,8 +146,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
145 | input_dev->name = "KB Gear Tablet"; | 146 | input_dev->name = "KB Gear Tablet"; |
146 | input_dev->phys = kbtab->phys; | 147 | input_dev->phys = kbtab->phys; |
147 | usb_to_input_id(dev, &input_dev->id); | 148 | usb_to_input_id(dev, &input_dev->id); |
148 | input_dev->cdev.dev = &intf->dev; | 149 | input_dev->dev.parent = &intf->dev; |
149 | input_dev->private = kbtab; | 150 | |
151 | input_set_drvdata(input_dev, kbtab); | ||
150 | 152 | ||
151 | input_dev->open = kbtab_open; | 153 | input_dev->open = kbtab_open; |
152 | input_dev->close = kbtab_close; | 154 | input_dev->close = kbtab_close; |
@@ -168,15 +170,19 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
168 | kbtab->irq->transfer_dma = kbtab->data_dma; | 170 | kbtab->irq->transfer_dma = kbtab->data_dma; |
169 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 171 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
170 | 172 | ||
171 | input_register_device(kbtab->dev); | 173 | error = input_register_device(kbtab->dev); |
174 | if (error) | ||
175 | goto fail3; | ||
172 | 176 | ||
173 | usb_set_intfdata(intf, kbtab); | 177 | usb_set_intfdata(intf, kbtab); |
178 | |||
174 | return 0; | 179 | return 0; |
175 | 180 | ||
176 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 181 | fail3: usb_free_urb(kbtab->irq); |
177 | fail1: input_free_device(input_dev); | 182 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); |
183 | fail1: input_free_device(input_dev); | ||
178 | kfree(kbtab); | 184 | kfree(kbtab); |
179 | return -ENOMEM; | 185 | return error; |
180 | } | 186 | } |
181 | 187 | ||
182 | static void kbtab_disconnect(struct usb_interface *intf) | 188 | static void kbtab_disconnect(struct usb_interface *intf) |
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 98bd323369c7..1bffc9fa98c2 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c | |||
@@ -394,7 +394,7 @@ resubmit: | |||
394 | 394 | ||
395 | static int keyspan_open(struct input_dev *dev) | 395 | static int keyspan_open(struct input_dev *dev) |
396 | { | 396 | { |
397 | struct usb_keyspan *remote = dev->private; | 397 | struct usb_keyspan *remote = input_get_drvdata(dev); |
398 | 398 | ||
399 | remote->irq_urb->dev = remote->udev; | 399 | remote->irq_urb->dev = remote->udev; |
400 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) | 400 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) |
@@ -405,7 +405,7 @@ static int keyspan_open(struct input_dev *dev) | |||
405 | 405 | ||
406 | static void keyspan_close(struct input_dev *dev) | 406 | static void keyspan_close(struct input_dev *dev) |
407 | { | 407 | { |
408 | struct usb_keyspan *remote = dev->private; | 408 | struct usb_keyspan *remote = input_get_drvdata(dev); |
409 | 409 | ||
410 | usb_kill_urb(remote->irq_urb); | 410 | usb_kill_urb(remote->irq_urb); |
411 | } | 411 | } |
@@ -437,7 +437,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
437 | struct usb_endpoint_descriptor *endpoint; | 437 | struct usb_endpoint_descriptor *endpoint; |
438 | struct usb_keyspan *remote; | 438 | struct usb_keyspan *remote; |
439 | struct input_dev *input_dev; | 439 | struct input_dev *input_dev; |
440 | int i, retval; | 440 | int i, error; |
441 | 441 | ||
442 | endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); | 442 | endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); |
443 | if (!endpoint) | 443 | if (!endpoint) |
@@ -446,7 +446,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
446 | remote = kzalloc(sizeof(*remote), GFP_KERNEL); | 446 | remote = kzalloc(sizeof(*remote), GFP_KERNEL); |
447 | input_dev = input_allocate_device(); | 447 | input_dev = input_allocate_device(); |
448 | if (!remote || !input_dev) { | 448 | if (!remote || !input_dev) { |
449 | retval = -ENOMEM; | 449 | error = -ENOMEM; |
450 | goto fail1; | 450 | goto fail1; |
451 | } | 451 | } |
452 | 452 | ||
@@ -458,19 +458,19 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
458 | 458 | ||
459 | remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma); | 459 | remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma); |
460 | if (!remote->in_buffer) { | 460 | if (!remote->in_buffer) { |
461 | retval = -ENOMEM; | 461 | error = -ENOMEM; |
462 | goto fail1; | 462 | goto fail1; |
463 | } | 463 | } |
464 | 464 | ||
465 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 465 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
466 | if (!remote->irq_urb) { | 466 | if (!remote->irq_urb) { |
467 | retval = -ENOMEM; | 467 | error = -ENOMEM; |
468 | goto fail2; | 468 | goto fail2; |
469 | } | 469 | } |
470 | 470 | ||
471 | retval = keyspan_setup(udev); | 471 | error = keyspan_setup(udev); |
472 | if (retval) { | 472 | if (error) { |
473 | retval = -ENODEV; | 473 | error = -ENODEV; |
474 | goto fail3; | 474 | goto fail3; |
475 | } | 475 | } |
476 | 476 | ||
@@ -495,14 +495,15 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
495 | input_dev->name = remote->name; | 495 | input_dev->name = remote->name; |
496 | input_dev->phys = remote->phys; | 496 | input_dev->phys = remote->phys; |
497 | usb_to_input_id(udev, &input_dev->id); | 497 | usb_to_input_id(udev, &input_dev->id); |
498 | input_dev->cdev.dev = &interface->dev; | 498 | input_dev->dev.parent = &interface->dev; |
499 | 499 | ||
500 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ | 500 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ |
501 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) | 501 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) |
502 | if (keyspan_key_table[i] != KEY_RESERVED) | 502 | if (keyspan_key_table[i] != KEY_RESERVED) |
503 | set_bit(keyspan_key_table[i], input_dev->keybit); | 503 | set_bit(keyspan_key_table[i], input_dev->keybit); |
504 | 504 | ||
505 | input_dev->private = remote; | 505 | input_set_drvdata(input_dev, remote); |
506 | |||
506 | input_dev->open = keyspan_open; | 507 | input_dev->open = keyspan_open; |
507 | input_dev->close = keyspan_close; | 508 | input_dev->close = keyspan_close; |
508 | 509 | ||
@@ -517,7 +518,9 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
517 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 518 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
518 | 519 | ||
519 | /* we can register the device now, as it is ready */ | 520 | /* we can register the device now, as it is ready */ |
520 | input_register_device(remote->input); | 521 | error = input_register_device(remote->input); |
522 | if (error) | ||
523 | goto fail3; | ||
521 | 524 | ||
522 | /* save our data pointer in this interface device */ | 525 | /* save our data pointer in this interface device */ |
523 | usb_set_intfdata(interface, remote); | 526 | usb_set_intfdata(interface, remote); |
@@ -529,7 +532,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
529 | fail1: kfree(remote); | 532 | fail1: kfree(remote); |
530 | input_free_device(input_dev); | 533 | input_free_device(input_dev); |
531 | 534 | ||
532 | return retval; | 535 | return error; |
533 | } | 536 | } |
534 | 537 | ||
535 | /* | 538 | /* |
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c deleted file mode 100644 index 92c4e07da4c8..000000000000 --- a/drivers/usb/input/mtouchusb.c +++ /dev/null | |||
@@ -1,332 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * mtouchusb.c -- Driver for Microtouch (Now 3M) USB Touchscreens | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation; either version 2 of the | ||
7 | * License, or (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | * | ||
18 | * Based upon original work by Radoslaw Garbacz (usb-support@ite.pl) | ||
19 | * (http://freshmeat.net/projects/3mtouchscreendriver) | ||
20 | * | ||
21 | * History | ||
22 | * | ||
23 | * 0.3 & 0.4 2002 (TEJ) tejohnson@yahoo.com | ||
24 | * Updated to 2.4.18, then 2.4.19 | ||
25 | * Old version still relied on stealing a minor | ||
26 | * | ||
27 | * 0.5 02/26/2004 (TEJ) tejohnson@yahoo.com | ||
28 | * Complete rewrite using Linux Input in 2.6.3 | ||
29 | * Unfortunately no calibration support at this time | ||
30 | * | ||
31 | * 1.4 04/25/2004 (TEJ) tejohnson@yahoo.com | ||
32 | * Changed reset from standard USB dev reset to vendor reset | ||
33 | * Changed data sent to host from compensated to raw coordinates | ||
34 | * Eliminated vendor/product module params | ||
35 | * Performed multiple successful tests with an EXII-5010UC | ||
36 | * | ||
37 | * 1.5 02/27/2005 ddstreet@ieee.org | ||
38 | * Added module parameter to select raw or hw-calibrated coordinate reporting | ||
39 | * | ||
40 | *****************************************************************************/ | ||
41 | |||
42 | #include <linux/kernel.h> | ||
43 | #include <linux/slab.h> | ||
44 | #include <linux/module.h> | ||
45 | #include <linux/init.h> | ||
46 | #include <linux/usb/input.h> | ||
47 | |||
48 | #define MTOUCHUSB_MIN_XC 0x0 | ||
49 | #define MTOUCHUSB_MAX_RAW_XC 0x4000 | ||
50 | #define MTOUCHUSB_MAX_CALIB_XC 0xffff | ||
51 | #define MTOUCHUSB_XC_FUZZ 0x0 | ||
52 | #define MTOUCHUSB_XC_FLAT 0x0 | ||
53 | #define MTOUCHUSB_MIN_YC 0x0 | ||
54 | #define MTOUCHUSB_MAX_RAW_YC 0x4000 | ||
55 | #define MTOUCHUSB_MAX_CALIB_YC 0xffff | ||
56 | #define MTOUCHUSB_YC_FUZZ 0x0 | ||
57 | #define MTOUCHUSB_YC_FLAT 0x0 | ||
58 | |||
59 | #define MTOUCHUSB_ASYNC_REPORT 1 | ||
60 | #define MTOUCHUSB_RESET 7 | ||
61 | #define MTOUCHUSB_REPORT_DATA_SIZE 11 | ||
62 | #define MTOUCHUSB_REQ_CTRLLR_ID 10 | ||
63 | |||
64 | #define MTOUCHUSB_GET_RAW_XC(data) (data[8]<<8 | data[7]) | ||
65 | #define MTOUCHUSB_GET_CALIB_XC(data) (data[4]<<8 | data[3]) | ||
66 | #define MTOUCHUSB_GET_RAW_YC(data) (data[10]<<8 | data[9]) | ||
67 | #define MTOUCHUSB_GET_CALIB_YC(data) (data[6]<<8 | data[5]) | ||
68 | #define MTOUCHUSB_GET_XC(data) (raw_coordinates ? \ | ||
69 | MTOUCHUSB_GET_RAW_XC(data) : \ | ||
70 | MTOUCHUSB_GET_CALIB_XC(data)) | ||
71 | #define MTOUCHUSB_GET_YC(data) (raw_coordinates ? \ | ||
72 | MTOUCHUSB_GET_RAW_YC(data) : \ | ||
73 | MTOUCHUSB_GET_CALIB_YC(data)) | ||
74 | #define MTOUCHUSB_GET_TOUCHED(data) ((data[2] & 0x40) ? 1:0) | ||
75 | |||
76 | #define DRIVER_VERSION "v1.5" | ||
77 | #define DRIVER_AUTHOR "Todd E. Johnson, tejohnson@yahoo.com" | ||
78 | #define DRIVER_DESC "3M USB Touchscreen Driver" | ||
79 | #define DRIVER_LICENSE "GPL" | ||
80 | |||
81 | static int raw_coordinates = 1; | ||
82 | |||
83 | module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR); | ||
84 | MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)"); | ||
85 | |||
86 | struct mtouch_usb { | ||
87 | unsigned char *data; | ||
88 | dma_addr_t data_dma; | ||
89 | struct urb *irq; | ||
90 | struct usb_device *udev; | ||
91 | struct input_dev *input; | ||
92 | char name[128]; | ||
93 | char phys[64]; | ||
94 | }; | ||
95 | |||
96 | static struct usb_device_id mtouchusb_devices[] = { | ||
97 | { USB_DEVICE(0x0596, 0x0001) }, | ||
98 | { } | ||
99 | }; | ||
100 | |||
101 | static void mtouchusb_irq(struct urb *urb) | ||
102 | { | ||
103 | struct mtouch_usb *mtouch = urb->context; | ||
104 | int retval; | ||
105 | |||
106 | switch (urb->status) { | ||
107 | case 0: | ||
108 | /* success */ | ||
109 | break; | ||
110 | case -ETIME: | ||
111 | /* this urb is timing out */ | ||
112 | dbg("%s - urb timed out - was the device unplugged?", | ||
113 | __FUNCTION__); | ||
114 | return; | ||
115 | case -ECONNRESET: | ||
116 | case -ENOENT: | ||
117 | case -ESHUTDOWN: | ||
118 | /* this urb is terminated, clean up */ | ||
119 | dbg("%s - urb shutting down with status: %d", | ||
120 | __FUNCTION__, urb->status); | ||
121 | return; | ||
122 | default: | ||
123 | dbg("%s - nonzero urb status received: %d", | ||
124 | __FUNCTION__, urb->status); | ||
125 | goto exit; | ||
126 | } | ||
127 | |||
128 | input_report_key(mtouch->input, BTN_TOUCH, | ||
129 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); | ||
130 | input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); | ||
131 | input_report_abs(mtouch->input, ABS_Y, | ||
132 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) | ||
133 | - MTOUCHUSB_GET_YC(mtouch->data)); | ||
134 | input_sync(mtouch->input); | ||
135 | |||
136 | exit: | ||
137 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
138 | if (retval) | ||
139 | err("%s - usb_submit_urb failed with result: %d", | ||
140 | __FUNCTION__, retval); | ||
141 | } | ||
142 | |||
143 | static int mtouchusb_open(struct input_dev *input) | ||
144 | { | ||
145 | struct mtouch_usb *mtouch = input->private; | ||
146 | |||
147 | mtouch->irq->dev = mtouch->udev; | ||
148 | |||
149 | if (usb_submit_urb(mtouch->irq, GFP_ATOMIC)) | ||
150 | return -EIO; | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | static void mtouchusb_close(struct input_dev *input) | ||
156 | { | ||
157 | struct mtouch_usb *mtouch = input->private; | ||
158 | |||
159 | usb_kill_urb(mtouch->irq); | ||
160 | } | ||
161 | |||
162 | static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) | ||
163 | { | ||
164 | dbg("%s - called", __FUNCTION__); | ||
165 | |||
166 | mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, | ||
167 | GFP_ATOMIC, &mtouch->data_dma); | ||
168 | |||
169 | if (!mtouch->data) | ||
170 | return -1; | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) | ||
176 | { | ||
177 | dbg("%s - called", __FUNCTION__); | ||
178 | |||
179 | if (mtouch->data) | ||
180 | usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, | ||
181 | mtouch->data, mtouch->data_dma); | ||
182 | } | ||
183 | |||
184 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
185 | { | ||
186 | struct mtouch_usb *mtouch; | ||
187 | struct input_dev *input_dev; | ||
188 | struct usb_host_interface *interface; | ||
189 | struct usb_endpoint_descriptor *endpoint; | ||
190 | struct usb_device *udev = interface_to_usbdev(intf); | ||
191 | int nRet; | ||
192 | |||
193 | dbg("%s - called", __FUNCTION__); | ||
194 | |||
195 | dbg("%s - setting interface", __FUNCTION__); | ||
196 | interface = intf->cur_altsetting; | ||
197 | |||
198 | dbg("%s - setting endpoint", __FUNCTION__); | ||
199 | endpoint = &interface->endpoint[0].desc; | ||
200 | |||
201 | mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL); | ||
202 | input_dev = input_allocate_device(); | ||
203 | if (!mtouch || !input_dev) { | ||
204 | err("%s - Out of memory.", __FUNCTION__); | ||
205 | goto fail1; | ||
206 | } | ||
207 | |||
208 | dbg("%s - allocating buffers", __FUNCTION__); | ||
209 | if (mtouchusb_alloc_buffers(udev, mtouch)) | ||
210 | goto fail2; | ||
211 | |||
212 | mtouch->udev = udev; | ||
213 | mtouch->input = input_dev; | ||
214 | |||
215 | if (udev->manufacturer) | ||
216 | strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name)); | ||
217 | |||
218 | if (udev->product) { | ||
219 | if (udev->manufacturer) | ||
220 | strlcat(mtouch->name, " ", sizeof(mtouch->name)); | ||
221 | strlcat(mtouch->name, udev->product, sizeof(mtouch->name)); | ||
222 | } | ||
223 | |||
224 | if (!strlen(mtouch->name)) | ||
225 | snprintf(mtouch->name, sizeof(mtouch->name), | ||
226 | "USB Touchscreen %04x:%04x", | ||
227 | le16_to_cpu(udev->descriptor.idVendor), | ||
228 | le16_to_cpu(udev->descriptor.idProduct)); | ||
229 | |||
230 | usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys)); | ||
231 | strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys)); | ||
232 | |||
233 | input_dev->name = mtouch->name; | ||
234 | input_dev->phys = mtouch->phys; | ||
235 | usb_to_input_id(udev, &input_dev->id); | ||
236 | input_dev->cdev.dev = &intf->dev; | ||
237 | input_dev->private = mtouch; | ||
238 | |||
239 | input_dev->open = mtouchusb_open; | ||
240 | input_dev->close = mtouchusb_close; | ||
241 | |||
242 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
243 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
244 | input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC, | ||
245 | raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC, | ||
246 | MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT); | ||
247 | input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC, | ||
248 | raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC, | ||
249 | MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT); | ||
250 | |||
251 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | ||
252 | MTOUCHUSB_RESET, | ||
253 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
254 | 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
255 | dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", | ||
256 | __FUNCTION__, nRet); | ||
257 | |||
258 | dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); | ||
259 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); | ||
260 | if (!mtouch->irq) { | ||
261 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); | ||
262 | goto fail2; | ||
263 | } | ||
264 | |||
265 | dbg("%s - usb_fill_int_urb", __FUNCTION__); | ||
266 | usb_fill_int_urb(mtouch->irq, mtouch->udev, | ||
267 | usb_rcvintpipe(mtouch->udev, 0x81), | ||
268 | mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE, | ||
269 | mtouchusb_irq, mtouch, endpoint->bInterval); | ||
270 | |||
271 | dbg("%s - input_register_device", __FUNCTION__); | ||
272 | input_register_device(mtouch->input); | ||
273 | |||
274 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | ||
275 | MTOUCHUSB_ASYNC_REPORT, | ||
276 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
277 | 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
278 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", | ||
279 | __FUNCTION__, nRet); | ||
280 | |||
281 | usb_set_intfdata(intf, mtouch); | ||
282 | return 0; | ||
283 | |||
284 | fail2: mtouchusb_free_buffers(udev, mtouch); | ||
285 | fail1: input_free_device(input_dev); | ||
286 | kfree(mtouch); | ||
287 | return -ENOMEM; | ||
288 | } | ||
289 | |||
290 | static void mtouchusb_disconnect(struct usb_interface *intf) | ||
291 | { | ||
292 | struct mtouch_usb *mtouch = usb_get_intfdata(intf); | ||
293 | |||
294 | dbg("%s - called", __FUNCTION__); | ||
295 | usb_set_intfdata(intf, NULL); | ||
296 | if (mtouch) { | ||
297 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); | ||
298 | usb_kill_urb(mtouch->irq); | ||
299 | input_unregister_device(mtouch->input); | ||
300 | usb_free_urb(mtouch->irq); | ||
301 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); | ||
302 | kfree(mtouch); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | MODULE_DEVICE_TABLE(usb, mtouchusb_devices); | ||
307 | |||
308 | static struct usb_driver mtouchusb_driver = { | ||
309 | .name = "mtouchusb", | ||
310 | .probe = mtouchusb_probe, | ||
311 | .disconnect = mtouchusb_disconnect, | ||
312 | .id_table = mtouchusb_devices, | ||
313 | }; | ||
314 | |||
315 | static int __init mtouchusb_init(void) | ||
316 | { | ||
317 | dbg("%s - called", __FUNCTION__); | ||
318 | return usb_register(&mtouchusb_driver); | ||
319 | } | ||
320 | |||
321 | static void __exit mtouchusb_cleanup(void) | ||
322 | { | ||
323 | dbg("%s - called", __FUNCTION__); | ||
324 | usb_deregister(&mtouchusb_driver); | ||
325 | } | ||
326 | |||
327 | module_init(mtouchusb_init); | ||
328 | module_exit(mtouchusb_cleanup); | ||
329 | |||
330 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
331 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
332 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index fea97e5437f8..4f93a760faee 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c | |||
@@ -252,7 +252,7 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
252 | static int powermate_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int _value) | 252 | static int powermate_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int _value) |
253 | { | 253 | { |
254 | unsigned int command = (unsigned int)_value; | 254 | unsigned int command = (unsigned int)_value; |
255 | struct powermate_device *pm = dev->private; | 255 | struct powermate_device *pm = input_get_drvdata(dev); |
256 | 256 | ||
257 | if (type == EV_MSC && code == MSC_PULSELED){ | 257 | if (type == EV_MSC && code == MSC_PULSELED){ |
258 | /* | 258 | /* |
@@ -308,7 +308,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
308 | struct powermate_device *pm; | 308 | struct powermate_device *pm; |
309 | struct input_dev *input_dev; | 309 | struct input_dev *input_dev; |
310 | int pipe, maxp; | 310 | int pipe, maxp; |
311 | int err = -ENOMEM; | 311 | int error = -ENOMEM; |
312 | 312 | ||
313 | interface = intf->cur_altsetting; | 313 | interface = intf->cur_altsetting; |
314 | endpoint = &interface->endpoint[0].desc; | 314 | endpoint = &interface->endpoint[0].desc; |
@@ -359,8 +359,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
359 | 359 | ||
360 | input_dev->phys = pm->phys; | 360 | input_dev->phys = pm->phys; |
361 | usb_to_input_id(udev, &input_dev->id); | 361 | usb_to_input_id(udev, &input_dev->id); |
362 | input_dev->cdev.dev = &intf->dev; | 362 | input_dev->dev.parent = &intf->dev; |
363 | input_dev->private = pm; | 363 | |
364 | input_set_drvdata(input_dev, pm); | ||
364 | 365 | ||
365 | input_dev->event = powermate_input_event; | 366 | input_dev->event = powermate_input_event; |
366 | 367 | ||
@@ -387,11 +388,14 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
387 | 388 | ||
388 | /* register our interrupt URB with the USB system */ | 389 | /* register our interrupt URB with the USB system */ |
389 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { | 390 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { |
390 | err = -EIO; | 391 | error = -EIO; |
391 | goto fail4; | 392 | goto fail4; |
392 | } | 393 | } |
393 | 394 | ||
394 | input_register_device(pm->input); | 395 | error = input_register_device(pm->input); |
396 | if (error) | ||
397 | goto fail5; | ||
398 | |||
395 | 399 | ||
396 | /* force an update of everything */ | 400 | /* force an update of everything */ |
397 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; | 401 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; |
@@ -400,12 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
400 | usb_set_intfdata(intf, pm); | 404 | usb_set_intfdata(intf, pm); |
401 | return 0; | 405 | return 0; |
402 | 406 | ||
403 | fail4: usb_free_urb(pm->config); | 407 | fail5: usb_kill_urb(pm->irq); |
404 | fail3: usb_free_urb(pm->irq); | 408 | fail4: usb_free_urb(pm->config); |
405 | fail2: powermate_free_buffers(udev, pm); | 409 | fail3: usb_free_urb(pm->irq); |
406 | fail1: input_free_device(input_dev); | 410 | fail2: powermate_free_buffers(udev, pm); |
411 | fail1: input_free_device(input_dev); | ||
407 | kfree(pm); | 412 | kfree(pm); |
408 | return err; | 413 | return error; |
409 | } | 414 | } |
410 | 415 | ||
411 | /* Called when a USB device we've accepted ownership of is removed */ | 416 | /* Called when a USB device we've accepted ownership of is removed */ |
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c deleted file mode 100644 index 2a314b065922..000000000000 --- a/drivers/usb/input/touchkitusb.c +++ /dev/null | |||
@@ -1,392 +0,0 @@ | |||
1 | /****************************************************************************** | ||
2 | * touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens | ||
3 | * | ||
4 | * Copyright (C) 2004-2005 by Daniel Ritz <daniel.ritz@gmx.ch> | ||
5 | * Copyright (C) by Todd E. Johnson (mtouchusb.c) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License as | ||
9 | * published by the Free Software Foundation; either version 2 of the | ||
10 | * License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | * Based upon mtouchusb.c | ||
22 | * | ||
23 | *****************************************************************************/ | ||
24 | |||
25 | //#define DEBUG | ||
26 | |||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/module.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/usb/input.h> | ||
32 | |||
33 | #define TOUCHKIT_MIN_XC 0x0 | ||
34 | #define TOUCHKIT_MAX_XC 0x07ff | ||
35 | #define TOUCHKIT_XC_FUZZ 0x0 | ||
36 | #define TOUCHKIT_XC_FLAT 0x0 | ||
37 | #define TOUCHKIT_MIN_YC 0x0 | ||
38 | #define TOUCHKIT_MAX_YC 0x07ff | ||
39 | #define TOUCHKIT_YC_FUZZ 0x0 | ||
40 | #define TOUCHKIT_YC_FLAT 0x0 | ||
41 | #define TOUCHKIT_REPORT_DATA_SIZE 16 | ||
42 | |||
43 | #define TOUCHKIT_DOWN 0x01 | ||
44 | |||
45 | #define TOUCHKIT_PKT_TYPE_MASK 0xFE | ||
46 | #define TOUCHKIT_PKT_TYPE_REPT 0x80 | ||
47 | #define TOUCHKIT_PKT_TYPE_DIAG 0x0A | ||
48 | |||
49 | #define DRIVER_VERSION "v0.1" | ||
50 | #define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" | ||
51 | #define DRIVER_DESC "eGalax TouchKit USB HID Touchscreen Driver" | ||
52 | |||
53 | static int swap_xy; | ||
54 | module_param(swap_xy, bool, 0644); | ||
55 | MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped."); | ||
56 | |||
57 | struct touchkit_usb { | ||
58 | unsigned char *data; | ||
59 | dma_addr_t data_dma; | ||
60 | char buffer[TOUCHKIT_REPORT_DATA_SIZE]; | ||
61 | int buf_len; | ||
62 | struct urb *irq; | ||
63 | struct usb_device *udev; | ||
64 | struct input_dev *input; | ||
65 | char name[128]; | ||
66 | char phys[64]; | ||
67 | }; | ||
68 | |||
69 | static struct usb_device_id touchkit_devices[] = { | ||
70 | {USB_DEVICE(0x3823, 0x0001)}, | ||
71 | {USB_DEVICE(0x0123, 0x0001)}, | ||
72 | {USB_DEVICE(0x0eef, 0x0001)}, | ||
73 | {USB_DEVICE(0x0eef, 0x0002)}, | ||
74 | {} | ||
75 | }; | ||
76 | |||
77 | /* helpers to read the data */ | ||
78 | static inline int touchkit_get_touched(char *data) | ||
79 | { | ||
80 | return (data[0] & TOUCHKIT_DOWN) ? 1 : 0; | ||
81 | } | ||
82 | |||
83 | static inline int touchkit_get_x(char *data) | ||
84 | { | ||
85 | return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F); | ||
86 | } | ||
87 | |||
88 | static inline int touchkit_get_y(char *data) | ||
89 | { | ||
90 | return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F); | ||
91 | } | ||
92 | |||
93 | |||
94 | /* processes one input packet. */ | ||
95 | static void touchkit_process_pkt(struct touchkit_usb *touchkit, char *pkt) | ||
96 | { | ||
97 | int x, y; | ||
98 | |||
99 | /* only process report packets */ | ||
100 | if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT) | ||
101 | return; | ||
102 | |||
103 | if (swap_xy) { | ||
104 | y = touchkit_get_x(pkt); | ||
105 | x = touchkit_get_y(pkt); | ||
106 | } else { | ||
107 | x = touchkit_get_x(pkt); | ||
108 | y = touchkit_get_y(pkt); | ||
109 | } | ||
110 | |||
111 | input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt)); | ||
112 | input_report_abs(touchkit->input, ABS_X, x); | ||
113 | input_report_abs(touchkit->input, ABS_Y, y); | ||
114 | input_sync(touchkit->input); | ||
115 | } | ||
116 | |||
117 | |||
118 | static int touchkit_get_pkt_len(char *buf) | ||
119 | { | ||
120 | switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) { | ||
121 | case TOUCHKIT_PKT_TYPE_REPT: | ||
122 | return 5; | ||
123 | |||
124 | case TOUCHKIT_PKT_TYPE_DIAG: | ||
125 | return buf[1] + 2; | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static void touchkit_process(struct touchkit_usb *touchkit, int len) | ||
132 | { | ||
133 | char *buffer; | ||
134 | int pkt_len, buf_len, pos; | ||
135 | |||
136 | /* if the buffer contains data, append */ | ||
137 | if (unlikely(touchkit->buf_len)) { | ||
138 | int tmp; | ||
139 | |||
140 | /* if only 1 byte in buffer, add another one to get length */ | ||
141 | if (touchkit->buf_len == 1) | ||
142 | touchkit->buffer[1] = touchkit->data[0]; | ||
143 | |||
144 | pkt_len = touchkit_get_pkt_len(touchkit->buffer); | ||
145 | |||
146 | /* unknown packet: drop everything */ | ||
147 | if (!pkt_len) | ||
148 | return; | ||
149 | |||
150 | /* append, process */ | ||
151 | tmp = pkt_len - touchkit->buf_len; | ||
152 | memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp); | ||
153 | touchkit_process_pkt(touchkit, touchkit->buffer); | ||
154 | |||
155 | buffer = touchkit->data + tmp; | ||
156 | buf_len = len - tmp; | ||
157 | } else { | ||
158 | buffer = touchkit->data; | ||
159 | buf_len = len; | ||
160 | } | ||
161 | |||
162 | /* only one byte left in buffer */ | ||
163 | if (unlikely(buf_len == 1)) { | ||
164 | touchkit->buffer[0] = buffer[0]; | ||
165 | touchkit->buf_len = 1; | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | /* loop over the buffer */ | ||
170 | pos = 0; | ||
171 | while (pos < buf_len) { | ||
172 | /* get packet len */ | ||
173 | pkt_len = touchkit_get_pkt_len(buffer + pos); | ||
174 | |||
175 | /* unknown packet: drop everything */ | ||
176 | if (unlikely(!pkt_len)) | ||
177 | return; | ||
178 | |||
179 | /* full packet: process */ | ||
180 | if (likely(pkt_len <= buf_len)) { | ||
181 | touchkit_process_pkt(touchkit, buffer + pos); | ||
182 | } else { | ||
183 | /* incomplete packet: save in buffer */ | ||
184 | memcpy(touchkit->buffer, buffer + pos, buf_len - pos); | ||
185 | touchkit->buf_len = buf_len - pos; | ||
186 | } | ||
187 | pos += pkt_len; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | |||
192 | static void touchkit_irq(struct urb *urb) | ||
193 | { | ||
194 | struct touchkit_usb *touchkit = urb->context; | ||
195 | int retval; | ||
196 | |||
197 | switch (urb->status) { | ||
198 | case 0: | ||
199 | /* success */ | ||
200 | break; | ||
201 | case -ETIME: | ||
202 | /* this urb is timing out */ | ||
203 | dbg("%s - urb timed out - was the device unplugged?", | ||
204 | __FUNCTION__); | ||
205 | return; | ||
206 | case -ECONNRESET: | ||
207 | case -ENOENT: | ||
208 | case -ESHUTDOWN: | ||
209 | /* this urb is terminated, clean up */ | ||
210 | dbg("%s - urb shutting down with status: %d", | ||
211 | __FUNCTION__, urb->status); | ||
212 | return; | ||
213 | default: | ||
214 | dbg("%s - nonzero urb status received: %d", | ||
215 | __FUNCTION__, urb->status); | ||
216 | goto exit; | ||
217 | } | ||
218 | |||
219 | touchkit_process(touchkit, urb->actual_length); | ||
220 | |||
221 | exit: | ||
222 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
223 | if (retval) | ||
224 | err("%s - usb_submit_urb failed with result: %d", | ||
225 | __FUNCTION__, retval); | ||
226 | } | ||
227 | |||
228 | static int touchkit_open(struct input_dev *input) | ||
229 | { | ||
230 | struct touchkit_usb *touchkit = input->private; | ||
231 | |||
232 | touchkit->irq->dev = touchkit->udev; | ||
233 | |||
234 | if (usb_submit_urb(touchkit->irq, GFP_ATOMIC)) | ||
235 | return -EIO; | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static void touchkit_close(struct input_dev *input) | ||
241 | { | ||
242 | struct touchkit_usb *touchkit = input->private; | ||
243 | |||
244 | usb_kill_urb(touchkit->irq); | ||
245 | } | ||
246 | |||
247 | static int touchkit_alloc_buffers(struct usb_device *udev, | ||
248 | struct touchkit_usb *touchkit) | ||
249 | { | ||
250 | touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE, | ||
251 | GFP_ATOMIC, &touchkit->data_dma); | ||
252 | |||
253 | if (!touchkit->data) | ||
254 | return -1; | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static void touchkit_free_buffers(struct usb_device *udev, | ||
260 | struct touchkit_usb *touchkit) | ||
261 | { | ||
262 | if (touchkit->data) | ||
263 | usb_buffer_free(udev, TOUCHKIT_REPORT_DATA_SIZE, | ||
264 | touchkit->data, touchkit->data_dma); | ||
265 | } | ||
266 | |||
267 | static int touchkit_probe(struct usb_interface *intf, | ||
268 | const struct usb_device_id *id) | ||
269 | { | ||
270 | struct touchkit_usb *touchkit; | ||
271 | struct input_dev *input_dev; | ||
272 | struct usb_host_interface *interface; | ||
273 | struct usb_endpoint_descriptor *endpoint; | ||
274 | struct usb_device *udev = interface_to_usbdev(intf); | ||
275 | |||
276 | interface = intf->cur_altsetting; | ||
277 | endpoint = &interface->endpoint[0].desc; | ||
278 | |||
279 | touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL); | ||
280 | input_dev = input_allocate_device(); | ||
281 | if (!touchkit || !input_dev) | ||
282 | goto out_free; | ||
283 | |||
284 | if (touchkit_alloc_buffers(udev, touchkit)) | ||
285 | goto out_free; | ||
286 | |||
287 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); | ||
288 | if (!touchkit->irq) { | ||
289 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); | ||
290 | goto out_free_buffers; | ||
291 | } | ||
292 | |||
293 | touchkit->udev = udev; | ||
294 | touchkit->input = input_dev; | ||
295 | |||
296 | if (udev->manufacturer) | ||
297 | strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name)); | ||
298 | |||
299 | if (udev->product) { | ||
300 | if (udev->manufacturer) | ||
301 | strlcat(touchkit->name, " ", sizeof(touchkit->name)); | ||
302 | strlcat(touchkit->name, udev->product, sizeof(touchkit->name)); | ||
303 | } | ||
304 | |||
305 | if (!strlen(touchkit->name)) | ||
306 | snprintf(touchkit->name, sizeof(touchkit->name), | ||
307 | "USB Touchscreen %04x:%04x", | ||
308 | le16_to_cpu(udev->descriptor.idVendor), | ||
309 | le16_to_cpu(udev->descriptor.idProduct)); | ||
310 | |||
311 | usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys)); | ||
312 | strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys)); | ||
313 | |||
314 | input_dev->name = touchkit->name; | ||
315 | input_dev->phys = touchkit->phys; | ||
316 | usb_to_input_id(udev, &input_dev->id); | ||
317 | input_dev->cdev.dev = &intf->dev; | ||
318 | input_dev->private = touchkit; | ||
319 | input_dev->open = touchkit_open; | ||
320 | input_dev->close = touchkit_close; | ||
321 | |||
322 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
323 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
324 | input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC, | ||
325 | TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT); | ||
326 | input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC, | ||
327 | TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT); | ||
328 | |||
329 | usb_fill_int_urb(touchkit->irq, touchkit->udev, | ||
330 | usb_rcvintpipe(touchkit->udev, 0x81), | ||
331 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, | ||
332 | touchkit_irq, touchkit, endpoint->bInterval); | ||
333 | |||
334 | touchkit->irq->transfer_dma = touchkit->data_dma; | ||
335 | touchkit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
336 | |||
337 | input_register_device(touchkit->input); | ||
338 | |||
339 | usb_set_intfdata(intf, touchkit); | ||
340 | return 0; | ||
341 | |||
342 | out_free_buffers: | ||
343 | touchkit_free_buffers(udev, touchkit); | ||
344 | out_free: | ||
345 | input_free_device(input_dev); | ||
346 | kfree(touchkit); | ||
347 | return -ENOMEM; | ||
348 | } | ||
349 | |||
350 | static void touchkit_disconnect(struct usb_interface *intf) | ||
351 | { | ||
352 | struct touchkit_usb *touchkit = usb_get_intfdata(intf); | ||
353 | |||
354 | dbg("%s - called", __FUNCTION__); | ||
355 | |||
356 | if (!touchkit) | ||
357 | return; | ||
358 | |||
359 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); | ||
360 | usb_set_intfdata(intf, NULL); | ||
361 | usb_kill_urb(touchkit->irq); | ||
362 | input_unregister_device(touchkit->input); | ||
363 | usb_free_urb(touchkit->irq); | ||
364 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); | ||
365 | kfree(touchkit); | ||
366 | } | ||
367 | |||
368 | MODULE_DEVICE_TABLE(usb, touchkit_devices); | ||
369 | |||
370 | static struct usb_driver touchkit_driver = { | ||
371 | .name = "touchkitusb", | ||
372 | .probe = touchkit_probe, | ||
373 | .disconnect = touchkit_disconnect, | ||
374 | .id_table = touchkit_devices, | ||
375 | }; | ||
376 | |||
377 | static int __init touchkit_init(void) | ||
378 | { | ||
379 | return usb_register(&touchkit_driver); | ||
380 | } | ||
381 | |||
382 | static void __exit touchkit_cleanup(void) | ||
383 | { | ||
384 | usb_deregister(&touchkit_driver); | ||
385 | } | ||
386 | |||
387 | module_init(touchkit_init); | ||
388 | module_exit(touchkit_cleanup); | ||
389 | |||
390 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
391 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
392 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c index 86e37a20f8e5..e0829413336b 100644 --- a/drivers/usb/input/usbtouchscreen.c +++ b/drivers/usb/input/usbtouchscreen.c | |||
@@ -647,7 +647,7 @@ exit: | |||
647 | 647 | ||
648 | static int usbtouch_open(struct input_dev *input) | 648 | static int usbtouch_open(struct input_dev *input) |
649 | { | 649 | { |
650 | struct usbtouch_usb *usbtouch = input->private; | 650 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); |
651 | 651 | ||
652 | usbtouch->irq->dev = usbtouch->udev; | 652 | usbtouch->irq->dev = usbtouch->udev; |
653 | 653 | ||
@@ -659,7 +659,7 @@ static int usbtouch_open(struct input_dev *input) | |||
659 | 659 | ||
660 | static void usbtouch_close(struct input_dev *input) | 660 | static void usbtouch_close(struct input_dev *input) |
661 | { | 661 | { |
662 | struct usbtouch_usb *usbtouch = input->private; | 662 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); |
663 | 663 | ||
664 | usb_kill_urb(usbtouch->irq); | 664 | usb_kill_urb(usbtouch->irq); |
665 | } | 665 | } |
@@ -740,8 +740,10 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
740 | input_dev->name = usbtouch->name; | 740 | input_dev->name = usbtouch->name; |
741 | input_dev->phys = usbtouch->phys; | 741 | input_dev->phys = usbtouch->phys; |
742 | usb_to_input_id(udev, &input_dev->id); | 742 | usb_to_input_id(udev, &input_dev->id); |
743 | input_dev->cdev.dev = &intf->dev; | 743 | input_dev->dev.parent = &intf->dev; |
744 | input_dev->private = usbtouch; | 744 | |
745 | input_set_drvdata(input_dev, usbtouch); | ||
746 | |||
745 | input_dev->open = usbtouch_open; | 747 | input_dev->open = usbtouch_open; |
746 | input_dev->close = usbtouch_close; | 748 | input_dev->close = usbtouch_close; |
747 | 749 | ||
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c index 12b42746ded8..1fe48208c2f4 100644 --- a/drivers/usb/input/wacom_sys.c +++ b/drivers/usb/input/wacom_sys.c | |||
@@ -122,7 +122,7 @@ void wacom_input_sync(void *wcombo) | |||
122 | 122 | ||
123 | static int wacom_open(struct input_dev *dev) | 123 | static int wacom_open(struct input_dev *dev) |
124 | { | 124 | { |
125 | struct wacom *wacom = dev->private; | 125 | struct wacom *wacom = input_get_drvdata(dev); |
126 | 126 | ||
127 | wacom->irq->dev = wacom->usbdev; | 127 | wacom->irq->dev = wacom->usbdev; |
128 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) | 128 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) |
@@ -133,7 +133,7 @@ static int wacom_open(struct input_dev *dev) | |||
133 | 133 | ||
134 | static void wacom_close(struct input_dev *dev) | 134 | static void wacom_close(struct input_dev *dev) |
135 | { | 135 | { |
136 | struct wacom *wacom = dev->private; | 136 | struct wacom *wacom = input_get_drvdata(dev); |
137 | 137 | ||
138 | usb_kill_urb(wacom->irq); | 138 | usb_kill_urb(wacom->irq); |
139 | } | 139 | } |
@@ -201,6 +201,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
201 | struct wacom *wacom; | 201 | struct wacom *wacom; |
202 | struct wacom_wac *wacom_wac; | 202 | struct wacom_wac *wacom_wac; |
203 | struct input_dev *input_dev; | 203 | struct input_dev *input_dev; |
204 | int error = -ENOMEM; | ||
204 | char rep_data[2], limit = 0; | 205 | char rep_data[2], limit = 0; |
205 | 206 | ||
206 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); | 207 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
@@ -229,8 +230,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
229 | wacom->wacom_wac = wacom_wac; | 230 | wacom->wacom_wac = wacom_wac; |
230 | usb_to_input_id(dev, &input_dev->id); | 231 | usb_to_input_id(dev, &input_dev->id); |
231 | 232 | ||
232 | input_dev->cdev.dev = &intf->dev; | 233 | input_dev->dev.parent = &intf->dev; |
233 | input_dev->private = wacom; | 234 | |
235 | input_set_drvdata(input_dev, wacom); | ||
236 | |||
234 | input_dev->open = wacom_open; | 237 | input_dev->open = wacom_open; |
235 | input_dev->close = wacom_close; | 238 | input_dev->close = wacom_close; |
236 | 239 | ||
@@ -252,7 +255,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
252 | wacom->irq->transfer_dma = wacom->data_dma; | 255 | wacom->irq->transfer_dma = wacom->data_dma; |
253 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 256 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
254 | 257 | ||
255 | input_register_device(wacom->dev); | 258 | error = input_register_device(wacom->dev); |
259 | if (error) | ||
260 | goto fail3; | ||
256 | 261 | ||
257 | /* Ask the tablet to report tablet data. Repeat until it succeeds */ | 262 | /* Ask the tablet to report tablet data. Repeat until it succeeds */ |
258 | do { | 263 | do { |
@@ -265,11 +270,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
265 | usb_set_intfdata(intf, wacom); | 270 | usb_set_intfdata(intf, wacom); |
266 | return 0; | 271 | return 0; |
267 | 272 | ||
268 | fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma); | 273 | fail3: usb_free_urb(wacom->irq); |
269 | fail1: input_free_device(input_dev); | 274 | fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma); |
275 | fail1: input_free_device(input_dev); | ||
270 | kfree(wacom); | 276 | kfree(wacom); |
271 | kfree(wacom_wac); | 277 | kfree(wacom_wac); |
272 | return -ENOMEM; | 278 | return error; |
273 | } | 279 | } |
274 | 280 | ||
275 | static void wacom_disconnect(struct usb_interface *intf) | 281 | static void wacom_disconnect(struct usb_interface *intf) |
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index e4bc76ebc835..735723912950 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
@@ -267,7 +267,7 @@ exit: | |||
267 | 267 | ||
268 | static int xpad_open (struct input_dev *dev) | 268 | static int xpad_open (struct input_dev *dev) |
269 | { | 269 | { |
270 | struct usb_xpad *xpad = dev->private; | 270 | struct usb_xpad *xpad = input_get_drvdata(dev); |
271 | 271 | ||
272 | xpad->irq_in->dev = xpad->udev; | 272 | xpad->irq_in->dev = xpad->udev; |
273 | if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) | 273 | if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) |
@@ -278,7 +278,7 @@ static int xpad_open (struct input_dev *dev) | |||
278 | 278 | ||
279 | static void xpad_close (struct input_dev *dev) | 279 | static void xpad_close (struct input_dev *dev) |
280 | { | 280 | { |
281 | struct usb_xpad *xpad = dev->private; | 281 | struct usb_xpad *xpad = input_get_drvdata(dev); |
282 | 282 | ||
283 | usb_kill_urb(xpad->irq_in); | 283 | usb_kill_urb(xpad->irq_in); |
284 | } | 284 | } |
@@ -312,6 +312,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
312 | struct input_dev *input_dev; | 312 | struct input_dev *input_dev; |
313 | struct usb_endpoint_descriptor *ep_irq_in; | 313 | struct usb_endpoint_descriptor *ep_irq_in; |
314 | int i; | 314 | int i; |
315 | int error = -ENOMEM; | ||
315 | 316 | ||
316 | for (i = 0; xpad_device[i].idVendor; i++) { | 317 | for (i = 0; xpad_device[i].idVendor; i++) { |
317 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && | 318 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && |
@@ -344,8 +345,10 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
344 | input_dev->name = xpad_device[i].name; | 345 | input_dev->name = xpad_device[i].name; |
345 | input_dev->phys = xpad->phys; | 346 | input_dev->phys = xpad->phys; |
346 | usb_to_input_id(udev, &input_dev->id); | 347 | usb_to_input_id(udev, &input_dev->id); |
347 | input_dev->cdev.dev = &intf->dev; | 348 | input_dev->dev.parent = &intf->dev; |
348 | input_dev->private = xpad; | 349 | |
350 | input_set_drvdata(input_dev, xpad); | ||
351 | |||
349 | input_dev->open = xpad_open; | 352 | input_dev->open = xpad_open; |
350 | input_dev->close = xpad_close; | 353 | input_dev->close = xpad_close; |
351 | 354 | ||
@@ -373,15 +376,18 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
373 | xpad->irq_in->transfer_dma = xpad->idata_dma; | 376 | xpad->irq_in->transfer_dma = xpad->idata_dma; |
374 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 377 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
375 | 378 | ||
376 | input_register_device(xpad->dev); | 379 | error = input_register_device(xpad->dev); |
380 | if (error) | ||
381 | goto fail3; | ||
377 | 382 | ||
378 | usb_set_intfdata(intf, xpad); | 383 | usb_set_intfdata(intf, xpad); |
379 | return 0; | 384 | return 0; |
380 | 385 | ||
381 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | 386 | fail3: usb_free_urb(xpad->irq_in); |
382 | fail1: input_free_device(input_dev); | 387 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); |
388 | fail1: input_free_device(input_dev); | ||
383 | kfree(xpad); | 389 | kfree(xpad); |
384 | return -ENOMEM; | 390 | return error; |
385 | 391 | ||
386 | } | 392 | } |
387 | 393 | ||
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index caff8e6d7448..c54f1a5dcb4a 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c | |||
@@ -502,7 +502,7 @@ static int input_ev(struct input_dev *dev, unsigned int type, | |||
502 | 502 | ||
503 | static int input_open(struct input_dev *dev) | 503 | static int input_open(struct input_dev *dev) |
504 | { | 504 | { |
505 | struct yealink_dev *yld = dev->private; | 505 | struct yealink_dev *yld = input_get_drvdata(dev); |
506 | int i, ret; | 506 | int i, ret; |
507 | 507 | ||
508 | dbg("%s", __FUNCTION__); | 508 | dbg("%s", __FUNCTION__); |
@@ -529,7 +529,7 @@ static int input_open(struct input_dev *dev) | |||
529 | 529 | ||
530 | static void input_close(struct input_dev *dev) | 530 | static void input_close(struct input_dev *dev) |
531 | { | 531 | { |
532 | struct yealink_dev *yld = dev->private; | 532 | struct yealink_dev *yld = input_get_drvdata(dev); |
533 | 533 | ||
534 | usb_kill_urb(yld->urb_ctl); | 534 | usb_kill_urb(yld->urb_ctl); |
535 | usb_kill_urb(yld->urb_irq); | 535 | usb_kill_urb(yld->urb_irq); |
@@ -937,9 +937,10 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
937 | input_dev->name = nfo->name; | 937 | input_dev->name = nfo->name; |
938 | input_dev->phys = yld->phys; | 938 | input_dev->phys = yld->phys; |
939 | usb_to_input_id(udev, &input_dev->id); | 939 | usb_to_input_id(udev, &input_dev->id); |
940 | input_dev->cdev.dev = &intf->dev; | 940 | input_dev->dev.parent = &intf->dev; |
941 | |||
942 | input_set_drvdata(input_dev, yld); | ||
941 | 943 | ||
942 | input_dev->private = yld; | ||
943 | input_dev->open = input_open; | 944 | input_dev->open = input_open; |
944 | input_dev->close = input_close; | 945 | input_dev->close = input_close; |
945 | /* input_dev->event = input_ev; TODO */ | 946 | /* input_dev->event = input_ev; TODO */ |
@@ -955,7 +956,9 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
955 | } | 956 | } |
956 | } | 957 | } |
957 | 958 | ||
958 | input_register_device(yld->idev); | 959 | ret = input_register_device(yld->idev); |
960 | if (ret) | ||
961 | return usb_cleanup(yld, ret); | ||
959 | 962 | ||
960 | usb_set_intfdata(intf, yld); | 963 | usb_set_intfdata(intf, yld); |
961 | 964 | ||
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index a0cc05d21a6a..60d29440f316 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c | |||
@@ -55,7 +55,6 @@ | |||
55 | #include <linux/usb.h> | 55 | #include <linux/usb.h> |
56 | #include <linux/types.h> | 56 | #include <linux/types.h> |
57 | #include <linux/ethtool.h> | 57 | #include <linux/ethtool.h> |
58 | #include <linux/pci.h> | ||
59 | #include <linux/dma-mapping.h> | 58 | #include <linux/dma-mapping.h> |
60 | #include <linux/wait.h> | 59 | #include <linux/wait.h> |
61 | #include <asm/uaccess.h> | 60 | #include <asm/uaccess.h> |