diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/input/acecad.c | 76 | ||||
-rw-r--r-- | drivers/usb/input/aiptek.c | 209 | ||||
-rw-r--r-- | drivers/usb/input/appletouch.c | 130 | ||||
-rw-r--r-- | drivers/usb/input/ati_remote.c | 173 | ||||
-rw-r--r-- | drivers/usb/input/hid-core.c | 51 | ||||
-rw-r--r-- | drivers/usb/input/hid-input.c | 56 | ||||
-rw-r--r-- | drivers/usb/input/hid-lgff.c | 17 | ||||
-rw-r--r-- | drivers/usb/input/hid-tmff.c | 11 | ||||
-rw-r--r-- | drivers/usb/input/hid.h | 2 | ||||
-rw-r--r-- | drivers/usb/input/itmtouch.c | 70 | ||||
-rw-r--r-- | drivers/usb/input/kbtab.c | 82 | ||||
-rw-r--r-- | drivers/usb/input/keyspan_remote.c | 210 | ||||
-rw-r--r-- | drivers/usb/input/mtouchusb.c | 111 | ||||
-rw-r--r-- | drivers/usb/input/pid.c | 12 | ||||
-rw-r--r-- | drivers/usb/input/powermate.c | 136 | ||||
-rw-r--r-- | drivers/usb/input/touchkitusb.c | 116 | ||||
-rw-r--r-- | drivers/usb/input/usbkbd.c | 105 | ||||
-rw-r--r-- | drivers/usb/input/usbmouse.c | 93 | ||||
-rw-r--r-- | drivers/usb/input/wacom.c | 142 | ||||
-rw-r--r-- | drivers/usb/input/xpad.c | 95 | ||||
-rw-r--r-- | drivers/usb/input/yealink.c | 66 |
21 files changed, 961 insertions, 1002 deletions
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c index 74f8760d7c07..a32558b4048e 100644 --- a/drivers/usb/input/acecad.c +++ b/drivers/usb/input/acecad.c | |||
@@ -53,7 +53,7 @@ struct usb_acecad { | |||
53 | char name[128]; | 53 | char name[128]; |
54 | char phys[64]; | 54 | char phys[64]; |
55 | struct usb_device *usbdev; | 55 | struct usb_device *usbdev; |
56 | struct input_dev dev; | 56 | struct input_dev *input; |
57 | struct urb *irq; | 57 | struct urb *irq; |
58 | 58 | ||
59 | signed char *data; | 59 | signed char *data; |
@@ -64,7 +64,7 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) | |||
64 | { | 64 | { |
65 | struct usb_acecad *acecad = urb->context; | 65 | struct usb_acecad *acecad = urb->context; |
66 | unsigned char *data = acecad->data; | 66 | unsigned char *data = acecad->data; |
67 | struct input_dev *dev = &acecad->dev; | 67 | struct input_dev *dev = acecad->input; |
68 | int prox, status; | 68 | int prox, status; |
69 | 69 | ||
70 | switch (urb->status) { | 70 | switch (urb->status) { |
@@ -135,8 +135,8 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
135 | struct usb_host_interface *interface = intf->cur_altsetting; | 135 | struct usb_host_interface *interface = intf->cur_altsetting; |
136 | struct usb_endpoint_descriptor *endpoint; | 136 | struct usb_endpoint_descriptor *endpoint; |
137 | struct usb_acecad *acecad; | 137 | struct usb_acecad *acecad; |
138 | struct input_dev *input_dev; | ||
138 | int pipe, maxp; | 139 | int pipe, maxp; |
139 | char path[64]; | ||
140 | 140 | ||
141 | if (interface->desc.bNumEndpoints != 1) | 141 | if (interface->desc.bNumEndpoints != 1) |
142 | return -ENODEV; | 142 | return -ENODEV; |
@@ -153,8 +153,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
154 | 154 | ||
155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); | 155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); |
156 | if (!acecad) | 156 | input_dev = input_allocate_device(); |
157 | return -ENOMEM; | 157 | if (!acecad || !input_dev) |
158 | goto fail1; | ||
158 | 159 | ||
159 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); | 160 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); |
160 | if (!acecad->data) | 161 | if (!acecad->data) |
@@ -164,6 +165,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
164 | if (!acecad->irq) | 165 | if (!acecad->irq) |
165 | goto fail2; | 166 | goto fail2; |
166 | 167 | ||
168 | acecad->usbdev = dev; | ||
169 | acecad->input = input_dev; | ||
170 | |||
167 | if (dev->manufacturer) | 171 | if (dev->manufacturer) |
168 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); | 172 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); |
169 | 173 | ||
@@ -173,48 +177,48 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
173 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); | 177 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); |
174 | } | 178 | } |
175 | 179 | ||
176 | usb_make_path(dev, path, sizeof(path)); | 180 | usb_make_path(dev, acecad->phys, sizeof(acecad->phys)); |
177 | snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); | 181 | strlcat(acecad->phys, "/input0", sizeof(acecad->phys)); |
178 | 182 | ||
179 | acecad->usbdev = dev; | 183 | input_dev->name = acecad->name; |
184 | input_dev->phys = acecad->phys; | ||
185 | usb_to_input_id(dev, &input_dev->id); | ||
186 | input_dev->cdev.dev = &intf->dev; | ||
187 | input_dev->private = acecad; | ||
180 | 188 | ||
181 | acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 189 | input_dev->open = usb_acecad_open; |
182 | acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 190 | input_dev->close = usb_acecad_close; |
183 | acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 191 | |
184 | acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | 192 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
193 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
194 | input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
195 | input_dev->keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | ||
185 | 196 | ||
186 | switch (id->driver_info) { | 197 | switch (id->driver_info) { |
187 | case 0: | 198 | case 0: |
188 | acecad->dev.absmax[ABS_X] = 5000; | 199 | input_dev->absmax[ABS_X] = 5000; |
189 | acecad->dev.absmax[ABS_Y] = 3750; | 200 | input_dev->absmax[ABS_Y] = 3750; |
190 | acecad->dev.absmax[ABS_PRESSURE] = 512; | 201 | input_dev->absmax[ABS_PRESSURE] = 512; |
191 | if (!strlen(acecad->name)) | 202 | if (!strlen(acecad->name)) |
192 | snprintf(acecad->name, sizeof(acecad->name), | 203 | snprintf(acecad->name, sizeof(acecad->name), |
193 | "USB Acecad Flair Tablet %04x:%04x", | 204 | "USB Acecad Flair Tablet %04x:%04x", |
194 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 205 | le16_to_cpu(dev->descriptor.idVendor), |
206 | le16_to_cpu(dev->descriptor.idProduct)); | ||
195 | break; | 207 | break; |
196 | case 1: | 208 | case 1: |
197 | acecad->dev.absmax[ABS_X] = 3000; | 209 | input_dev->absmax[ABS_X] = 3000; |
198 | acecad->dev.absmax[ABS_Y] = 2250; | 210 | input_dev->absmax[ABS_Y] = 2250; |
199 | acecad->dev.absmax[ABS_PRESSURE] = 1024; | 211 | input_dev->absmax[ABS_PRESSURE] = 1024; |
200 | if (!strlen(acecad->name)) | 212 | if (!strlen(acecad->name)) |
201 | snprintf(acecad->name, sizeof(acecad->name), | 213 | snprintf(acecad->name, sizeof(acecad->name), |
202 | "USB Acecad 302 Tablet %04x:%04x", | 214 | "USB Acecad 302 Tablet %04x:%04x", |
203 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 215 | le16_to_cpu(dev->descriptor.idVendor), |
216 | le16_to_cpu(dev->descriptor.idProduct)); | ||
204 | break; | 217 | break; |
205 | } | 218 | } |
206 | 219 | ||
207 | acecad->dev.absfuzz[ABS_X] = 4; | 220 | input_dev->absfuzz[ABS_X] = 4; |
208 | acecad->dev.absfuzz[ABS_Y] = 4; | 221 | input_dev->absfuzz[ABS_Y] = 4; |
209 | |||
210 | acecad->dev.private = acecad; | ||
211 | acecad->dev.open = usb_acecad_open; | ||
212 | acecad->dev.close = usb_acecad_close; | ||
213 | |||
214 | acecad->dev.name = acecad->name; | ||
215 | acecad->dev.phys = acecad->phys; | ||
216 | usb_to_input_id(dev, &acecad->dev.id); | ||
217 | acecad->dev.dev = &intf->dev; | ||
218 | 222 | ||
219 | usb_fill_int_urb(acecad->irq, dev, pipe, | 223 | usb_fill_int_urb(acecad->irq, dev, pipe, |
220 | acecad->data, maxp > 8 ? 8 : maxp, | 224 | acecad->data, maxp > 8 ? 8 : maxp, |
@@ -222,17 +226,15 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
222 | acecad->irq->transfer_dma = acecad->data_dma; | 226 | acecad->irq->transfer_dma = acecad->data_dma; |
223 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 227 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
224 | 228 | ||
225 | input_register_device(&acecad->dev); | 229 | input_register_device(acecad->input); |
226 | |||
227 | printk(KERN_INFO "input: %s with packet size %d on %s\n", | ||
228 | acecad->name, maxp, path); | ||
229 | 230 | ||
230 | usb_set_intfdata(intf, acecad); | 231 | usb_set_intfdata(intf, acecad); |
231 | 232 | ||
232 | return 0; | 233 | return 0; |
233 | 234 | ||
234 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); | 235 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); |
235 | fail1: kfree(acecad); | 236 | fail1: input_free_device(input_dev); |
237 | kfree(acecad); | ||
236 | return -ENOMEM; | 238 | return -ENOMEM; |
237 | } | 239 | } |
238 | 240 | ||
@@ -243,7 +245,7 @@ static void usb_acecad_disconnect(struct usb_interface *intf) | |||
243 | usb_set_intfdata(intf, NULL); | 245 | usb_set_intfdata(intf, NULL); |
244 | if (acecad) { | 246 | if (acecad) { |
245 | usb_kill_urb(acecad->irq); | 247 | usb_kill_urb(acecad->irq); |
246 | input_unregister_device(&acecad->dev); | 248 | input_unregister_device(acecad->input); |
247 | usb_free_urb(acecad->irq); | 249 | usb_free_urb(acecad->irq); |
248 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); | 250 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); |
249 | kfree(acecad); | 251 | kfree(acecad); |
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index cd0cbfe20723..1c5205321d83 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
@@ -317,7 +317,7 @@ struct aiptek_settings { | |||
317 | }; | 317 | }; |
318 | 318 | ||
319 | struct aiptek { | 319 | struct aiptek { |
320 | struct input_dev inputdev; /* input device struct */ | 320 | struct input_dev *inputdev; /* input device struct */ |
321 | struct usb_device *usbdev; /* usb device struct */ | 321 | struct usb_device *usbdev; /* usb device struct */ |
322 | struct urb *urb; /* urb for incoming reports */ | 322 | struct urb *urb; /* urb for incoming reports */ |
323 | dma_addr_t data_dma; /* our dma stuffage */ | 323 | dma_addr_t data_dma; /* our dma stuffage */ |
@@ -402,7 +402,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) | |||
402 | { | 402 | { |
403 | struct aiptek *aiptek = urb->context; | 403 | struct aiptek *aiptek = urb->context; |
404 | unsigned char *data = aiptek->data; | 404 | unsigned char *data = aiptek->data; |
405 | struct input_dev *inputdev = &aiptek->inputdev; | 405 | struct input_dev *inputdev = aiptek->inputdev; |
406 | int jitterable = 0; | 406 | int jitterable = 0; |
407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; | 407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; |
408 | 408 | ||
@@ -955,20 +955,20 @@ static int aiptek_program_tablet(struct aiptek *aiptek) | |||
955 | /* Query getXextension */ | 955 | /* Query getXextension */ |
956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) | 956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) |
957 | return ret; | 957 | return ret; |
958 | aiptek->inputdev.absmin[ABS_X] = 0; | 958 | aiptek->inputdev->absmin[ABS_X] = 0; |
959 | aiptek->inputdev.absmax[ABS_X] = ret - 1; | 959 | aiptek->inputdev->absmax[ABS_X] = ret - 1; |
960 | 960 | ||
961 | /* Query getYextension */ | 961 | /* Query getYextension */ |
962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) | 962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) |
963 | return ret; | 963 | return ret; |
964 | aiptek->inputdev.absmin[ABS_Y] = 0; | 964 | aiptek->inputdev->absmin[ABS_Y] = 0; |
965 | aiptek->inputdev.absmax[ABS_Y] = ret - 1; | 965 | aiptek->inputdev->absmax[ABS_Y] = ret - 1; |
966 | 966 | ||
967 | /* Query getPressureLevels */ | 967 | /* Query getPressureLevels */ |
968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) | 968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) |
969 | return ret; | 969 | return ret; |
970 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 970 | aiptek->inputdev->absmin[ABS_PRESSURE] = 0; |
971 | aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1; | 971 | aiptek->inputdev->absmax[ABS_PRESSURE] = ret - 1; |
972 | 972 | ||
973 | /* Depending on whether we are in absolute or relative mode, we will | 973 | /* Depending on whether we are in absolute or relative mode, we will |
974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. | 974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. |
@@ -1025,8 +1025,8 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr | |||
1025 | return 0; | 1025 | return 0; |
1026 | 1026 | ||
1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", | 1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", |
1028 | aiptek->inputdev.absmax[ABS_X] + 1, | 1028 | aiptek->inputdev->absmax[ABS_X] + 1, |
1029 | aiptek->inputdev.absmax[ABS_Y] + 1); | 1029 | aiptek->inputdev->absmax[ABS_Y] + 1); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | /* These structs define the sysfs files, param #1 is the name of the | 1032 | /* These structs define the sysfs files, param #1 is the name of the |
@@ -1048,7 +1048,7 @@ static ssize_t show_tabletProductId(struct device *dev, struct device_attribute | |||
1048 | return 0; | 1048 | return 0; |
1049 | 1049 | ||
1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", | 1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", |
1051 | aiptek->inputdev.id.product); | 1051 | aiptek->inputdev->id.product); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); | 1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); |
@@ -1063,7 +1063,7 @@ static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute * | |||
1063 | if (aiptek == NULL) | 1063 | if (aiptek == NULL) |
1064 | return 0; | 1064 | return 0; |
1065 | 1065 | ||
1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor); | 1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev->id.vendor); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); | 1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); |
@@ -1977,7 +1977,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1977 | struct input_dev *inputdev; | 1977 | struct input_dev *inputdev; |
1978 | struct input_handle *inputhandle; | 1978 | struct input_handle *inputhandle; |
1979 | struct list_head *node, *next; | 1979 | struct list_head *node, *next; |
1980 | char path[64 + 1]; | ||
1981 | int i; | 1980 | int i; |
1982 | int speeds[] = { 0, | 1981 | int speeds[] = { 0, |
1983 | AIPTEK_PROGRAMMABLE_DELAY_50, | 1982 | AIPTEK_PROGRAMMABLE_DELAY_50, |
@@ -1996,24 +1995,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1996 | */ | 1995 | */ |
1997 | speeds[0] = programmableDelay; | 1996 | speeds[0] = programmableDelay; |
1998 | 1997 | ||
1999 | if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL) | 1998 | aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); |
2000 | return -ENOMEM; | 1999 | inputdev = input_allocate_device(); |
2001 | memset(aiptek, 0, sizeof(struct aiptek)); | 2000 | if (!aiptek || !inputdev) |
2001 | goto fail1; | ||
2002 | 2002 | ||
2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, | 2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, |
2004 | SLAB_ATOMIC, &aiptek->data_dma); | 2004 | SLAB_ATOMIC, &aiptek->data_dma); |
2005 | if (aiptek->data == NULL) { | 2005 | if (!aiptek->data) |
2006 | kfree(aiptek); | 2006 | goto fail1; |
2007 | return -ENOMEM; | ||
2008 | } | ||
2009 | 2007 | ||
2010 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); | 2008 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); |
2011 | if (aiptek->urb == NULL) { | 2009 | if (!aiptek->urb) |
2012 | usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | 2010 | goto fail2; |
2013 | aiptek->data_dma); | 2011 | |
2014 | kfree(aiptek); | 2012 | aiptek->inputdev = inputdev; |
2015 | return -ENOMEM; | 2013 | aiptek->usbdev = usbdev; |
2016 | } | 2014 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; |
2015 | aiptek->inDelay = 0; | ||
2016 | aiptek->endDelay = 0; | ||
2017 | aiptek->previousJitterable = 0; | ||
2017 | 2018 | ||
2018 | /* Set up the curSettings struct. Said struct contains the current | 2019 | /* Set up the curSettings struct. Said struct contains the current |
2019 | * programmable parameters. The newSetting struct contains changes | 2020 | * programmable parameters. The newSetting struct contains changes |
@@ -2036,31 +2037,48 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2036 | 2037 | ||
2037 | /* Both structs should have equivalent settings | 2038 | /* Both structs should have equivalent settings |
2038 | */ | 2039 | */ |
2039 | memcpy(&aiptek->newSetting, &aiptek->curSetting, | 2040 | aiptek->newSetting = aiptek->curSetting; |
2040 | sizeof(struct aiptek_settings)); | 2041 | |
2042 | /* Determine the usb devices' physical path. | ||
2043 | * Asketh not why we always pretend we're using "../input0", | ||
2044 | * but I suspect this will have to be refactored one | ||
2045 | * day if a single USB device can be a keyboard & a mouse | ||
2046 | * & a tablet, and the inputX number actually will tell | ||
2047 | * us something... | ||
2048 | */ | ||
2049 | usb_make_path(usbdev, aiptek->features.usbPath, | ||
2050 | sizeof(aiptek->features.usbPath)); | ||
2051 | strlcat(aiptek->features.usbPath, "/input0", | ||
2052 | sizeof(aiptek->features.usbPath)); | ||
2053 | |||
2054 | /* Set up client data, pointers to open and close routines | ||
2055 | * for the input device. | ||
2056 | */ | ||
2057 | inputdev->name = "Aiptek"; | ||
2058 | inputdev->phys = aiptek->features.usbPath; | ||
2059 | usb_to_input_id(usbdev, &inputdev->id); | ||
2060 | inputdev->cdev.dev = &intf->dev; | ||
2061 | inputdev->private = aiptek; | ||
2062 | inputdev->open = aiptek_open; | ||
2063 | inputdev->close = aiptek_close; | ||
2041 | 2064 | ||
2042 | /* Now program the capacities of the tablet, in terms of being | 2065 | /* Now program the capacities of the tablet, in terms of being |
2043 | * an input device. | 2066 | * an input device. |
2044 | */ | 2067 | */ |
2045 | aiptek->inputdev.evbit[0] |= BIT(EV_KEY) | 2068 | inputdev->evbit[0] |= BIT(EV_KEY) |
2046 | | BIT(EV_ABS) | 2069 | | BIT(EV_ABS) |
2047 | | BIT(EV_REL) | 2070 | | BIT(EV_REL) |
2048 | | BIT(EV_MSC); | 2071 | | BIT(EV_MSC); |
2049 | 2072 | ||
2050 | aiptek->inputdev.absbit[0] |= | 2073 | inputdev->absbit[0] |= BIT(ABS_MISC); |
2051 | (BIT(ABS_X) | | ||
2052 | BIT(ABS_Y) | | ||
2053 | BIT(ABS_PRESSURE) | | ||
2054 | BIT(ABS_TILT_X) | | ||
2055 | BIT(ABS_TILT_Y) | BIT(ABS_WHEEL) | BIT(ABS_MISC)); | ||
2056 | 2074 | ||
2057 | aiptek->inputdev.relbit[0] |= | 2075 | inputdev->relbit[0] |= |
2058 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); | 2076 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); |
2059 | 2077 | ||
2060 | aiptek->inputdev.keybit[LONG(BTN_LEFT)] |= | 2078 | inputdev->keybit[LONG(BTN_LEFT)] |= |
2061 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); | 2079 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); |
2062 | 2080 | ||
2063 | aiptek->inputdev.keybit[LONG(BTN_DIGI)] |= | 2081 | inputdev->keybit[LONG(BTN_DIGI)] |= |
2064 | (BIT(BTN_TOOL_PEN) | | 2082 | (BIT(BTN_TOOL_PEN) | |
2065 | BIT(BTN_TOOL_RUBBER) | | 2083 | BIT(BTN_TOOL_RUBBER) | |
2066 | BIT(BTN_TOOL_PENCIL) | | 2084 | BIT(BTN_TOOL_PENCIL) | |
@@ -2070,70 +2088,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2070 | BIT(BTN_TOOL_LENS) | | 2088 | BIT(BTN_TOOL_LENS) | |
2071 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); | 2089 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); |
2072 | 2090 | ||
2073 | aiptek->inputdev.mscbit[0] = BIT(MSC_SERIAL); | 2091 | inputdev->mscbit[0] = BIT(MSC_SERIAL); |
2074 | 2092 | ||
2075 | /* Programming the tablet macro keys needs to be done with a for loop | 2093 | /* Programming the tablet macro keys needs to be done with a for loop |
2076 | * as the keycodes are discontiguous. | 2094 | * as the keycodes are discontiguous. |
2077 | */ | 2095 | */ |
2078 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) | 2096 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) |
2079 | set_bit(macroKeyEvents[i], aiptek->inputdev.keybit); | 2097 | set_bit(macroKeyEvents[i], inputdev->keybit); |
2080 | |||
2081 | /* Set up client data, pointers to open and close routines | ||
2082 | * for the input device. | ||
2083 | */ | ||
2084 | aiptek->inputdev.private = aiptek; | ||
2085 | aiptek->inputdev.open = aiptek_open; | ||
2086 | aiptek->inputdev.close = aiptek_close; | ||
2087 | |||
2088 | /* Determine the usb devices' physical path. | ||
2089 | * Asketh not why we always pretend we're using "../input0", | ||
2090 | * but I suspect this will have to be refactored one | ||
2091 | * day if a single USB device can be a keyboard & a mouse | ||
2092 | * & a tablet, and the inputX number actually will tell | ||
2093 | * us something... | ||
2094 | */ | ||
2095 | if (usb_make_path(usbdev, path, 64) > 0) | ||
2096 | sprintf(aiptek->features.usbPath, "%s/input0", path); | ||
2097 | 2098 | ||
2098 | /* Program the input device coordinate capacities. We do not yet | 2099 | /* |
2100 | * Program the input device coordinate capacities. We do not yet | ||
2099 | * know what maximum X, Y, and Z values are, so we're putting fake | 2101 | * know what maximum X, Y, and Z values are, so we're putting fake |
2100 | * values in. Later, we'll ask the tablet to put in the correct | 2102 | * values in. Later, we'll ask the tablet to put in the correct |
2101 | * values. | 2103 | * values. |
2102 | */ | 2104 | */ |
2103 | aiptek->inputdev.absmin[ABS_X] = 0; | 2105 | input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0); |
2104 | aiptek->inputdev.absmax[ABS_X] = 2999; | 2106 | input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0); |
2105 | aiptek->inputdev.absmin[ABS_Y] = 0; | 2107 | input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0); |
2106 | aiptek->inputdev.absmax[ABS_Y] = 2249; | 2108 | input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
2107 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 2109 | input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
2108 | aiptek->inputdev.absmax[ABS_PRESSURE] = 511; | 2110 | input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); |
2109 | aiptek->inputdev.absmin[ABS_TILT_X] = AIPTEK_TILT_MIN; | ||
2110 | aiptek->inputdev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX; | ||
2111 | aiptek->inputdev.absmin[ABS_TILT_Y] = AIPTEK_TILT_MIN; | ||
2112 | aiptek->inputdev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX; | ||
2113 | aiptek->inputdev.absmin[ABS_WHEEL] = AIPTEK_WHEEL_MIN; | ||
2114 | aiptek->inputdev.absmax[ABS_WHEEL] = AIPTEK_WHEEL_MAX - 1; | ||
2115 | aiptek->inputdev.absfuzz[ABS_X] = 0; | ||
2116 | aiptek->inputdev.absfuzz[ABS_Y] = 0; | ||
2117 | aiptek->inputdev.absfuzz[ABS_PRESSURE] = 0; | ||
2118 | aiptek->inputdev.absfuzz[ABS_TILT_X] = 0; | ||
2119 | aiptek->inputdev.absfuzz[ABS_TILT_Y] = 0; | ||
2120 | aiptek->inputdev.absfuzz[ABS_WHEEL] = 0; | ||
2121 | aiptek->inputdev.absflat[ABS_X] = 0; | ||
2122 | aiptek->inputdev.absflat[ABS_Y] = 0; | ||
2123 | aiptek->inputdev.absflat[ABS_PRESSURE] = 0; | ||
2124 | aiptek->inputdev.absflat[ABS_TILT_X] = 0; | ||
2125 | aiptek->inputdev.absflat[ABS_TILT_Y] = 0; | ||
2126 | aiptek->inputdev.absflat[ABS_WHEEL] = 0; | ||
2127 | aiptek->inputdev.name = "Aiptek"; | ||
2128 | aiptek->inputdev.phys = aiptek->features.usbPath; | ||
2129 | usb_to_input_id(usbdev, &aiptek->inputdev.id); | ||
2130 | aiptek->inputdev.dev = &intf->dev; | ||
2131 | |||
2132 | aiptek->usbdev = usbdev; | ||
2133 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; | ||
2134 | aiptek->inDelay = 0; | ||
2135 | aiptek->endDelay = 0; | ||
2136 | aiptek->previousJitterable = 0; | ||
2137 | 2111 | ||
2138 | endpoint = &intf->altsetting[0].endpoint[0].desc; | 2112 | endpoint = &intf->altsetting[0].endpoint[0].desc; |
2139 | 2113 | ||
@@ -2150,28 +2124,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2150 | aiptek->urb->transfer_dma = aiptek->data_dma; | 2124 | aiptek->urb->transfer_dma = aiptek->data_dma; |
2151 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 2125 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
2152 | 2126 | ||
2153 | /* Register the tablet as an Input Device | ||
2154 | */ | ||
2155 | input_register_device(&aiptek->inputdev); | ||
2156 | |||
2157 | /* We now will look for the evdev device which is mapped to | ||
2158 | * the tablet. The partial name is kept in the link list of | ||
2159 | * input_handles associated with this input device. | ||
2160 | * What identifies an evdev input_handler is that it begins | ||
2161 | * with 'event', continues with a digit, and that in turn | ||
2162 | * is mapped to /{devfs}/input/eventN. | ||
2163 | */ | ||
2164 | inputdev = &aiptek->inputdev; | ||
2165 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
2166 | inputhandle = to_handle(node); | ||
2167 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
2168 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
2169 | break; | ||
2170 | } | ||
2171 | } | ||
2172 | |||
2173 | info("input: Aiptek on %s (%s)\n", path, aiptek->features.inputPath); | ||
2174 | |||
2175 | /* Program the tablet. This sets the tablet up in the mode | 2127 | /* Program the tablet. This sets the tablet up in the mode |
2176 | * specified in newSetting, and also queries the tablet's | 2128 | * specified in newSetting, and also queries the tablet's |
2177 | * physical capacities. | 2129 | * physical capacities. |
@@ -2186,13 +2138,32 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2186 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { | 2138 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { |
2187 | aiptek->curSetting.programmableDelay = speeds[i]; | 2139 | aiptek->curSetting.programmableDelay = speeds[i]; |
2188 | (void)aiptek_program_tablet(aiptek); | 2140 | (void)aiptek_program_tablet(aiptek); |
2189 | if (aiptek->inputdev.absmax[ABS_X] > 0) { | 2141 | if (aiptek->inputdev->absmax[ABS_X] > 0) { |
2190 | info("input: Aiptek using %d ms programming speed\n", | 2142 | info("input: Aiptek using %d ms programming speed\n", |
2191 | aiptek->curSetting.programmableDelay); | 2143 | aiptek->curSetting.programmableDelay); |
2192 | break; | 2144 | break; |
2193 | } | 2145 | } |
2194 | } | 2146 | } |
2195 | 2147 | ||
2148 | /* Register the tablet as an Input Device | ||
2149 | */ | ||
2150 | input_register_device(aiptek->inputdev); | ||
2151 | |||
2152 | /* We now will look for the evdev device which is mapped to | ||
2153 | * the tablet. The partial name is kept in the link list of | ||
2154 | * input_handles associated with this input device. | ||
2155 | * What identifies an evdev input_handler is that it begins | ||
2156 | * with 'event', continues with a digit, and that in turn | ||
2157 | * is mapped to /{devfs}/input/eventN. | ||
2158 | */ | ||
2159 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
2160 | inputhandle = to_handle(node); | ||
2161 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
2162 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
2163 | break; | ||
2164 | } | ||
2165 | } | ||
2166 | |||
2196 | /* Associate this driver's struct with the usb interface. | 2167 | /* Associate this driver's struct with the usb interface. |
2197 | */ | 2168 | */ |
2198 | usb_set_intfdata(intf, aiptek); | 2169 | usb_set_intfdata(intf, aiptek); |
@@ -2207,6 +2178,12 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2207 | info("aiptek: error loading 'evdev' module"); | 2178 | info("aiptek: error loading 'evdev' module"); |
2208 | 2179 | ||
2209 | return 0; | 2180 | return 0; |
2181 | |||
2182 | fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | ||
2183 | aiptek->data_dma); | ||
2184 | fail1: input_free_device(inputdev); | ||
2185 | kfree(aiptek); | ||
2186 | return -ENOMEM; | ||
2210 | } | 2187 | } |
2211 | 2188 | ||
2212 | /* Forward declaration */ | 2189 | /* Forward declaration */ |
@@ -2234,7 +2211,7 @@ static void aiptek_disconnect(struct usb_interface *intf) | |||
2234 | /* Free & unhook everything from the system. | 2211 | /* Free & unhook everything from the system. |
2235 | */ | 2212 | */ |
2236 | usb_kill_urb(aiptek->urb); | 2213 | usb_kill_urb(aiptek->urb); |
2237 | input_unregister_device(&aiptek->inputdev); | 2214 | input_unregister_device(aiptek->inputdev); |
2238 | aiptek_delete_files(&intf->dev); | 2215 | aiptek_delete_files(&intf->dev); |
2239 | usb_free_urb(aiptek->urb); | 2216 | usb_free_urb(aiptek->urb); |
2240 | usb_buffer_free(interface_to_usbdev(intf), | 2217 | usb_buffer_free(interface_to_usbdev(intf), |
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c index e03c1c567a14..15840db092a5 100644 --- a/drivers/usb/input/appletouch.c +++ b/drivers/usb/input/appletouch.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #define APPLE_VENDOR_ID 0x05AC | 39 | #define APPLE_VENDOR_ID 0x05AC |
40 | 40 | ||
41 | #define ATP_DEVICE(prod) \ | 41 | #define ATP_DEVICE(prod) \ |
42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ | 42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | 43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ |
44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ | 44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ |
45 | .idVendor = APPLE_VENDOR_ID, \ | 45 | .idVendor = APPLE_VENDOR_ID, \ |
@@ -78,9 +78,9 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
78 | * We try to keep the touchpad aspect ratio while still doing only simple | 78 | * We try to keep the touchpad aspect ratio while still doing only simple |
79 | * arithmetics. | 79 | * arithmetics. |
80 | * The factors below give coordinates like: | 80 | * The factors below give coordinates like: |
81 | * 0 <= x < 960 on 12" and 15" Powerbooks | 81 | * 0 <= x < 960 on 12" and 15" Powerbooks |
82 | * 0 <= x < 1600 on 17" Powerbooks | 82 | * 0 <= x < 1600 on 17" Powerbooks |
83 | * 0 <= y < 646 | 83 | * 0 <= y < 646 |
84 | */ | 84 | */ |
85 | #define ATP_XFACT 64 | 85 | #define ATP_XFACT 64 |
86 | #define ATP_YFACT 43 | 86 | #define ATP_YFACT 43 |
@@ -93,11 +93,12 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
93 | 93 | ||
94 | /* Structure to hold all of our device specific stuff */ | 94 | /* Structure to hold all of our device specific stuff */ |
95 | struct atp { | 95 | struct atp { |
96 | char phys[64]; | ||
96 | struct usb_device * udev; /* usb device */ | 97 | struct usb_device * udev; /* usb device */ |
97 | struct urb * urb; /* usb request block */ | 98 | struct urb * urb; /* usb request block */ |
98 | signed char * data; /* transferred data */ | 99 | signed char * data; /* transferred data */ |
99 | int open; /* non-zero if opened */ | 100 | int open; /* non-zero if opened */ |
100 | struct input_dev input; /* input dev */ | 101 | struct input_dev *input; /* input dev */ |
101 | int valid; /* are the sensors valid ? */ | 102 | int valid; /* are the sensors valid ? */ |
102 | int x_old; /* last reported x/y, */ | 103 | int x_old; /* last reported x/y, */ |
103 | int y_old; /* used for smoothing */ | 104 | int y_old; /* used for smoothing */ |
@@ -114,11 +115,11 @@ struct atp { | |||
114 | int i; \ | 115 | int i; \ |
115 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ | 116 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ |
116 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ | 117 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ |
117 | printk(" %02x", tab[i]); \ | 118 | printk(" %02x", tab[i]); \ |
118 | printk("\n"); \ | 119 | printk("\n"); \ |
119 | } | 120 | } |
120 | 121 | ||
121 | #define dprintk(format, a...) \ | 122 | #define dprintk(format, a...) \ |
122 | do { \ | 123 | do { \ |
123 | if (debug) printk(format, ##a); \ | 124 | if (debug) printk(format, ##a); \ |
124 | } while (0) | 125 | } while (0) |
@@ -219,8 +220,8 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
219 | for (i = 16; i < ATP_XSENSORS; i++) | 220 | for (i = 16; i < ATP_XSENSORS; i++) |
220 | if (dev->xy_cur[i]) { | 221 | if (dev->xy_cur[i]) { |
221 | printk("appletouch: 17\" model detected.\n"); | 222 | printk("appletouch: 17\" model detected.\n"); |
222 | input_set_abs_params(&dev->input, ABS_X, 0, | 223 | input_set_abs_params(dev->input, ABS_X, 0, |
223 | (ATP_XSENSORS - 1) * | 224 | (ATP_XSENSORS - 1) * |
224 | ATP_XFACT - 1, | 225 | ATP_XFACT - 1, |
225 | ATP_FUZZ, 0); | 226 | ATP_FUZZ, 0); |
226 | break; | 227 | break; |
@@ -260,12 +261,12 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
260 | "Xz: %3d Yz: %3d\n", | 261 | "Xz: %3d Yz: %3d\n", |
261 | x, y, x_z, y_z); | 262 | x, y, x_z, y_z); |
262 | 263 | ||
263 | input_report_key(&dev->input, BTN_TOUCH, 1); | 264 | input_report_key(dev->input, BTN_TOUCH, 1); |
264 | input_report_abs(&dev->input, ABS_X, x); | 265 | input_report_abs(dev->input, ABS_X, x); |
265 | input_report_abs(&dev->input, ABS_Y, y); | 266 | input_report_abs(dev->input, ABS_Y, y); |
266 | input_report_abs(&dev->input, ABS_PRESSURE, | 267 | input_report_abs(dev->input, ABS_PRESSURE, |
267 | min(ATP_PRESSURE, x_z + y_z)); | 268 | min(ATP_PRESSURE, x_z + y_z)); |
268 | atp_report_fingers(&dev->input, max(x_f, y_f)); | 269 | atp_report_fingers(dev->input, max(x_f, y_f)); |
269 | } | 270 | } |
270 | dev->x_old = x; | 271 | dev->x_old = x; |
271 | dev->y_old = y; | 272 | dev->y_old = y; |
@@ -273,17 +274,17 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
273 | else if (!x && !y) { | 274 | else if (!x && !y) { |
274 | 275 | ||
275 | dev->x_old = dev->y_old = -1; | 276 | dev->x_old = dev->y_old = -1; |
276 | input_report_key(&dev->input, BTN_TOUCH, 0); | 277 | input_report_key(dev->input, BTN_TOUCH, 0); |
277 | input_report_abs(&dev->input, ABS_PRESSURE, 0); | 278 | input_report_abs(dev->input, ABS_PRESSURE, 0); |
278 | atp_report_fingers(&dev->input, 0); | 279 | atp_report_fingers(dev->input, 0); |
279 | 280 | ||
280 | /* reset the accumulator on release */ | 281 | /* reset the accumulator on release */ |
281 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); | 282 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); |
282 | } | 283 | } |
283 | 284 | ||
284 | input_report_key(&dev->input, BTN_LEFT, !!dev->data[80]); | 285 | input_report_key(dev->input, BTN_LEFT, !!dev->data[80]); |
285 | 286 | ||
286 | input_sync(&dev->input); | 287 | input_sync(dev->input); |
287 | 288 | ||
288 | exit: | 289 | exit: |
289 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 290 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
@@ -314,21 +315,14 @@ static void atp_close(struct input_dev *input) | |||
314 | 315 | ||
315 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) | 316 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) |
316 | { | 317 | { |
317 | struct atp *dev = NULL; | 318 | struct atp *dev; |
319 | struct input_dev *input_dev; | ||
320 | struct usb_device *udev = interface_to_usbdev(iface); | ||
318 | struct usb_host_interface *iface_desc; | 321 | struct usb_host_interface *iface_desc; |
319 | struct usb_endpoint_descriptor *endpoint; | 322 | struct usb_endpoint_descriptor *endpoint; |
320 | int int_in_endpointAddr = 0; | 323 | int int_in_endpointAddr = 0; |
321 | int i, retval = -ENOMEM; | 324 | int i, retval = -ENOMEM; |
322 | 325 | ||
323 | /* allocate memory for our device state and initialize it */ | ||
324 | dev = kmalloc(sizeof(struct atp), GFP_KERNEL); | ||
325 | if (dev == NULL) { | ||
326 | err("Out of memory"); | ||
327 | goto err_kmalloc; | ||
328 | } | ||
329 | memset(dev, 0, sizeof(struct atp)); | ||
330 | |||
331 | dev->udev = interface_to_usbdev(iface); | ||
332 | 326 | ||
333 | /* set up the endpoint information */ | 327 | /* set up the endpoint information */ |
334 | /* use only the first interrupt-in endpoint */ | 328 | /* use only the first interrupt-in endpoint */ |
@@ -345,70 +339,82 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
345 | } | 339 | } |
346 | } | 340 | } |
347 | if (!int_in_endpointAddr) { | 341 | if (!int_in_endpointAddr) { |
348 | retval = -EIO; | ||
349 | err("Could not find int-in endpoint"); | 342 | err("Could not find int-in endpoint"); |
350 | goto err_endpoint; | 343 | return -EIO; |
351 | } | 344 | } |
352 | 345 | ||
353 | /* save our data pointer in this interface device */ | 346 | /* allocate memory for our device state and initialize it */ |
354 | usb_set_intfdata(iface, dev); | 347 | dev = kzalloc(sizeof(struct atp), GFP_KERNEL); |
348 | input_dev = input_allocate_device(); | ||
349 | if (!dev || !input_dev) { | ||
350 | err("Out of memory"); | ||
351 | goto err_free_devs; | ||
352 | } | ||
353 | |||
354 | dev->udev = udev; | ||
355 | dev->input = input_dev; | ||
355 | 356 | ||
356 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | 357 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
357 | if (!dev->urb) { | 358 | if (!dev->urb) { |
358 | retval = -ENOMEM; | 359 | retval = -ENOMEM; |
359 | goto err_usballoc; | 360 | goto err_free_devs; |
360 | } | 361 | } |
362 | |||
361 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, | 363 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, |
362 | &dev->urb->transfer_dma); | 364 | &dev->urb->transfer_dma); |
363 | if (!dev->data) { | 365 | if (!dev->data) { |
364 | retval = -ENOMEM; | 366 | retval = -ENOMEM; |
365 | goto err_usbbufalloc; | 367 | goto err_free_urb; |
366 | } | 368 | } |
367 | usb_fill_int_urb(dev->urb, dev->udev, | 369 | |
368 | usb_rcvintpipe(dev->udev, int_in_endpointAddr), | 370 | usb_fill_int_urb(dev->urb, udev, |
371 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
369 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); | 372 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); |
370 | 373 | ||
371 | init_input_dev(&dev->input); | 374 | usb_make_path(udev, dev->phys, sizeof(dev->phys)); |
372 | dev->input.name = "appletouch"; | 375 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); |
373 | dev->input.dev = &iface->dev; | 376 | |
374 | dev->input.private = dev; | 377 | input_dev->name = "appletouch"; |
375 | dev->input.open = atp_open; | 378 | input_dev->phys = dev->phys; |
376 | dev->input.close = atp_close; | 379 | usb_to_input_id(dev->udev, &input_dev->id); |
380 | input_dev->cdev.dev = &iface->dev; | ||
377 | 381 | ||
378 | usb_to_input_id(dev->udev, &dev->input.id); | 382 | input_dev->private = dev; |
383 | input_dev->open = atp_open; | ||
384 | input_dev->close = atp_close; | ||
379 | 385 | ||
380 | set_bit(EV_ABS, dev->input.evbit); | 386 | set_bit(EV_ABS, input_dev->evbit); |
381 | 387 | ||
382 | /* | 388 | /* |
383 | * 12" and 15" Powerbooks only have 16 x sensors, | 389 | * 12" and 15" Powerbooks only have 16 x sensors, |
384 | * 17" models are detected later. | 390 | * 17" models are detected later. |
385 | */ | 391 | */ |
386 | input_set_abs_params(&dev->input, ABS_X, 0, | 392 | input_set_abs_params(input_dev, ABS_X, 0, |
387 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); | 393 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); |
388 | input_set_abs_params(&dev->input, ABS_Y, 0, | 394 | input_set_abs_params(input_dev, ABS_Y, 0, |
389 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); | 395 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); |
390 | input_set_abs_params(&dev->input, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | 396 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
391 | 397 | ||
392 | set_bit(EV_KEY, dev->input.evbit); | 398 | set_bit(EV_KEY, input_dev->evbit); |
393 | set_bit(BTN_TOUCH, dev->input.keybit); | 399 | set_bit(BTN_TOUCH, input_dev->keybit); |
394 | set_bit(BTN_TOOL_FINGER, dev->input.keybit); | 400 | set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
395 | set_bit(BTN_TOOL_DOUBLETAP, dev->input.keybit); | 401 | set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
396 | set_bit(BTN_TOOL_TRIPLETAP, dev->input.keybit); | 402 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
397 | set_bit(BTN_LEFT, dev->input.keybit); | 403 | set_bit(BTN_LEFT, input_dev->keybit); |
398 | 404 | ||
399 | input_register_device(&dev->input); | 405 | input_register_device(dev->input); |
400 | 406 | ||
401 | printk(KERN_INFO "input: appletouch connected\n"); | 407 | /* save our data pointer in this interface device */ |
408 | usb_set_intfdata(iface, dev); | ||
402 | 409 | ||
403 | return 0; | 410 | return 0; |
404 | 411 | ||
405 | err_usbbufalloc: | 412 | err_free_urb: |
406 | usb_free_urb(dev->urb); | 413 | usb_free_urb(dev->urb); |
407 | err_usballoc: | 414 | err_free_devs: |
408 | usb_set_intfdata(iface, NULL); | 415 | usb_set_intfdata(iface, NULL); |
409 | err_endpoint: | ||
410 | kfree(dev); | 416 | kfree(dev); |
411 | err_kmalloc: | 417 | input_free_device(input_dev); |
412 | return retval; | 418 | return retval; |
413 | } | 419 | } |
414 | 420 | ||
@@ -419,7 +425,7 @@ static void atp_disconnect(struct usb_interface *iface) | |||
419 | usb_set_intfdata(iface, NULL); | 425 | usb_set_intfdata(iface, NULL); |
420 | if (dev) { | 426 | if (dev) { |
421 | usb_kill_urb(dev->urb); | 427 | usb_kill_urb(dev->urb); |
422 | input_unregister_device(&dev->input); | 428 | input_unregister_device(dev->input); |
423 | usb_free_urb(dev->urb); | 429 | usb_free_urb(dev->urb); |
424 | usb_buffer_free(dev->udev, ATP_DATASIZE, | 430 | usb_buffer_free(dev->udev, ATP_DATASIZE, |
425 | dev->data, dev->urb->transfer_dma); | 431 | dev->data, dev->urb->transfer_dma); |
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index fd99681ee483..9a2a47db9494 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -112,7 +112,6 @@ | |||
112 | 112 | ||
113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ | 113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ |
114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ | 114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ |
115 | #define ATI_INPUTNUM 1 /* Which input device to register as */ | ||
116 | 115 | ||
117 | static unsigned long channel_mask; | 116 | static unsigned long channel_mask; |
118 | module_param(channel_mask, ulong, 0444); | 117 | module_param(channel_mask, ulong, 0444); |
@@ -162,7 +161,7 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | |||
162 | static DECLARE_MUTEX(disconnect_sem); | 161 | static DECLARE_MUTEX(disconnect_sem); |
163 | 162 | ||
164 | struct ati_remote { | 163 | struct ati_remote { |
165 | struct input_dev idev; | 164 | struct input_dev *idev; |
166 | struct usb_device *udev; | 165 | struct usb_device *udev; |
167 | struct usb_interface *interface; | 166 | struct usb_interface *interface; |
168 | 167 | ||
@@ -198,15 +197,13 @@ struct ati_remote { | |||
198 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ | 197 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ |
199 | 198 | ||
200 | /* Translation table from hardware messages to input events. */ | 199 | /* Translation table from hardware messages to input events. */ |
201 | static struct | 200 | static struct { |
202 | { | ||
203 | short kind; | 201 | short kind; |
204 | unsigned char data1, data2; | 202 | unsigned char data1, data2; |
205 | int type; | 203 | int type; |
206 | unsigned int code; | 204 | unsigned int code; |
207 | int value; | 205 | int value; |
208 | } ati_remote_tbl[] = | 206 | } ati_remote_tbl[] = { |
209 | { | ||
210 | /* Directional control pad axes */ | 207 | /* Directional control pad axes */ |
211 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ | 208 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ |
212 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ | 209 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ |
@@ -286,7 +283,6 @@ static struct | |||
286 | 283 | ||
287 | /* Local function prototypes */ | 284 | /* Local function prototypes */ |
288 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); | 285 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); |
289 | static void ati_remote_delete (struct ati_remote *dev); | ||
290 | static int ati_remote_open (struct input_dev *inputdev); | 286 | static int ati_remote_open (struct input_dev *inputdev); |
291 | static void ati_remote_close (struct input_dev *inputdev); | 287 | static void ati_remote_close (struct input_dev *inputdev); |
292 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); | 288 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); |
@@ -428,7 +424,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
428 | { | 424 | { |
429 | struct ati_remote *ati_remote = urb->context; | 425 | struct ati_remote *ati_remote = urb->context; |
430 | unsigned char *data= ati_remote->inbuf; | 426 | unsigned char *data= ati_remote->inbuf; |
431 | struct input_dev *dev = &ati_remote->idev; | 427 | struct input_dev *dev = ati_remote->idev; |
432 | int index, acc; | 428 | int index, acc; |
433 | int remote_num; | 429 | int remote_num; |
434 | 430 | ||
@@ -587,38 +583,55 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) | |||
587 | } | 583 | } |
588 | 584 | ||
589 | /* | 585 | /* |
590 | * ati_remote_delete | 586 | * ati_remote_alloc_buffers |
591 | */ | 587 | */ |
592 | static void ati_remote_delete(struct ati_remote *ati_remote) | 588 | static int ati_remote_alloc_buffers(struct usb_device *udev, |
589 | struct ati_remote *ati_remote) | ||
593 | { | 590 | { |
594 | if (ati_remote->irq_urb) | 591 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
595 | usb_kill_urb(ati_remote->irq_urb); | 592 | &ati_remote->inbuf_dma); |
593 | if (!ati_remote->inbuf) | ||
594 | return -1; | ||
596 | 595 | ||
597 | if (ati_remote->out_urb) | 596 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
598 | usb_kill_urb(ati_remote->out_urb); | 597 | &ati_remote->outbuf_dma); |
598 | if (!ati_remote->outbuf) | ||
599 | return -1; | ||
599 | 600 | ||
600 | input_unregister_device(&ati_remote->idev); | 601 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
602 | if (!ati_remote->irq_urb) | ||
603 | return -1; | ||
601 | 604 | ||
602 | if (ati_remote->inbuf) | 605 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); |
603 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 606 | if (!ati_remote->out_urb) |
604 | ati_remote->inbuf, ati_remote->inbuf_dma); | 607 | return -1; |
605 | 608 | ||
606 | if (ati_remote->outbuf) | 609 | return 0; |
607 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 610 | } |
608 | ati_remote->outbuf, ati_remote->outbuf_dma); | ||
609 | 611 | ||
612 | /* | ||
613 | * ati_remote_free_buffers | ||
614 | */ | ||
615 | static void ati_remote_free_buffers(struct ati_remote *ati_remote) | ||
616 | { | ||
610 | if (ati_remote->irq_urb) | 617 | if (ati_remote->irq_urb) |
611 | usb_free_urb(ati_remote->irq_urb); | 618 | usb_free_urb(ati_remote->irq_urb); |
612 | 619 | ||
613 | if (ati_remote->out_urb) | 620 | if (ati_remote->out_urb) |
614 | usb_free_urb(ati_remote->out_urb); | 621 | usb_free_urb(ati_remote->out_urb); |
615 | 622 | ||
616 | kfree(ati_remote); | 623 | if (ati_remote->inbuf) |
624 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
625 | ati_remote->inbuf, ati_remote->inbuf_dma); | ||
626 | |||
627 | if (ati_remote->outbuf) | ||
628 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
629 | ati_remote->inbuf, ati_remote->outbuf_dma); | ||
617 | } | 630 | } |
618 | 631 | ||
619 | static void ati_remote_input_init(struct ati_remote *ati_remote) | 632 | static void ati_remote_input_init(struct ati_remote *ati_remote) |
620 | { | 633 | { |
621 | struct input_dev *idev = &(ati_remote->idev); | 634 | struct input_dev *idev = ati_remote->idev; |
622 | int i; | 635 | int i; |
623 | 636 | ||
624 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 637 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
@@ -637,7 +650,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
637 | idev->phys = ati_remote->phys; | 650 | idev->phys = ati_remote->phys; |
638 | 651 | ||
639 | usb_to_input_id(ati_remote->udev, &idev->id); | 652 | usb_to_input_id(ati_remote->udev, &idev->id); |
640 | idev->dev = &ati_remote->udev->dev; | 653 | idev->cdev.dev = &ati_remote->udev->dev; |
641 | } | 654 | } |
642 | 655 | ||
643 | static int ati_remote_initialize(struct ati_remote *ati_remote) | 656 | static int ati_remote_initialize(struct ati_remote *ati_remote) |
@@ -674,7 +687,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
674 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { | 687 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { |
675 | dev_err(&ati_remote->interface->dev, | 688 | dev_err(&ati_remote->interface->dev, |
676 | "Initializing ati_remote hardware failed.\n"); | 689 | "Initializing ati_remote hardware failed.\n"); |
677 | return 1; | 690 | return -EIO; |
678 | } | 691 | } |
679 | 692 | ||
680 | return 0; | 693 | return 0; |
@@ -686,95 +699,83 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
686 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) | 699 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) |
687 | { | 700 | { |
688 | struct usb_device *udev = interface_to_usbdev(interface); | 701 | struct usb_device *udev = interface_to_usbdev(interface); |
689 | struct ati_remote *ati_remote = NULL; | 702 | struct usb_host_interface *iface_host = interface->cur_altsetting; |
690 | struct usb_host_interface *iface_host; | 703 | struct usb_endpoint_descriptor *endpoint_in, *endpoint_out; |
691 | int retval = -ENOMEM; | 704 | struct ati_remote *ati_remote; |
692 | char path[64]; | 705 | struct input_dev *input_dev; |
693 | 706 | int err = -ENOMEM; | |
694 | /* Allocate and clear an ati_remote struct */ | ||
695 | if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL))) | ||
696 | return -ENOMEM; | ||
697 | memset(ati_remote, 0x00, sizeof (struct ati_remote)); | ||
698 | 707 | ||
699 | iface_host = interface->cur_altsetting; | ||
700 | if (iface_host->desc.bNumEndpoints != 2) { | 708 | if (iface_host->desc.bNumEndpoints != 2) { |
701 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); | 709 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); |
702 | retval = -ENODEV; | 710 | return -ENODEV; |
703 | goto error; | ||
704 | } | 711 | } |
705 | 712 | ||
706 | ati_remote->endpoint_in = &(iface_host->endpoint[0].desc); | 713 | endpoint_in = &iface_host->endpoint[0].desc; |
707 | ati_remote->endpoint_out = &(iface_host->endpoint[1].desc); | 714 | endpoint_out = &iface_host->endpoint[1].desc; |
708 | ati_remote->udev = udev; | ||
709 | ati_remote->interface = interface; | ||
710 | 715 | ||
711 | if (!(ati_remote->endpoint_in->bEndpointAddress & 0x80)) { | 716 | if (!(endpoint_in->bEndpointAddress & USB_DIR_IN)) { |
712 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); | 717 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); |
713 | retval = -ENODEV; | 718 | return -ENODEV; |
714 | goto error; | ||
715 | } | 719 | } |
716 | if ((ati_remote->endpoint_in->bmAttributes & 3) != 3) { | 720 | if ((endpoint_in->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) { |
717 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); | 721 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); |
718 | retval = -ENODEV; | 722 | return -ENODEV; |
719 | goto error; | ||
720 | } | 723 | } |
721 | if (le16_to_cpu(ati_remote->endpoint_in->wMaxPacketSize) == 0) { | 724 | if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) { |
722 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); | 725 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); |
723 | retval = -ENODEV; | 726 | return -ENODEV; |
724 | goto error; | ||
725 | } | 727 | } |
726 | 728 | ||
727 | /* Allocate URB buffers, URBs */ | 729 | ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); |
728 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 730 | input_dev = input_allocate_device(); |
729 | &ati_remote->inbuf_dma); | 731 | if (!ati_remote || !input_dev) |
730 | if (!ati_remote->inbuf) | 732 | goto fail1; |
731 | goto error; | ||
732 | 733 | ||
733 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 734 | /* Allocate URB buffers, URBs */ |
734 | &ati_remote->outbuf_dma); | 735 | if (ati_remote_alloc_buffers(udev, ati_remote)) |
735 | if (!ati_remote->outbuf) | 736 | goto fail2; |
736 | goto error; | ||
737 | 737 | ||
738 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 738 | ati_remote->endpoint_in = endpoint_in; |
739 | if (!ati_remote->irq_urb) | 739 | ati_remote->endpoint_out = endpoint_out; |
740 | goto error; | 740 | ati_remote->udev = udev; |
741 | ati_remote->idev = input_dev; | ||
742 | ati_remote->interface = interface; | ||
741 | 743 | ||
742 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); | 744 | usb_make_path(udev, ati_remote->phys, sizeof(ati_remote->phys)); |
743 | if (!ati_remote->out_urb) | 745 | strlcpy(ati_remote->phys, "/input0", sizeof(ati_remote->phys)); |
744 | goto error; | ||
745 | 746 | ||
746 | usb_make_path(udev, path, NAME_BUFSIZE); | ||
747 | sprintf(ati_remote->phys, "%s/input%d", path, ATI_INPUTNUM); | ||
748 | if (udev->manufacturer) | 747 | if (udev->manufacturer) |
749 | strcat(ati_remote->name, udev->manufacturer); | 748 | strlcpy(ati_remote->name, udev->manufacturer, sizeof(ati_remote->name)); |
750 | 749 | ||
751 | if (udev->product) | 750 | if (udev->product) |
752 | sprintf(ati_remote->name, "%s %s", ati_remote->name, udev->product); | 751 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
752 | "%s %s", ati_remote->name, udev->product); | ||
753 | 753 | ||
754 | if (!strlen(ati_remote->name)) | 754 | if (!strlen(ati_remote->name)) |
755 | sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", | 755 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
756 | DRIVER_DESC "(%04x,%04x)", | ||
756 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), | 757 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), |
757 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); | 758 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); |
758 | 759 | ||
760 | ati_remote_input_init(ati_remote); | ||
761 | |||
759 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ | 762 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ |
760 | retval = ati_remote_initialize(ati_remote); | 763 | err = ati_remote_initialize(ati_remote); |
761 | if (retval) | 764 | if (err) |
762 | goto error; | 765 | goto fail3; |
763 | 766 | ||
764 | /* Set up and register input device */ | 767 | /* Set up and register input device */ |
765 | ati_remote_input_init(ati_remote); | 768 | input_register_device(ati_remote->idev); |
766 | input_register_device(&ati_remote->idev); | ||
767 | |||
768 | dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", | ||
769 | ati_remote->name, path); | ||
770 | 769 | ||
771 | usb_set_intfdata(interface, ati_remote); | 770 | usb_set_intfdata(interface, ati_remote); |
771 | return 0; | ||
772 | 772 | ||
773 | error: | 773 | fail3: usb_kill_urb(ati_remote->irq_urb); |
774 | if (retval) | 774 | usb_kill_urb(ati_remote->out_urb); |
775 | ati_remote_delete(ati_remote); | 775 | fail2: ati_remote_free_buffers(ati_remote); |
776 | 776 | fail1: input_free_device(input_dev); | |
777 | return retval; | 777 | kfree(ati_remote); |
778 | return err; | ||
778 | } | 779 | } |
779 | 780 | ||
780 | /* | 781 | /* |
@@ -791,7 +792,11 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
791 | return; | 792 | return; |
792 | } | 793 | } |
793 | 794 | ||
794 | ati_remote_delete(ati_remote); | 795 | usb_kill_urb(ati_remote->irq_urb); |
796 | usb_kill_urb(ati_remote->out_urb); | ||
797 | input_unregister_device(ati_remote->idev); | ||
798 | ati_remote_free_buffers(ati_remote); | ||
799 | kfree(ati_remote); | ||
795 | } | 800 | } |
796 | 801 | ||
797 | /* | 802 | /* |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 41f92b924761..411a0645a7a3 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -1619,8 +1619,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1619 | struct hid_descriptor *hdesc; | 1619 | struct hid_descriptor *hdesc; |
1620 | struct hid_device *hid; | 1620 | struct hid_device *hid; |
1621 | unsigned quirks = 0, rsize = 0; | 1621 | unsigned quirks = 0, rsize = 0; |
1622 | char *buf, *rdesc; | 1622 | char *rdesc; |
1623 | int n, insize = 0; | 1623 | int n, len, insize = 0; |
1624 | 1624 | ||
1625 | for (n = 0; hid_blacklist[n].idVendor; n++) | 1625 | for (n = 0; hid_blacklist[n].idVendor; n++) |
1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && | 1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
@@ -1630,10 +1630,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1630 | if (quirks & HID_QUIRK_IGNORE) | 1630 | if (quirks & HID_QUIRK_IGNORE) |
1631 | return NULL; | 1631 | return NULL; |
1632 | 1632 | ||
1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || | 1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
1634 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { | 1634 | (!interface->desc.bNumEndpoints || |
1635 | dbg("class descriptor not present\n"); | 1635 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
1636 | return NULL; | 1636 | dbg("class descriptor not present\n"); |
1637 | return NULL; | ||
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | for (n = 0; n < hdesc->bNumDescriptors; n++) | 1640 | for (n = 0; n < hdesc->bNumDescriptors; n++) |
@@ -1749,32 +1750,34 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1749 | 1750 | ||
1750 | hid->name[0] = 0; | 1751 | hid->name[0] = 0; |
1751 | 1752 | ||
1752 | if (!(buf = kmalloc(64, GFP_KERNEL))) | 1753 | if (dev->manufacturer) |
1753 | goto fail; | 1754 | strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); |
1755 | |||
1756 | if (dev->product) { | ||
1757 | if (dev->manufacturer) | ||
1758 | strlcat(hid->name, " ", sizeof(hid->name)); | ||
1759 | strlcat(hid->name, dev->product, sizeof(hid->name)); | ||
1760 | } | ||
1761 | |||
1762 | if (!strlen(hid->name)) | ||
1763 | snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", | ||
1764 | le16_to_cpu(dev->descriptor.idVendor), | ||
1765 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1754 | 1766 | ||
1755 | if (dev->manufacturer) { | 1767 | usb_make_path(dev, hid->phys, sizeof(hid->phys)); |
1756 | strcat(hid->name, dev->manufacturer); | 1768 | strlcat(hid->phys, "/input", sizeof(hid->phys)); |
1757 | if (dev->product) | 1769 | len = strlen(hid->phys); |
1758 | snprintf(hid->name, 64, "%s %s", hid->name, dev->product); | 1770 | if (len < sizeof(hid->phys) - 1) |
1759 | } else if (dev->product) { | 1771 | snprintf(hid->phys + len, sizeof(hid->phys) - len, |
1760 | snprintf(hid->name, 128, "%s", dev->product); | 1772 | "%d", intf->altsetting[0].desc.bInterfaceNumber); |
1761 | } else | ||
1762 | snprintf(hid->name, 128, "%04x:%04x", | ||
1763 | le16_to_cpu(dev->descriptor.idVendor), | ||
1764 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1765 | |||
1766 | usb_make_path(dev, buf, 64); | ||
1767 | snprintf(hid->phys, 64, "%s/input%d", buf, | ||
1768 | intf->altsetting[0].desc.bInterfaceNumber); | ||
1769 | 1773 | ||
1770 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1774 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
1771 | hid->uniq[0] = 0; | 1775 | hid->uniq[0] = 0; |
1772 | 1776 | ||
1773 | kfree(buf); | ||
1774 | |||
1775 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1777 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
1776 | if (!hid->urbctrl) | 1778 | if (!hid->urbctrl) |
1777 | goto fail; | 1779 | goto fail; |
1780 | |||
1778 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, | 1781 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, |
1779 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1782 | hid->ctrlbuf, 1, hid_ctrl, hid); |
1780 | hid->urbctrl->setup_dma = hid->cr_dma; | 1783 | hid->urbctrl->setup_dma = hid->cr_dma; |
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 0b6452248a39..9ff25eb520a6 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
@@ -76,8 +76,8 @@ static struct { | |||
76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
77 | struct hid_usage *usage) | 77 | struct hid_usage *usage) |
78 | { | 78 | { |
79 | struct input_dev *input = &hidinput->input; | 79 | struct input_dev *input = hidinput->input; |
80 | struct hid_device *device = hidinput->input.private; | 80 | struct hid_device *device = input->private; |
81 | int max = 0, code; | 81 | int max = 0, code; |
82 | unsigned long *bit = NULL; | 82 | unsigned long *bit = NULL; |
83 | 83 | ||
@@ -461,7 +461,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
461 | 461 | ||
462 | if (!field->hidinput) | 462 | if (!field->hidinput) |
463 | return; | 463 | return; |
464 | input = &field->hidinput->input; | 464 | |
465 | input = field->hidinput->input; | ||
465 | 466 | ||
466 | input_regs(input, regs); | 467 | input_regs(input, regs); |
467 | 468 | ||
@@ -533,13 +534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
533 | 534 | ||
534 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) | 535 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) |
535 | { | 536 | { |
536 | struct list_head *lh; | ||
537 | struct hid_input *hidinput; | 537 | struct hid_input *hidinput; |
538 | 538 | ||
539 | list_for_each (lh, &hid->inputs) { | 539 | list_for_each_entry(hidinput, &hid->inputs, list) |
540 | hidinput = list_entry(lh, struct hid_input, list); | 540 | input_sync(hidinput->input); |
541 | input_sync(&hidinput->input); | ||
542 | } | ||
543 | } | 541 | } |
544 | 542 | ||
545 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) | 543 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) |
@@ -604,6 +602,7 @@ int hidinput_connect(struct hid_device *hid) | |||
604 | struct usb_device *dev = hid->dev; | 602 | struct usb_device *dev = hid->dev; |
605 | struct hid_report *report; | 603 | struct hid_report *report; |
606 | struct hid_input *hidinput = NULL; | 604 | struct hid_input *hidinput = NULL; |
605 | struct input_dev *input_dev; | ||
607 | int i, j, k; | 606 | int i, j, k; |
608 | 607 | ||
609 | INIT_LIST_HEAD(&hid->inputs); | 608 | INIT_LIST_HEAD(&hid->inputs); |
@@ -624,25 +623,28 @@ int hidinput_connect(struct hid_device *hid) | |||
624 | continue; | 623 | continue; |
625 | 624 | ||
626 | if (!hidinput) { | 625 | if (!hidinput) { |
627 | hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL); | 626 | hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); |
628 | if (!hidinput) { | 627 | input_dev = input_allocate_device(); |
628 | if (!hidinput || !input_dev) { | ||
629 | kfree(hidinput); | ||
630 | input_free_device(input_dev); | ||
629 | err("Out of memory during hid input probe"); | 631 | err("Out of memory during hid input probe"); |
630 | return -1; | 632 | return -1; |
631 | } | 633 | } |
632 | memset(hidinput, 0, sizeof(*hidinput)); | ||
633 | 634 | ||
634 | list_add_tail(&hidinput->list, &hid->inputs); | 635 | input_dev->private = hid; |
636 | input_dev->event = hidinput_input_event; | ||
637 | input_dev->open = hidinput_open; | ||
638 | input_dev->close = hidinput_close; | ||
635 | 639 | ||
636 | hidinput->input.private = hid; | 640 | input_dev->name = hid->name; |
637 | hidinput->input.event = hidinput_input_event; | 641 | input_dev->phys = hid->phys; |
638 | hidinput->input.open = hidinput_open; | 642 | input_dev->uniq = hid->uniq; |
639 | hidinput->input.close = hidinput_close; | 643 | usb_to_input_id(dev, &input_dev->id); |
644 | input_dev->cdev.dev = &hid->intf->dev; | ||
640 | 645 | ||
641 | hidinput->input.name = hid->name; | 646 | hidinput->input = input_dev; |
642 | hidinput->input.phys = hid->phys; | 647 | list_add_tail(&hidinput->list, &hid->inputs); |
643 | hidinput->input.uniq = hid->uniq; | ||
644 | usb_to_input_id(dev, &hidinput->input.id); | ||
645 | hidinput->input.dev = &hid->intf->dev; | ||
646 | } | 648 | } |
647 | 649 | ||
648 | for (i = 0; i < report->maxfield; i++) | 650 | for (i = 0; i < report->maxfield; i++) |
@@ -657,7 +659,7 @@ int hidinput_connect(struct hid_device *hid) | |||
657 | * UGCI) cram a lot of unrelated inputs into the | 659 | * UGCI) cram a lot of unrelated inputs into the |
658 | * same interface. */ | 660 | * same interface. */ |
659 | hidinput->report = report; | 661 | hidinput->report = report; |
660 | input_register_device(&hidinput->input); | 662 | input_register_device(hidinput->input); |
661 | hidinput = NULL; | 663 | hidinput = NULL; |
662 | } | 664 | } |
663 | } | 665 | } |
@@ -667,7 +669,7 @@ int hidinput_connect(struct hid_device *hid) | |||
667 | * only useful in this case, and not for multi-input quirks. */ | 669 | * only useful in this case, and not for multi-input quirks. */ |
668 | if (hidinput) { | 670 | if (hidinput) { |
669 | hid_ff_init(hid); | 671 | hid_ff_init(hid); |
670 | input_register_device(&hidinput->input); | 672 | input_register_device(hidinput->input); |
671 | } | 673 | } |
672 | 674 | ||
673 | return 0; | 675 | return 0; |
@@ -675,13 +677,11 @@ int hidinput_connect(struct hid_device *hid) | |||
675 | 677 | ||
676 | void hidinput_disconnect(struct hid_device *hid) | 678 | void hidinput_disconnect(struct hid_device *hid) |
677 | { | 679 | { |
678 | struct list_head *lh, *next; | 680 | struct hid_input *hidinput, *next; |
679 | struct hid_input *hidinput; | ||
680 | 681 | ||
681 | list_for_each_safe(lh, next, &hid->inputs) { | 682 | list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { |
682 | hidinput = list_entry(lh, struct hid_input, list); | ||
683 | input_unregister_device(&hidinput->input); | ||
684 | list_del(&hidinput->list); | 683 | list_del(&hidinput->list); |
684 | input_unregister_device(hidinput->input); | ||
685 | kfree(hidinput); | 685 | kfree(hidinput); |
686 | } | 686 | } |
687 | } | 687 | } |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index 0c4c77aa31ea..f82c9c9e5d51 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -255,22 +255,19 @@ static void hid_lgff_input_init(struct hid_device* hid) | |||
255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); | 255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); |
256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); | 256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); |
257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
258 | struct input_dev *input_dev = hidinput->input; | ||
258 | 259 | ||
259 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) | 260 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) |
260 | dev++; | 261 | dev++; |
261 | 262 | ||
262 | ff = dev->ff; | 263 | for (ff = dev->ff; *ff >= 0; ff++) |
264 | set_bit(*ff, input_dev->ffbit); | ||
263 | 265 | ||
264 | while (*ff >= 0) { | 266 | input_dev->upload_effect = hid_lgff_upload_effect; |
265 | set_bit(*ff, hidinput->input.ffbit); | 267 | input_dev->flush = hid_lgff_flush; |
266 | ++ff; | ||
267 | } | ||
268 | |||
269 | hidinput->input.upload_effect = hid_lgff_upload_effect; | ||
270 | hidinput->input.flush = hid_lgff_flush; | ||
271 | 268 | ||
272 | set_bit(EV_FF, hidinput->input.evbit); | 269 | set_bit(EV_FF, input_dev->evbit); |
273 | hidinput->input.ff_effects_max = LGFF_EFFECTS; | 270 | input_dev->ff_effects_max = LGFF_EFFECTS; |
274 | } | 271 | } |
275 | 272 | ||
276 | static void hid_lgff_exit(struct hid_device* hid) | 273 | static void hid_lgff_exit(struct hid_device* hid) |
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c index 8f6a0a6f94a9..023fd5ac31c8 100644 --- a/drivers/usb/input/hid-tmff.c +++ b/drivers/usb/input/hid-tmff.c | |||
@@ -111,6 +111,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
111 | struct tmff_device *private; | 111 | struct tmff_device *private; |
112 | struct list_head *pos; | 112 | struct list_head *pos; |
113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
114 | struct input_dev *input_dev = hidinput->input; | ||
114 | 115 | ||
115 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); | 116 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); |
116 | if (!private) | 117 | if (!private) |
@@ -155,7 +156,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
155 | private->report = report; | 156 | private->report = report; |
156 | private->rumble = field; | 157 | private->rumble = field; |
157 | 158 | ||
158 | set_bit(FF_RUMBLE, hidinput->input.ffbit); | 159 | set_bit(FF_RUMBLE, input_dev->ffbit); |
159 | break; | 160 | break; |
160 | 161 | ||
161 | default: | 162 | default: |
@@ -164,11 +165,11 @@ int hid_tmff_init(struct hid_device *hid) | |||
164 | } | 165 | } |
165 | 166 | ||
166 | /* Fallthrough to here only when a valid usage is found */ | 167 | /* Fallthrough to here only when a valid usage is found */ |
167 | hidinput->input.upload_effect = hid_tmff_upload_effect; | 168 | input_dev->upload_effect = hid_tmff_upload_effect; |
168 | hidinput->input.flush = hid_tmff_flush; | 169 | input_dev->flush = hid_tmff_flush; |
169 | 170 | ||
170 | set_bit(EV_FF, hidinput->input.evbit); | 171 | set_bit(EV_FF, input_dev->evbit); |
171 | hidinput->input.ff_effects_max = TMFF_EFFECTS; | 172 | input_dev->ff_effects_max = TMFF_EFFECTS; |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index ec2412c42f1e..ee48a2276104 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
@@ -371,7 +371,7 @@ struct hid_control_fifo { | |||
371 | struct hid_input { | 371 | struct hid_input { |
372 | struct list_head list; | 372 | struct list_head list; |
373 | struct hid_report *report; | 373 | struct hid_report *report; |
374 | struct input_dev input; | 374 | struct input_dev *input; |
375 | }; | 375 | }; |
376 | 376 | ||
377 | struct hid_device { /* device report descriptor */ | 377 | struct hid_device { /* device report descriptor */ |
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c index becb87efb869..3b581853cf10 100644 --- a/drivers/usb/input/itmtouch.c +++ b/drivers/usb/input/itmtouch.c | |||
@@ -73,7 +73,7 @@ MODULE_LICENSE( DRIVER_LICENSE ); | |||
73 | 73 | ||
74 | struct itmtouch_dev { | 74 | struct itmtouch_dev { |
75 | struct usb_device *usbdev; /* usb device */ | 75 | struct usb_device *usbdev; /* usb device */ |
76 | struct input_dev inputdev; /* input device */ | 76 | struct input_dev *inputdev; /* input device */ |
77 | struct urb *readurb; /* urb */ | 77 | struct urb *readurb; /* urb */ |
78 | char rbuf[ITM_BUFSIZE]; /* data */ | 78 | char rbuf[ITM_BUFSIZE]; /* data */ |
79 | int users; | 79 | int users; |
@@ -88,9 +88,9 @@ static struct usb_device_id itmtouch_ids [] = { | |||
88 | 88 | ||
89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) | 89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) |
90 | { | 90 | { |
91 | struct itmtouch_dev * itmtouch = urb->context; | 91 | struct itmtouch_dev *itmtouch = urb->context; |
92 | unsigned char *data = urb->transfer_buffer; | 92 | unsigned char *data = urb->transfer_buffer; |
93 | struct input_dev *dev = &itmtouch->inputdev; | 93 | struct input_dev *dev = itmtouch->inputdev; |
94 | int retval; | 94 | int retval; |
95 | 95 | ||
96 | switch (urb->status) { | 96 | switch (urb->status) { |
@@ -156,49 +156,62 @@ static void itmtouch_close(struct input_dev *input) | |||
156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) | 156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) |
157 | { | 157 | { |
158 | struct itmtouch_dev *itmtouch; | 158 | struct itmtouch_dev *itmtouch; |
159 | struct input_dev *input_dev; | ||
159 | struct usb_host_interface *interface; | 160 | struct usb_host_interface *interface; |
160 | struct usb_endpoint_descriptor *endpoint; | 161 | struct usb_endpoint_descriptor *endpoint; |
161 | struct usb_device *udev = interface_to_usbdev(intf); | 162 | struct usb_device *udev = interface_to_usbdev(intf); |
162 | unsigned int pipe; | 163 | unsigned int pipe; |
163 | unsigned int maxp; | 164 | unsigned int maxp; |
164 | char path[PATH_SIZE]; | ||
165 | 165 | ||
166 | interface = intf->cur_altsetting; | 166 | interface = intf->cur_altsetting; |
167 | endpoint = &interface->endpoint[0].desc; | 167 | endpoint = &interface->endpoint[0].desc; |
168 | 168 | ||
169 | if (!(itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL))) { | 169 | itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL); |
170 | input_dev = input_allocate_device(); | ||
171 | if (!itmtouch || !input_dev) { | ||
170 | err("%s - Out of memory.", __FUNCTION__); | 172 | err("%s - Out of memory.", __FUNCTION__); |
171 | return -ENOMEM; | 173 | goto fail; |
172 | } | 174 | } |
173 | 175 | ||
174 | itmtouch->usbdev = udev; | 176 | itmtouch->usbdev = udev; |
177 | itmtouch->inputdev = input_dev; | ||
175 | 178 | ||
176 | itmtouch->inputdev.private = itmtouch; | 179 | if (udev->manufacturer) |
177 | itmtouch->inputdev.open = itmtouch_open; | 180 | strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name)); |
178 | itmtouch->inputdev.close = itmtouch_close; | ||
179 | 181 | ||
180 | usb_make_path(udev, path, PATH_SIZE); | 182 | if (udev->product) { |
181 | 183 | if (udev->manufacturer) | |
182 | itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 184 | strlcat(itmtouch->name, " ", sizeof(itmtouch->name)); |
183 | itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 185 | strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name)); |
184 | itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 186 | } |
185 | |||
186 | itmtouch->inputdev.name = itmtouch->name; | ||
187 | itmtouch->inputdev.phys = itmtouch->phys; | ||
188 | usb_to_input_id(udev, &itmtouch->inputdev.id); | ||
189 | itmtouch->inputdev.dev = &intf->dev; | ||
190 | 187 | ||
191 | if (!strlen(itmtouch->name)) | 188 | if (!strlen(itmtouch->name)) |
192 | sprintf(itmtouch->name, "USB ITM touchscreen"); | 189 | sprintf(itmtouch->name, "USB ITM touchscreen"); |
193 | 190 | ||
191 | usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys)); | ||
192 | strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys)); | ||
193 | |||
194 | input_dev->name = itmtouch->name; | ||
195 | input_dev->phys = itmtouch->phys; | ||
196 | usb_to_input_id(udev, &input_dev->id); | ||
197 | input_dev->cdev.dev = &intf->dev; | ||
198 | input_dev->private = itmtouch; | ||
199 | |||
200 | input_dev->open = itmtouch_open; | ||
201 | input_dev->close = itmtouch_close; | ||
202 | |||
203 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
204 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
205 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
206 | |||
194 | /* device limits */ | 207 | /* device limits */ |
195 | /* as specified by the ITM datasheet, X and Y are 12bit, | 208 | /* as specified by the ITM datasheet, X and Y are 12bit, |
196 | * Z (pressure) is 8 bit. However, the fields are defined up | 209 | * Z (pressure) is 8 bit. However, the fields are defined up |
197 | * to 14 bits for future possible expansion. | 210 | * to 14 bits for future possible expansion. |
198 | */ | 211 | */ |
199 | input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); | 212 | input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0); |
200 | input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); | 213 | input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0); |
201 | input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); | 214 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0); |
202 | 215 | ||
203 | /* initialise the URB so we can read from the transport stream */ | 216 | /* initialise the URB so we can read from the transport stream */ |
204 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); | 217 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); |
@@ -208,22 +221,23 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id | |||
208 | maxp = ITM_BUFSIZE; | 221 | maxp = ITM_BUFSIZE; |
209 | 222 | ||
210 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); | 223 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); |
211 | |||
212 | if (!itmtouch->readurb) { | 224 | if (!itmtouch->readurb) { |
213 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); | 225 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); |
214 | kfree(itmtouch); | 226 | goto fail; |
215 | return -ENOMEM; | ||
216 | } | 227 | } |
217 | 228 | ||
218 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, | 229 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, |
219 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); | 230 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); |
220 | 231 | ||
221 | input_register_device(&itmtouch->inputdev); | 232 | input_register_device(itmtouch->inputdev); |
222 | 233 | ||
223 | printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path); | ||
224 | usb_set_intfdata(intf, itmtouch); | 234 | usb_set_intfdata(intf, itmtouch); |
225 | 235 | ||
226 | return 0; | 236 | return 0; |
237 | |||
238 | fail: input_free_device(input_dev); | ||
239 | kfree(itmtouch); | ||
240 | return -ENOMEM; | ||
227 | } | 241 | } |
228 | 242 | ||
229 | static void itmtouch_disconnect(struct usb_interface *intf) | 243 | static void itmtouch_disconnect(struct usb_interface *intf) |
@@ -233,7 +247,7 @@ static void itmtouch_disconnect(struct usb_interface *intf) | |||
233 | usb_set_intfdata(intf, NULL); | 247 | usb_set_intfdata(intf, NULL); |
234 | 248 | ||
235 | if (itmtouch) { | 249 | if (itmtouch) { |
236 | input_unregister_device(&itmtouch->inputdev); | 250 | input_unregister_device(itmtouch->inputdev); |
237 | usb_kill_urb(itmtouch->readurb); | 251 | usb_kill_urb(itmtouch->readurb); |
238 | usb_free_urb(itmtouch->readurb); | 252 | usb_free_urb(itmtouch->readurb); |
239 | kfree(itmtouch); | 253 | kfree(itmtouch); |
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index b6f6ac8d9c2f..a248664b5d1d 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -34,7 +34,7 @@ MODULE_PARM_DESC(kb_pressure_click, "pressure threshold for clicks"); | |||
34 | struct kbtab { | 34 | struct kbtab { |
35 | signed char *data; | 35 | signed char *data; |
36 | dma_addr_t data_dma; | 36 | dma_addr_t data_dma; |
37 | struct input_dev dev; | 37 | struct input_dev *dev; |
38 | struct usb_device *usbdev; | 38 | struct usb_device *usbdev; |
39 | struct urb *irq; | 39 | struct urb *irq; |
40 | int x, y; | 40 | int x, y; |
@@ -48,7 +48,7 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs) | |||
48 | { | 48 | { |
49 | struct kbtab *kbtab = urb->context; | 49 | struct kbtab *kbtab = urb->context; |
50 | unsigned char *data = kbtab->data; | 50 | unsigned char *data = kbtab->data; |
51 | struct input_dev *dev = &kbtab->dev; | 51 | struct input_dev *dev = kbtab->dev; |
52 | int retval; | 52 | int retval; |
53 | 53 | ||
54 | switch (urb->status) { | 54 | switch (urb->status) { |
@@ -124,53 +124,43 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
124 | struct usb_device *dev = interface_to_usbdev(intf); | 124 | struct usb_device *dev = interface_to_usbdev(intf); |
125 | struct usb_endpoint_descriptor *endpoint; | 125 | struct usb_endpoint_descriptor *endpoint; |
126 | struct kbtab *kbtab; | 126 | struct kbtab *kbtab; |
127 | char path[64]; | 127 | struct input_dev *input_dev; |
128 | 128 | ||
129 | if (!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL))) | 129 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
130 | return -ENOMEM; | 130 | input_dev = input_allocate_device(); |
131 | memset(kbtab, 0, sizeof(struct kbtab)); | 131 | if (!kbtab || !input_dev) |
132 | goto fail1; | ||
132 | 133 | ||
133 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); | 134 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); |
134 | if (!kbtab->data) { | 135 | if (!kbtab->data) |
135 | kfree(kbtab); | 136 | goto fail1; |
136 | return -ENOMEM; | ||
137 | } | ||
138 | 137 | ||
139 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); | 138 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); |
140 | if (!kbtab->irq) { | 139 | if (!kbtab->irq) |
141 | usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 140 | goto fail2; |
142 | kfree(kbtab); | ||
143 | return -ENOMEM; | ||
144 | } | ||
145 | |||
146 | kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | ||
147 | kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
148 | |||
149 | kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
150 | |||
151 | kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); | ||
152 | 141 | ||
153 | kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL); | 142 | kbtab->usbdev = dev; |
154 | 143 | kbtab->dev = input_dev; | |
155 | kbtab->dev.absmax[ABS_X] = 0x2000; | ||
156 | kbtab->dev.absmax[ABS_Y] = 0x1750; | ||
157 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; | ||
158 | 144 | ||
159 | kbtab->dev.absfuzz[ABS_X] = 4; | 145 | usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys)); |
160 | kbtab->dev.absfuzz[ABS_Y] = 4; | 146 | strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys)); |
161 | 147 | ||
162 | kbtab->dev.private = kbtab; | 148 | input_dev->name = "KB Gear Tablet"; |
163 | kbtab->dev.open = kbtab_open; | 149 | input_dev->phys = kbtab->phys; |
164 | kbtab->dev.close = kbtab_close; | 150 | usb_to_input_id(dev, &input_dev->id); |
151 | input_dev->cdev.dev = &intf->dev; | ||
152 | input_dev->private = kbtab; | ||
165 | 153 | ||
166 | usb_make_path(dev, path, 64); | 154 | input_dev->open = kbtab_open; |
167 | sprintf(kbtab->phys, "%s/input0", path); | 155 | input_dev->close = kbtab_close; |
168 | 156 | ||
169 | kbtab->dev.name = "KB Gear Tablet"; | 157 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); |
170 | kbtab->dev.phys = kbtab->phys; | 158 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
171 | usb_to_input_id(dev, &kbtab->dev.id); | 159 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); |
172 | kbtab->dev.dev = &intf->dev; | 160 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
173 | kbtab->usbdev = dev; | 161 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); |
162 | input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0); | ||
163 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | ||
174 | 164 | ||
175 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 165 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
176 | 166 | ||
@@ -181,23 +171,25 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
181 | kbtab->irq->transfer_dma = kbtab->data_dma; | 171 | kbtab->irq->transfer_dma = kbtab->data_dma; |
182 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 172 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
183 | 173 | ||
184 | input_register_device(&kbtab->dev); | 174 | input_register_device(kbtab->dev); |
185 | |||
186 | printk(KERN_INFO "input: KB Gear Tablet on %s\n", path); | ||
187 | 175 | ||
188 | usb_set_intfdata(intf, kbtab); | 176 | usb_set_intfdata(intf, kbtab); |
189 | |||
190 | return 0; | 177 | return 0; |
178 | |||
179 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | ||
180 | fail1: input_free_device(input_dev); | ||
181 | kfree(kbtab); | ||
182 | return -ENOMEM; | ||
191 | } | 183 | } |
192 | 184 | ||
193 | static void kbtab_disconnect(struct usb_interface *intf) | 185 | static void kbtab_disconnect(struct usb_interface *intf) |
194 | { | 186 | { |
195 | struct kbtab *kbtab = usb_get_intfdata (intf); | 187 | struct kbtab *kbtab = usb_get_intfdata(intf); |
196 | 188 | ||
197 | usb_set_intfdata(intf, NULL); | 189 | usb_set_intfdata(intf, NULL); |
198 | if (kbtab) { | 190 | if (kbtab) { |
199 | usb_kill_urb(kbtab->irq); | 191 | usb_kill_urb(kbtab->irq); |
200 | input_unregister_device(&kbtab->dev); | 192 | input_unregister_device(kbtab->dev); |
201 | usb_free_urb(kbtab->irq); | 193 | usb_free_urb(kbtab->irq); |
202 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); | 194 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); |
203 | kfree(kbtab); | 195 | kfree(kbtab); |
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 99de1b33c07d..5b8d65f62abf 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
22 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
23 | #include <linux/usb_input.h> | ||
23 | 24 | ||
24 | #define DRIVER_VERSION "v0.1" | 25 | #define DRIVER_VERSION "v0.1" |
25 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" | 26 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" |
@@ -75,7 +76,7 @@ struct usb_keyspan { | |||
75 | char name[128]; | 76 | char name[128]; |
76 | char phys[64]; | 77 | char phys[64]; |
77 | struct usb_device* udev; | 78 | struct usb_device* udev; |
78 | struct input_dev input; | 79 | struct input_dev *input; |
79 | struct usb_interface* interface; | 80 | struct usb_interface* interface; |
80 | struct usb_endpoint_descriptor* in_endpoint; | 81 | struct usb_endpoint_descriptor* in_endpoint; |
81 | struct urb* irq_urb; | 82 | struct urb* irq_urb; |
@@ -136,12 +137,11 @@ static struct usb_driver keyspan_driver; | |||
136 | */ | 137 | */ |
137 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | 138 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ |
138 | { | 139 | { |
139 | char codes[4*RECV_SIZE]; | 140 | char codes[4 * RECV_SIZE]; |
140 | int i; | 141 | int i; |
141 | 142 | ||
142 | for (i = 0; i < RECV_SIZE; i++) { | 143 | for (i = 0; i < RECV_SIZE; i++) |
143 | snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]); | 144 | snprintf(codes + i * 3, 4, "%02x ", dev->in_buffer[i]); |
144 | } | ||
145 | 145 | ||
146 | dev_info(&dev->udev->dev, "%s\n", codes); | 146 | dev_info(&dev->udev->dev, "%s\n", codes); |
147 | } | 147 | } |
@@ -153,7 +153,7 @@ static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | |||
153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | 153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) |
154 | { | 154 | { |
155 | if (dev->data.bits_left >= bits_needed) | 155 | if (dev->data.bits_left >= bits_needed) |
156 | return(0); | 156 | return 0; |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * Somehow we've missed the last message. The message will be repeated | 159 | * Somehow we've missed the last message. The message will be repeated |
@@ -162,7 +162,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
162 | if (dev->data.pos >= dev->data.len) { | 162 | if (dev->data.pos >= dev->data.len) { |
163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", | 163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", |
164 | __FUNCTION__, dev->data.pos, dev->data.len); | 164 | __FUNCTION__, dev->data.pos, dev->data.len); |
165 | return(-1); | 165 | return -1; |
166 | } | 166 | } |
167 | 167 | ||
168 | /* Load as much as we can into the tester. */ | 168 | /* Load as much as we can into the tester. */ |
@@ -172,7 +172,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
172 | dev->data.bits_left += 8; | 172 | dev->data.bits_left += 8; |
173 | } | 173 | } |
174 | 174 | ||
175 | return(0); | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* | 178 | /* |
@@ -311,10 +311,10 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs) | |||
311 | __FUNCTION__, message.system, message.button, message.toggle); | 311 | __FUNCTION__, message.system, message.button, message.toggle); |
312 | 312 | ||
313 | if (message.toggle != remote->toggle) { | 313 | if (message.toggle != remote->toggle) { |
314 | input_regs(&remote->input, regs); | 314 | input_regs(remote->input, regs); |
315 | input_report_key(&remote->input, keyspan_key_table[message.button], 1); | 315 | input_report_key(remote->input, keyspan_key_table[message.button], 1); |
316 | input_report_key(&remote->input, keyspan_key_table[message.button], 0); | 316 | input_report_key(remote->input, keyspan_key_table[message.button], 0); |
317 | input_sync(&remote->input); | 317 | input_sync(remote->input); |
318 | remote->toggle = message.toggle; | 318 | remote->toggle = message.toggle; |
319 | } | 319 | } |
320 | 320 | ||
@@ -397,14 +397,9 @@ static int keyspan_open(struct input_dev *dev) | |||
397 | { | 397 | { |
398 | struct usb_keyspan *remote = dev->private; | 398 | struct usb_keyspan *remote = dev->private; |
399 | 399 | ||
400 | if (remote->open++) | ||
401 | return 0; | ||
402 | |||
403 | remote->irq_urb->dev = remote->udev; | 400 | remote->irq_urb->dev = remote->udev; |
404 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) { | 401 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) |
405 | remote->open--; | ||
406 | return -EIO; | 402 | return -EIO; |
407 | } | ||
408 | 403 | ||
409 | return 0; | 404 | return 0; |
410 | } | 405 | } |
@@ -413,8 +408,26 @@ static void keyspan_close(struct input_dev *dev) | |||
413 | { | 408 | { |
414 | struct usb_keyspan *remote = dev->private; | 409 | struct usb_keyspan *remote = dev->private; |
415 | 410 | ||
416 | if (!--remote->open) | 411 | usb_kill_urb(remote->irq_urb); |
417 | usb_kill_urb(remote->irq_urb); | 412 | } |
413 | |||
414 | static struct usb_endpoint_descriptor *keyspan_get_in_endpoint(struct usb_host_interface *iface) | ||
415 | { | ||
416 | |||
417 | struct usb_endpoint_descriptor *endpoint; | ||
418 | int i; | ||
419 | |||
420 | for (i = 0; i < iface->desc.bNumEndpoints; ++i) { | ||
421 | endpoint = &iface->endpoint[i].desc; | ||
422 | |||
423 | if ((endpoint->bEndpointAddress & USB_DIR_IN) && | ||
424 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
425 | /* we found our interrupt in endpoint */ | ||
426 | return endpoint; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | return NULL; | ||
418 | } | 431 | } |
419 | 432 | ||
420 | /* | 433 | /* |
@@ -422,110 +435,78 @@ static void keyspan_close(struct input_dev *dev) | |||
422 | */ | 435 | */ |
423 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) | 436 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) |
424 | { | 437 | { |
425 | int i; | 438 | struct usb_device *udev = interface_to_usbdev(interface); |
426 | int retval = -ENOMEM; | ||
427 | char path[64]; | ||
428 | char *buf; | ||
429 | struct usb_keyspan *remote = NULL; | ||
430 | struct usb_host_interface *iface_desc; | ||
431 | struct usb_endpoint_descriptor *endpoint; | 439 | struct usb_endpoint_descriptor *endpoint; |
432 | struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); | 440 | struct usb_keyspan *remote; |
441 | struct input_dev *input_dev; | ||
442 | int i, retval; | ||
433 | 443 | ||
434 | /* allocate memory for our device state and initialize it */ | 444 | endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); |
435 | remote = kmalloc(sizeof(*remote), GFP_KERNEL); | 445 | if (!endpoint) |
436 | if (remote == NULL) { | 446 | return -ENODEV; |
437 | err("Out of memory\n"); | 447 | |
438 | goto error; | 448 | remote = kzalloc(sizeof(*remote), GFP_KERNEL); |
449 | input_dev = input_allocate_device(); | ||
450 | if (!remote || !input_dev) { | ||
451 | retval = -ENOMEM; | ||
452 | goto fail1; | ||
439 | } | 453 | } |
440 | memset(remote, 0x00, sizeof(*remote)); | ||
441 | 454 | ||
442 | remote->udev = udev; | 455 | remote->udev = udev; |
456 | remote->input = input_dev; | ||
443 | remote->interface = interface; | 457 | remote->interface = interface; |
458 | remote->in_endpoint = endpoint; | ||
444 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ | 459 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ |
445 | 460 | ||
446 | /* set up the endpoint information */ | 461 | remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); |
447 | /* use only the first in interrupt endpoint */ | 462 | if (!remote->in_buffer) { |
448 | iface_desc = interface->cur_altsetting; | 463 | retval = -ENOMEM; |
449 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 464 | goto fail1; |
450 | endpoint = &iface_desc->endpoint[i].desc; | ||
451 | |||
452 | if (!remote->in_endpoint && | ||
453 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
454 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
455 | /* we found our interrupt in endpoint */ | ||
456 | remote->in_endpoint = endpoint; | ||
457 | |||
458 | remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); | ||
459 | if (!remote->in_buffer) { | ||
460 | retval = -ENOMEM; | ||
461 | goto error; | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | |||
466 | if (!remote->in_endpoint) { | ||
467 | err("Could not find interrupt input endpoint.\n"); | ||
468 | retval = -ENODEV; | ||
469 | goto error; | ||
470 | } | 465 | } |
471 | 466 | ||
472 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 467 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
473 | if (!remote->irq_urb) { | 468 | if (!remote->irq_urb) { |
474 | err("Failed to allocate urb.\n"); | ||
475 | retval = -ENOMEM; | 469 | retval = -ENOMEM; |
476 | goto error; | 470 | goto fail2; |
477 | } | 471 | } |
478 | 472 | ||
479 | retval = keyspan_setup(remote->udev); | 473 | retval = keyspan_setup(udev); |
480 | if (retval) { | 474 | if (retval) { |
481 | err("Failed to setup device.\n"); | ||
482 | retval = -ENODEV; | 475 | retval = -ENODEV; |
483 | goto error; | 476 | goto fail3; |
484 | } | ||
485 | |||
486 | /* | ||
487 | * Setup the input system with the bits we are going to be reporting | ||
488 | */ | ||
489 | remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ | ||
490 | for (i = 0; i < 32; ++i) { | ||
491 | if (keyspan_key_table[i] != KEY_RESERVED) { | ||
492 | set_bit(keyspan_key_table[i], remote->input.keybit); | ||
493 | } | ||
494 | } | 477 | } |
495 | 478 | ||
496 | remote->input.private = remote; | 479 | if (udev->manufacturer) |
497 | remote->input.open = keyspan_open; | 480 | strlcpy(remote->name, udev->manufacturer, sizeof(remote->name)); |
498 | remote->input.close = keyspan_close; | ||
499 | |||
500 | usb_make_path(remote->udev, path, 64); | ||
501 | sprintf(remote->phys, "%s/input0", path); | ||
502 | 481 | ||
503 | remote->input.name = remote->name; | 482 | if (udev->product) { |
504 | remote->input.phys = remote->phys; | 483 | if (udev->manufacturer) |
505 | remote->input.id.bustype = BUS_USB; | 484 | strlcat(remote->name, " ", sizeof(remote->name)); |
506 | remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor); | 485 | strlcat(remote->name, udev->product, sizeof(remote->name)); |
507 | remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct); | ||
508 | remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice); | ||
509 | |||
510 | if (!(buf = kmalloc(63, GFP_KERNEL))) { | ||
511 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
512 | kfree(remote); | ||
513 | return -ENOMEM; | ||
514 | } | 486 | } |
515 | 487 | ||
516 | if (remote->udev->descriptor.iManufacturer && | 488 | if (!strlen(remote->name)) |
517 | usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0) | 489 | snprintf(remote->name, sizeof(remote->name), |
518 | strcat(remote->name, buf); | 490 | "USB Keyspan Remote %04x:%04x", |
491 | le16_to_cpu(udev->descriptor.idVendor), | ||
492 | le16_to_cpu(udev->descriptor.idProduct)); | ||
519 | 493 | ||
520 | if (remote->udev->descriptor.iProduct && | 494 | usb_make_path(udev, remote->phys, sizeof(remote->phys)); |
521 | usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0) | 495 | strlcat(remote->phys, "/input0", sizeof(remote->phys)); |
522 | sprintf(remote->name, "%s %s", remote->name, buf); | ||
523 | 496 | ||
524 | if (!strlen(remote->name)) | 497 | input_dev->name = remote->name; |
525 | sprintf(remote->name, "USB Keyspan Remote %04x:%04x", | 498 | input_dev->phys = remote->phys; |
526 | remote->input.id.vendor, remote->input.id.product); | 499 | usb_to_input_id(udev, &input_dev->id); |
500 | input_dev->cdev.dev = &interface->dev; | ||
527 | 501 | ||
528 | kfree(buf); | 502 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ |
503 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) | ||
504 | if (keyspan_key_table[i] != KEY_RESERVED) | ||
505 | set_bit(keyspan_key_table[i], input_dev->keybit); | ||
506 | |||
507 | input_dev->private = remote; | ||
508 | input_dev->open = keyspan_open; | ||
509 | input_dev->close = keyspan_close; | ||
529 | 510 | ||
530 | /* | 511 | /* |
531 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() | 512 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() |
@@ -538,27 +519,17 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
538 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 519 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
539 | 520 | ||
540 | /* we can register the device now, as it is ready */ | 521 | /* we can register the device now, as it is ready */ |
541 | input_register_device(&remote->input); | 522 | input_register_device(remote->input); |
542 | 523 | ||
543 | /* save our data pointer in this interface device */ | 524 | /* save our data pointer in this interface device */ |
544 | usb_set_intfdata(interface, remote); | 525 | usb_set_intfdata(interface, remote); |
545 | 526 | ||
546 | /* let the user know what node this device is now attached to */ | ||
547 | info("connected: %s on %s", remote->name, path); | ||
548 | return 0; | 527 | return 0; |
549 | 528 | ||
550 | error: | 529 | fail3: usb_free_urb(remote->irq_urb); |
551 | /* | 530 | fail2: usb_buffer_free(udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
552 | * In case of error we need to clean up any allocated buffers | 531 | fail1: kfree(remote); |
553 | */ | 532 | input_free_device(input_dev); |
554 | if (remote->irq_urb) | ||
555 | usb_free_urb(remote->irq_urb); | ||
556 | |||
557 | if (remote->in_buffer) | ||
558 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
559 | |||
560 | if (remote) | ||
561 | kfree(remote); | ||
562 | 533 | ||
563 | return retval; | 534 | return retval; |
564 | } | 535 | } |
@@ -570,23 +541,16 @@ static void keyspan_disconnect(struct usb_interface *interface) | |||
570 | { | 541 | { |
571 | struct usb_keyspan *remote; | 542 | struct usb_keyspan *remote; |
572 | 543 | ||
573 | /* prevent keyspan_open() from racing keyspan_disconnect() */ | ||
574 | lock_kernel(); | ||
575 | |||
576 | remote = usb_get_intfdata(interface); | 544 | remote = usb_get_intfdata(interface); |
577 | usb_set_intfdata(interface, NULL); | 545 | usb_set_intfdata(interface, NULL); |
578 | 546 | ||
579 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ | 547 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ |
580 | input_unregister_device(&remote->input); | 548 | input_unregister_device(remote->input); |
581 | usb_kill_urb(remote->irq_urb); | 549 | usb_kill_urb(remote->irq_urb); |
582 | usb_free_urb(remote->irq_urb); | 550 | usb_free_urb(remote->irq_urb); |
583 | usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma); | 551 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
584 | kfree(remote); | 552 | kfree(remote); |
585 | } | 553 | } |
586 | |||
587 | unlock_kernel(); | ||
588 | |||
589 | info("USB Keyspan now disconnected"); | ||
590 | } | 554 | } |
591 | 555 | ||
592 | /* | 556 | /* |
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index ff9275057a18..7fce526560ca 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c | |||
@@ -98,7 +98,7 @@ struct mtouch_usb { | |||
98 | dma_addr_t data_dma; | 98 | dma_addr_t data_dma; |
99 | struct urb *irq; | 99 | struct urb *irq; |
100 | struct usb_device *udev; | 100 | struct usb_device *udev; |
101 | struct input_dev input; | 101 | struct input_dev *input; |
102 | char name[128]; | 102 | char name[128]; |
103 | char phys[64]; | 103 | char phys[64]; |
104 | }; | 104 | }; |
@@ -135,14 +135,14 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) | |||
135 | goto exit; | 135 | goto exit; |
136 | } | 136 | } |
137 | 137 | ||
138 | input_regs(&mtouch->input, regs); | 138 | input_regs(mtouch->input, regs); |
139 | input_report_key(&mtouch->input, BTN_TOUCH, | 139 | input_report_key(mtouch->input, BTN_TOUCH, |
140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); | 140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); |
141 | input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); | 141 | input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); |
142 | input_report_abs(&mtouch->input, ABS_Y, | 142 | input_report_abs(mtouch->input, ABS_Y, |
143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) | 143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) |
144 | - MTOUCHUSB_GET_YC(mtouch->data)); | 144 | - MTOUCHUSB_GET_YC(mtouch->data)); |
145 | input_sync(&mtouch->input); | 145 | input_sync(mtouch->input); |
146 | 146 | ||
147 | exit: | 147 | exit: |
148 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 148 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -195,10 +195,10 @@ static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *m | |||
195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
196 | { | 196 | { |
197 | struct mtouch_usb *mtouch; | 197 | struct mtouch_usb *mtouch; |
198 | struct input_dev *input_dev; | ||
198 | struct usb_host_interface *interface; | 199 | struct usb_host_interface *interface; |
199 | struct usb_endpoint_descriptor *endpoint; | 200 | struct usb_endpoint_descriptor *endpoint; |
200 | struct usb_device *udev = interface_to_usbdev(intf); | 201 | struct usb_device *udev = interface_to_usbdev(intf); |
201 | char path[64]; | ||
202 | int nRet; | 202 | int nRet; |
203 | 203 | ||
204 | dbg("%s - called", __FUNCTION__); | 204 | dbg("%s - called", __FUNCTION__); |
@@ -209,57 +209,55 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
209 | dbg("%s - setting endpoint", __FUNCTION__); | 209 | dbg("%s - setting endpoint", __FUNCTION__); |
210 | endpoint = &interface->endpoint[0].desc; | 210 | endpoint = &interface->endpoint[0].desc; |
211 | 211 | ||
212 | if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { | 212 | mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL); |
213 | input_dev = input_allocate_device(); | ||
214 | if (!mtouch || !input_dev) { | ||
213 | err("%s - Out of memory.", __FUNCTION__); | 215 | err("%s - Out of memory.", __FUNCTION__); |
214 | return -ENOMEM; | 216 | goto fail1; |
215 | } | 217 | } |
216 | 218 | ||
217 | memset(mtouch, 0, sizeof(struct mtouch_usb)); | ||
218 | mtouch->udev = udev; | ||
219 | |||
220 | dbg("%s - allocating buffers", __FUNCTION__); | 219 | dbg("%s - allocating buffers", __FUNCTION__); |
221 | if (mtouchusb_alloc_buffers(udev, mtouch)) { | 220 | if (mtouchusb_alloc_buffers(udev, mtouch)) |
222 | mtouchusb_free_buffers(udev, mtouch); | 221 | goto fail2; |
223 | kfree(mtouch); | ||
224 | return -ENOMEM; | ||
225 | } | ||
226 | 222 | ||
227 | mtouch->input.private = mtouch; | 223 | mtouch->udev = udev; |
228 | mtouch->input.open = mtouchusb_open; | 224 | mtouch->input = input_dev; |
229 | mtouch->input.close = mtouchusb_close; | ||
230 | |||
231 | usb_make_path(udev, path, 64); | ||
232 | sprintf(mtouch->phys, "%s/input0", path); | ||
233 | |||
234 | mtouch->input.name = mtouch->name; | ||
235 | mtouch->input.phys = mtouch->phys; | ||
236 | usb_to_input_id(udev, &mtouch->input.id); | ||
237 | mtouch->input.dev = &intf->dev; | ||
238 | |||
239 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
240 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
241 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
242 | |||
243 | /* Used to Scale Compensated Data and Flip Y */ | ||
244 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; | ||
245 | mtouch->input.absmax[ABS_X] = raw_coordinates ? | ||
246 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; | ||
247 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; | ||
248 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; | ||
249 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; | ||
250 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? | ||
251 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; | ||
252 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; | ||
253 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; | ||
254 | 225 | ||
255 | if (udev->manufacturer) | 226 | if (udev->manufacturer) |
256 | strcat(mtouch->name, udev->manufacturer); | 227 | strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name)); |
257 | if (udev->product) | 228 | |
258 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); | 229 | if (udev->product) { |
230 | if (udev->manufacturer) | ||
231 | strlcat(mtouch->name, " ", sizeof(mtouch->name)); | ||
232 | strlcat(mtouch->name, udev->product, sizeof(mtouch->name)); | ||
233 | } | ||
259 | 234 | ||
260 | if (!strlen(mtouch->name)) | 235 | if (!strlen(mtouch->name)) |
261 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", | 236 | snprintf(mtouch->name, sizeof(mtouch->name), |
262 | mtouch->input.id.vendor, mtouch->input.id.product); | 237 | "USB Touchscreen %04x:%04x", |
238 | le16_to_cpu(udev->descriptor.idVendor), | ||
239 | le16_to_cpu(udev->descriptor.idProduct)); | ||
240 | |||
241 | usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys)); | ||
242 | strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys)); | ||
243 | |||
244 | input_dev->name = mtouch->name; | ||
245 | input_dev->phys = mtouch->phys; | ||
246 | usb_to_input_id(udev, &input_dev->id); | ||
247 | input_dev->cdev.dev = &intf->dev; | ||
248 | input_dev->private = mtouch; | ||
249 | |||
250 | input_dev->open = mtouchusb_open; | ||
251 | input_dev->close = mtouchusb_close; | ||
252 | |||
253 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
254 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
255 | input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC, | ||
256 | raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC, | ||
257 | MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT); | ||
258 | input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC, | ||
259 | raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC, | ||
260 | MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT); | ||
263 | 261 | ||
264 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 262 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
265 | MTOUCHUSB_RESET, | 263 | MTOUCHUSB_RESET, |
@@ -272,9 +270,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
272 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 270 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
273 | if (!mtouch->irq) { | 271 | if (!mtouch->irq) { |
274 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); | 272 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); |
275 | mtouchusb_free_buffers(udev, mtouch); | 273 | goto fail2; |
276 | kfree(mtouch); | ||
277 | return -ENOMEM; | ||
278 | } | 274 | } |
279 | 275 | ||
280 | dbg("%s - usb_fill_int_urb", __FUNCTION__); | 276 | dbg("%s - usb_fill_int_urb", __FUNCTION__); |
@@ -284,7 +280,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
284 | mtouchusb_irq, mtouch, endpoint->bInterval); | 280 | mtouchusb_irq, mtouch, endpoint->bInterval); |
285 | 281 | ||
286 | dbg("%s - input_register_device", __FUNCTION__); | 282 | dbg("%s - input_register_device", __FUNCTION__); |
287 | input_register_device(&mtouch->input); | 283 | input_register_device(mtouch->input); |
288 | 284 | ||
289 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 285 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
290 | MTOUCHUSB_ASYNC_REPORT, | 286 | MTOUCHUSB_ASYNC_REPORT, |
@@ -293,10 +289,13 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
293 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", | 289 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
294 | __FUNCTION__, nRet); | 290 | __FUNCTION__, nRet); |
295 | 291 | ||
296 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); | ||
297 | usb_set_intfdata(intf, mtouch); | 292 | usb_set_intfdata(intf, mtouch); |
298 | |||
299 | return 0; | 293 | return 0; |
294 | |||
295 | fail2: mtouchusb_free_buffers(udev, mtouch); | ||
296 | fail1: input_free_device(input_dev); | ||
297 | kfree(mtouch); | ||
298 | return -ENOMEM; | ||
300 | } | 299 | } |
301 | 300 | ||
302 | static void mtouchusb_disconnect(struct usb_interface *intf) | 301 | static void mtouchusb_disconnect(struct usb_interface *intf) |
@@ -308,7 +307,7 @@ static void mtouchusb_disconnect(struct usb_interface *intf) | |||
308 | if (mtouch) { | 307 | if (mtouch) { |
309 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); | 308 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); |
310 | usb_kill_urb(mtouch->irq); | 309 | usb_kill_urb(mtouch->irq); |
311 | input_unregister_device(&mtouch->input); | 310 | input_unregister_device(mtouch->input); |
312 | usb_free_urb(mtouch->irq); | 311 | usb_free_urb(mtouch->irq); |
313 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); | 312 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); |
314 | kfree(mtouch); | 313 | kfree(mtouch); |
diff --git a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c index acc71ec560e9..a00672c96644 100644 --- a/drivers/usb/input/pid.c +++ b/drivers/usb/input/pid.c | |||
@@ -262,6 +262,7 @@ int hid_pid_init(struct hid_device *hid) | |||
262 | { | 262 | { |
263 | struct hid_ff_pid *private; | 263 | struct hid_ff_pid *private; |
264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); | 264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); |
265 | struct input_dev *input_dev = hidinput->input; | ||
265 | 266 | ||
266 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); | 267 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); |
267 | if (!private) | 268 | if (!private) |
@@ -281,11 +282,12 @@ int hid_pid_init(struct hid_device *hid) | |||
281 | usb_fill_control_urb(private->urbffout, hid->dev, 0, | 282 | usb_fill_control_urb(private->urbffout, hid->dev, 0, |
282 | (void *)&private->ffcr, private->ctrl_buffer, 8, | 283 | (void *)&private->ffcr, private->ctrl_buffer, 8, |
283 | hid_pid_ctrl_out, hid); | 284 | hid_pid_ctrl_out, hid); |
284 | hidinput->input.upload_effect = hid_pid_upload_effect; | 285 | |
285 | hidinput->input.flush = hid_pid_flush; | 286 | input_dev->upload_effect = hid_pid_upload_effect; |
286 | hidinput->input.ff_effects_max = 8; // A random default | 287 | input_dev->flush = hid_pid_flush; |
287 | set_bit(EV_FF, hidinput->input.evbit); | 288 | input_dev->ff_effects_max = 8; // A random default |
288 | set_bit(EV_FF_STATUS, hidinput->input.evbit); | 289 | set_bit(EV_FF, input_dev->evbit); |
290 | set_bit(EV_FF_STATUS, input_dev->evbit); | ||
289 | 291 | ||
290 | spin_lock_init(&private->lock); | 292 | spin_lock_init(&private->lock); |
291 | 293 | ||
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index ad4afe7e5897..b7476233ef5d 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c | |||
@@ -68,7 +68,7 @@ struct powermate_device { | |||
68 | struct usb_ctrlrequest *configcr; | 68 | struct usb_ctrlrequest *configcr; |
69 | dma_addr_t configcr_dma; | 69 | dma_addr_t configcr_dma; |
70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
71 | struct input_dev input; | 71 | struct input_dev *input; |
72 | spinlock_t lock; | 72 | spinlock_t lock; |
73 | int static_brightness; | 73 | int static_brightness; |
74 | int pulse_speed; | 74 | int pulse_speed; |
@@ -106,10 +106,10 @@ static void powermate_irq(struct urb *urb, struct pt_regs *regs) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | /* handle updates to device state */ | 108 | /* handle updates to device state */ |
109 | input_regs(&pm->input, regs); | 109 | input_regs(pm->input, regs); |
110 | input_report_key(&pm->input, BTN_0, pm->data[0] & 0x01); | 110 | input_report_key(pm->input, BTN_0, pm->data[0] & 0x01); |
111 | input_report_rel(&pm->input, REL_DIAL, pm->data[1]); | 111 | input_report_rel(pm->input, REL_DIAL, pm->data[1]); |
112 | input_sync(&pm->input); | 112 | input_sync(pm->input); |
113 | 113 | ||
114 | exit: | 114 | exit: |
115 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 115 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
@@ -153,10 +153,10 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
153 | 153 | ||
154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. | 154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. |
155 | */ | 155 | */ |
156 | if (pm->pulse_speed < 255){ | 156 | if (pm->pulse_speed < 255) { |
157 | op = 0; // divide | 157 | op = 0; // divide |
158 | arg = 255 - pm->pulse_speed; | 158 | arg = 255 - pm->pulse_speed; |
159 | } else if (pm->pulse_speed > 255){ | 159 | } else if (pm->pulse_speed > 255) { |
160 | op = 2; // multiply | 160 | op = 2; // multiply |
161 | arg = pm->pulse_speed - 255; | 161 | arg = pm->pulse_speed - 255; |
162 | } else { | 162 | } else { |
@@ -166,11 +166,11 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); | 166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); |
167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); | 167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); |
168 | pm->requires_update &= ~UPDATE_PULSE_MODE; | 168 | pm->requires_update &= ~UPDATE_PULSE_MODE; |
169 | }else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS){ | 169 | } else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS) { |
170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); | 170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); |
171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); | 171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); |
172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; | 172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; |
173 | }else{ | 173 | } else { |
174 | printk(KERN_ERR "powermate: unknown update required"); | 174 | printk(KERN_ERR "powermate: unknown update required"); |
175 | pm->requires_update = 0; /* fudge the bug */ | 175 | pm->requires_update = 0; /* fudge the bug */ |
176 | return; | 176 | return; |
@@ -228,19 +228,19 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
228 | spin_lock_irqsave(&pm->lock, flags); | 228 | spin_lock_irqsave(&pm->lock, flags); |
229 | 229 | ||
230 | /* mark state updates which are required */ | 230 | /* mark state updates which are required */ |
231 | if (static_brightness != pm->static_brightness){ | 231 | if (static_brightness != pm->static_brightness) { |
232 | pm->static_brightness = static_brightness; | 232 | pm->static_brightness = static_brightness; |
233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; | 233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; |
234 | } | 234 | } |
235 | if (pulse_asleep != pm->pulse_asleep){ | 235 | if (pulse_asleep != pm->pulse_asleep) { |
236 | pm->pulse_asleep = pulse_asleep; | 236 | pm->pulse_asleep = pulse_asleep; |
237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); | 237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); |
238 | } | 238 | } |
239 | if (pulse_awake != pm->pulse_awake){ | 239 | if (pulse_awake != pm->pulse_awake) { |
240 | pm->pulse_awake = pulse_awake; | 240 | pm->pulse_awake = pulse_awake; |
241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); | 241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); |
242 | } | 242 | } |
243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table){ | 243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table) { |
244 | pm->pulse_speed = pulse_speed; | 244 | pm->pulse_speed = pulse_speed; |
245 | pm->pulse_table = pulse_table; | 245 | pm->pulse_table = pulse_table; |
246 | pm->requires_update |= UPDATE_PULSE_MODE; | 246 | pm->requires_update |= UPDATE_PULSE_MODE; |
@@ -283,6 +283,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev | |||
283 | SLAB_ATOMIC, &pm->data_dma); | 283 | SLAB_ATOMIC, &pm->data_dma); |
284 | if (!pm->data) | 284 | if (!pm->data) |
285 | return -1; | 285 | return -1; |
286 | |||
286 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), | 287 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), |
287 | SLAB_ATOMIC, &pm->configcr_dma); | 288 | SLAB_ATOMIC, &pm->configcr_dma); |
288 | if (!pm->configcr) | 289 | if (!pm->configcr) |
@@ -308,8 +309,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
308 | struct usb_host_interface *interface; | 309 | struct usb_host_interface *interface; |
309 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
310 | struct powermate_device *pm; | 311 | struct powermate_device *pm; |
312 | struct input_dev *input_dev; | ||
311 | int pipe, maxp; | 313 | int pipe, maxp; |
312 | char path[64]; | 314 | int err = -ENOMEM; |
313 | 315 | ||
314 | interface = intf->cur_altsetting; | 316 | interface = intf->cur_altsetting; |
315 | endpoint = &interface->endpoint[0].desc; | 317 | endpoint = &interface->endpoint[0].desc; |
@@ -323,42 +325,61 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
323 | 0, interface->desc.bInterfaceNumber, NULL, 0, | 325 | 0, interface->desc.bInterfaceNumber, NULL, 0, |
324 | USB_CTRL_SET_TIMEOUT); | 326 | USB_CTRL_SET_TIMEOUT); |
325 | 327 | ||
326 | if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) | 328 | pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL); |
327 | return -ENOMEM; | 329 | input_dev = input_allocate_device(); |
328 | 330 | if (!pm || !input_dev) | |
329 | memset(pm, 0, sizeof(struct powermate_device)); | 331 | goto fail1; |
330 | pm->udev = udev; | ||
331 | 332 | ||
332 | if (powermate_alloc_buffers(udev, pm)) { | 333 | if (powermate_alloc_buffers(udev, pm)) |
333 | powermate_free_buffers(udev, pm); | 334 | goto fail2; |
334 | kfree(pm); | ||
335 | return -ENOMEM; | ||
336 | } | ||
337 | 335 | ||
338 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); | 336 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); |
339 | if (!pm->irq) { | 337 | if (!pm->irq) |
340 | powermate_free_buffers(udev, pm); | 338 | goto fail2; |
341 | kfree(pm); | ||
342 | return -ENOMEM; | ||
343 | } | ||
344 | 339 | ||
345 | pm->config = usb_alloc_urb(0, GFP_KERNEL); | 340 | pm->config = usb_alloc_urb(0, GFP_KERNEL); |
346 | if (!pm->config) { | 341 | if (!pm->config) |
347 | usb_free_urb(pm->irq); | 342 | goto fail3; |
348 | powermate_free_buffers(udev, pm); | 343 | |
349 | kfree(pm); | 344 | pm->udev = udev; |
350 | return -ENOMEM; | 345 | pm->input = input_dev; |
351 | } | 346 | |
347 | usb_make_path(udev, pm->phys, sizeof(pm->phys)); | ||
348 | strlcpy(pm->phys, "/input0", sizeof(pm->phys)); | ||
352 | 349 | ||
353 | spin_lock_init(&pm->lock); | 350 | spin_lock_init(&pm->lock); |
354 | init_input_dev(&pm->input); | 351 | |
352 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | ||
353 | case POWERMATE_PRODUCT_NEW: | ||
354 | input_dev->name = pm_name_powermate; | ||
355 | break; | ||
356 | case POWERMATE_PRODUCT_OLD: | ||
357 | input_dev->name = pm_name_soundknob; | ||
358 | break; | ||
359 | default: | ||
360 | input_dev->name = pm_name_soundknob; | ||
361 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
362 | le16_to_cpu(udev->descriptor.idProduct)); | ||
363 | } | ||
364 | |||
365 | input_dev->phys = pm->phys; | ||
366 | usb_to_input_id(udev, &input_dev->id); | ||
367 | input_dev->cdev.dev = &intf->dev; | ||
368 | input_dev->private = pm; | ||
369 | |||
370 | input_dev->event = powermate_input_event; | ||
371 | |||
372 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
373 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
374 | input_dev->relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
375 | input_dev->mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
355 | 376 | ||
356 | /* get a handle to the interrupt data pipe */ | 377 | /* get a handle to the interrupt data pipe */ |
357 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 378 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
358 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 379 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
359 | 380 | ||
360 | if(maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX){ | 381 | if (maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX) { |
361 | printk("powermate: Expected payload of %d--%d bytes, found %d bytes!\n", | 382 | printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n", |
362 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); | 383 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); |
363 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; | 384 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; |
364 | } | 385 | } |
@@ -371,35 +392,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
371 | 392 | ||
372 | /* register our interrupt URB with the USB system */ | 393 | /* register our interrupt URB with the USB system */ |
373 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { | 394 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { |
374 | powermate_free_buffers(udev, pm); | 395 | err = -EIO; |
375 | kfree(pm); | 396 | goto fail4; |
376 | return -EIO; /* failure */ | ||
377 | } | 397 | } |
378 | 398 | ||
379 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | 399 | input_register_device(pm->input); |
380 | case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; | ||
381 | case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; | ||
382 | default: | ||
383 | pm->input.name = pm_name_soundknob; | ||
384 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
385 | le16_to_cpu(udev->descriptor.idProduct)); | ||
386 | } | ||
387 | |||
388 | pm->input.private = pm; | ||
389 | pm->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
390 | pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
391 | pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
392 | pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
393 | usb_to_input_id(udev, &pm->input.id); | ||
394 | pm->input.event = powermate_input_event; | ||
395 | pm->input.dev = &intf->dev; | ||
396 | pm->input.phys = pm->phys; | ||
397 | |||
398 | input_register_device(&pm->input); | ||
399 | |||
400 | usb_make_path(udev, path, 64); | ||
401 | snprintf(pm->phys, 64, "%s/input0", path); | ||
402 | printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); | ||
403 | 400 | ||
404 | /* force an update of everything */ | 401 | /* force an update of everything */ |
405 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; | 402 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; |
@@ -407,6 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
407 | 404 | ||
408 | usb_set_intfdata(intf, pm); | 405 | usb_set_intfdata(intf, pm); |
409 | return 0; | 406 | return 0; |
407 | |||
408 | fail4: usb_free_urb(pm->config); | ||
409 | fail3: usb_free_urb(pm->irq); | ||
410 | fail2: powermate_free_buffers(udev, pm); | ||
411 | fail1: input_free_device(input_dev); | ||
412 | kfree(pm); | ||
413 | return err; | ||
410 | } | 414 | } |
411 | 415 | ||
412 | /* 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 */ |
@@ -418,7 +422,7 @@ static void powermate_disconnect(struct usb_interface *intf) | |||
418 | if (pm) { | 422 | if (pm) { |
419 | pm->requires_update = 0; | 423 | pm->requires_update = 0; |
420 | usb_kill_urb(pm->irq); | 424 | usb_kill_urb(pm->irq); |
421 | input_unregister_device(&pm->input); | 425 | input_unregister_device(pm->input); |
422 | usb_free_urb(pm->irq); | 426 | usb_free_urb(pm->irq); |
423 | usb_free_urb(pm->config); | 427 | usb_free_urb(pm->config); |
424 | powermate_free_buffers(interface_to_usbdev(intf), pm); | 428 | powermate_free_buffers(interface_to_usbdev(intf), pm); |
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 4276c24a5080..3766ccc271be 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c | |||
@@ -68,7 +68,7 @@ struct touchkit_usb { | |||
68 | dma_addr_t data_dma; | 68 | dma_addr_t data_dma; |
69 | struct urb *irq; | 69 | struct urb *irq; |
70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
71 | struct input_dev input; | 71 | struct input_dev *input; |
72 | char name[128]; | 72 | char name[128]; |
73 | char phys[64]; | 73 | char phys[64]; |
74 | }; | 74 | }; |
@@ -115,12 +115,12 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs) | |||
115 | y = TOUCHKIT_GET_Y(touchkit->data); | 115 | y = TOUCHKIT_GET_Y(touchkit->data); |
116 | } | 116 | } |
117 | 117 | ||
118 | input_regs(&touchkit->input, regs); | 118 | input_regs(touchkit->input, regs); |
119 | input_report_key(&touchkit->input, BTN_TOUCH, | 119 | input_report_key(touchkit->input, BTN_TOUCH, |
120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); | 120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); |
121 | input_report_abs(&touchkit->input, ABS_X, x); | 121 | input_report_abs(touchkit->input, ABS_X, x); |
122 | input_report_abs(&touchkit->input, ABS_Y, y); | 122 | input_report_abs(touchkit->input, ABS_Y, y); |
123 | input_sync(&touchkit->input); | 123 | input_sync(touchkit->input); |
124 | 124 | ||
125 | exit: | 125 | exit: |
126 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 126 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -171,87 +171,81 @@ static void touchkit_free_buffers(struct usb_device *udev, | |||
171 | static int touchkit_probe(struct usb_interface *intf, | 171 | static int touchkit_probe(struct usb_interface *intf, |
172 | const struct usb_device_id *id) | 172 | const struct usb_device_id *id) |
173 | { | 173 | { |
174 | int ret; | ||
175 | struct touchkit_usb *touchkit; | 174 | struct touchkit_usb *touchkit; |
175 | struct input_dev *input_dev; | ||
176 | struct usb_host_interface *interface; | 176 | struct usb_host_interface *interface; |
177 | struct usb_endpoint_descriptor *endpoint; | 177 | struct usb_endpoint_descriptor *endpoint; |
178 | struct usb_device *udev = interface_to_usbdev(intf); | 178 | struct usb_device *udev = interface_to_usbdev(intf); |
179 | char path[64]; | ||
180 | 179 | ||
181 | interface = intf->cur_altsetting; | 180 | interface = intf->cur_altsetting; |
182 | endpoint = &interface->endpoint[0].desc; | 181 | endpoint = &interface->endpoint[0].desc; |
183 | 182 | ||
184 | touchkit = kmalloc(sizeof(struct touchkit_usb), GFP_KERNEL); | 183 | touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL); |
185 | if (!touchkit) | 184 | input_dev = input_allocate_device(); |
186 | return -ENOMEM; | 185 | if (!touchkit || !input_dev) |
187 | |||
188 | memset(touchkit, 0, sizeof(struct touchkit_usb)); | ||
189 | touchkit->udev = udev; | ||
190 | |||
191 | if (touchkit_alloc_buffers(udev, touchkit)) { | ||
192 | ret = -ENOMEM; | ||
193 | goto out_free; | 186 | goto out_free; |
194 | } | ||
195 | |||
196 | touchkit->input.private = touchkit; | ||
197 | touchkit->input.open = touchkit_open; | ||
198 | touchkit->input.close = touchkit_close; | ||
199 | |||
200 | usb_make_path(udev, path, 64); | ||
201 | sprintf(touchkit->phys, "%s/input0", path); | ||
202 | |||
203 | touchkit->input.name = touchkit->name; | ||
204 | touchkit->input.phys = touchkit->phys; | ||
205 | usb_to_input_id(udev, &touchkit->input.id); | ||
206 | touchkit->input.dev = &intf->dev; | ||
207 | |||
208 | touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
209 | touchkit->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
210 | touchkit->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
211 | |||
212 | /* Used to Scale Compensated Data */ | ||
213 | touchkit->input.absmin[ABS_X] = TOUCHKIT_MIN_XC; | ||
214 | touchkit->input.absmax[ABS_X] = TOUCHKIT_MAX_XC; | ||
215 | touchkit->input.absfuzz[ABS_X] = TOUCHKIT_XC_FUZZ; | ||
216 | touchkit->input.absflat[ABS_X] = TOUCHKIT_XC_FLAT; | ||
217 | touchkit->input.absmin[ABS_Y] = TOUCHKIT_MIN_YC; | ||
218 | touchkit->input.absmax[ABS_Y] = TOUCHKIT_MAX_YC; | ||
219 | touchkit->input.absfuzz[ABS_Y] = TOUCHKIT_YC_FUZZ; | ||
220 | touchkit->input.absflat[ABS_Y] = TOUCHKIT_YC_FLAT; | ||
221 | |||
222 | if (udev->manufacturer) | ||
223 | strcat(touchkit->name, udev->manufacturer); | ||
224 | if (udev->product) | ||
225 | sprintf(touchkit->name, "%s %s", touchkit->name, udev->product); | ||
226 | 187 | ||
227 | if (!strlen(touchkit->name)) | 188 | if (touchkit_alloc_buffers(udev, touchkit)) |
228 | sprintf(touchkit->name, "USB Touchscreen %04x:%04x", | 189 | goto out_free; |
229 | touchkit->input.id.vendor, touchkit->input.id.product); | ||
230 | 190 | ||
231 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); | 191 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); |
232 | if (!touchkit->irq) { | 192 | if (!touchkit->irq) { |
233 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); | 193 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); |
234 | ret = -ENOMEM; | ||
235 | goto out_free_buffers; | 194 | goto out_free_buffers; |
236 | } | 195 | } |
237 | 196 | ||
197 | touchkit->udev = udev; | ||
198 | touchkit->input = input_dev; | ||
199 | |||
200 | if (udev->manufacturer) | ||
201 | strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name)); | ||
202 | |||
203 | if (udev->product) { | ||
204 | if (udev->manufacturer) | ||
205 | strlcat(touchkit->name, " ", sizeof(touchkit->name)); | ||
206 | strlcat(touchkit->name, udev->product, sizeof(touchkit->name)); | ||
207 | } | ||
208 | |||
209 | if (!strlen(touchkit->name)) | ||
210 | snprintf(touchkit->name, sizeof(touchkit->name), | ||
211 | "USB Touchscreen %04x:%04x", | ||
212 | le16_to_cpu(udev->descriptor.idVendor), | ||
213 | le16_to_cpu(udev->descriptor.idProduct)); | ||
214 | |||
215 | usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys)); | ||
216 | strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys)); | ||
217 | |||
218 | input_dev->name = touchkit->name; | ||
219 | input_dev->phys = touchkit->phys; | ||
220 | usb_to_input_id(udev, &input_dev->id); | ||
221 | input_dev->cdev.dev = &intf->dev; | ||
222 | input_dev->private = touchkit; | ||
223 | input_dev->open = touchkit_open; | ||
224 | input_dev->close = touchkit_close; | ||
225 | |||
226 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
227 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
228 | input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC, | ||
229 | TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT); | ||
230 | input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC, | ||
231 | TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT); | ||
232 | |||
238 | usb_fill_int_urb(touchkit->irq, touchkit->udev, | 233 | usb_fill_int_urb(touchkit->irq, touchkit->udev, |
239 | usb_rcvintpipe(touchkit->udev, 0x81), | 234 | usb_rcvintpipe(touchkit->udev, 0x81), |
240 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, | 235 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, |
241 | touchkit_irq, touchkit, endpoint->bInterval); | 236 | touchkit_irq, touchkit, endpoint->bInterval); |
242 | 237 | ||
243 | input_register_device(&touchkit->input); | 238 | input_register_device(touchkit->input); |
244 | 239 | ||
245 | printk(KERN_INFO "input: %s on %s\n", touchkit->name, path); | ||
246 | usb_set_intfdata(intf, touchkit); | 240 | usb_set_intfdata(intf, touchkit); |
247 | |||
248 | return 0; | 241 | return 0; |
249 | 242 | ||
250 | out_free_buffers: | 243 | out_free_buffers: |
251 | touchkit_free_buffers(udev, touchkit); | 244 | touchkit_free_buffers(udev, touchkit); |
252 | out_free: | 245 | out_free: |
246 | input_free_device(input_dev); | ||
253 | kfree(touchkit); | 247 | kfree(touchkit); |
254 | return ret; | 248 | return -ENOMEM; |
255 | } | 249 | } |
256 | 250 | ||
257 | static void touchkit_disconnect(struct usb_interface *intf) | 251 | static void touchkit_disconnect(struct usb_interface *intf) |
@@ -265,8 +259,8 @@ static void touchkit_disconnect(struct usb_interface *intf) | |||
265 | 259 | ||
266 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); | 260 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); |
267 | usb_set_intfdata(intf, NULL); | 261 | usb_set_intfdata(intf, NULL); |
268 | input_unregister_device(&touchkit->input); | ||
269 | usb_kill_urb(touchkit->irq); | 262 | usb_kill_urb(touchkit->irq); |
263 | input_unregister_device(touchkit->input); | ||
270 | usb_free_urb(touchkit->irq); | 264 | usb_free_urb(touchkit->irq); |
271 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); | 265 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); |
272 | kfree(touchkit); | 266 | kfree(touchkit); |
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 28987f15eeee..226b6f90a907 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c | |||
@@ -66,7 +66,7 @@ static unsigned char usb_kbd_keycode[256] = { | |||
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct usb_kbd { | 68 | struct usb_kbd { |
69 | struct input_dev dev; | 69 | struct input_dev *dev; |
70 | struct usb_device *usbdev; | 70 | struct usb_device *usbdev; |
71 | unsigned char old[8]; | 71 | unsigned char old[8]; |
72 | struct urb *irq, *led; | 72 | struct urb *irq, *led; |
@@ -99,29 +99,29 @@ static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs) | |||
99 | goto resubmit; | 99 | goto resubmit; |
100 | } | 100 | } |
101 | 101 | ||
102 | input_regs(&kbd->dev, regs); | 102 | input_regs(kbd->dev, regs); |
103 | 103 | ||
104 | for (i = 0; i < 8; i++) | 104 | for (i = 0; i < 8; i++) |
105 | input_report_key(&kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); | 105 | input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
106 | 106 | ||
107 | for (i = 2; i < 8; i++) { | 107 | for (i = 2; i < 8; i++) { |
108 | 108 | ||
109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { | 109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { |
110 | if (usb_kbd_keycode[kbd->old[i]]) | 110 | if (usb_kbd_keycode[kbd->old[i]]) |
111 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); | 111 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); |
112 | else | 112 | else |
113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); | 113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); |
114 | } | 114 | } |
115 | 115 | ||
116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { | 116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { |
117 | if (usb_kbd_keycode[kbd->new[i]]) | 117 | if (usb_kbd_keycode[kbd->new[i]]) |
118 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); | 118 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); |
119 | else | 119 | else |
120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); | 120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | input_sync(&kbd->dev); | 124 | input_sync(kbd->dev); |
125 | 125 | ||
126 | memcpy(kbd->old, kbd->new, 8); | 126 | memcpy(kbd->old, kbd->new, 8); |
127 | 127 | ||
@@ -227,12 +227,12 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
227 | static int usb_kbd_probe(struct usb_interface *iface, | 227 | static int usb_kbd_probe(struct usb_interface *iface, |
228 | const struct usb_device_id *id) | 228 | const struct usb_device_id *id) |
229 | { | 229 | { |
230 | struct usb_device * dev = interface_to_usbdev(iface); | 230 | struct usb_device *dev = interface_to_usbdev(iface); |
231 | struct usb_host_interface *interface; | 231 | struct usb_host_interface *interface; |
232 | struct usb_endpoint_descriptor *endpoint; | 232 | struct usb_endpoint_descriptor *endpoint; |
233 | struct usb_kbd *kbd; | 233 | struct usb_kbd *kbd; |
234 | struct input_dev *input_dev; | ||
234 | int i, pipe, maxp; | 235 | int i, pipe, maxp; |
235 | char path[64]; | ||
236 | 236 | ||
237 | interface = iface->cur_altsetting; | 237 | interface = iface->cur_altsetting; |
238 | 238 | ||
@@ -240,37 +240,59 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
240 | return -ENODEV; | 240 | return -ENODEV; |
241 | 241 | ||
242 | endpoint = &interface->endpoint[0].desc; | 242 | endpoint = &interface->endpoint[0].desc; |
243 | if (!(endpoint->bEndpointAddress & 0x80)) | 243 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
244 | return -ENODEV; | 244 | return -ENODEV; |
245 | if ((endpoint->bmAttributes & 3) != 3) | 245 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
246 | return -ENODEV; | 246 | return -ENODEV; |
247 | 247 | ||
248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
250 | 250 | ||
251 | if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) | 251 | kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); |
252 | return -ENOMEM; | 252 | input_dev = input_allocate_device(); |
253 | memset(kbd, 0, sizeof(struct usb_kbd)); | 253 | if (!kbd || !input_dev) |
254 | goto fail1; | ||
254 | 255 | ||
255 | if (usb_kbd_alloc_mem(dev, kbd)) { | 256 | if (usb_kbd_alloc_mem(dev, kbd)) |
256 | usb_kbd_free_mem(dev, kbd); | 257 | goto fail2; |
257 | kfree(kbd); | ||
258 | return -ENOMEM; | ||
259 | } | ||
260 | 258 | ||
261 | kbd->usbdev = dev; | 259 | kbd->usbdev = dev; |
260 | kbd->dev = input_dev; | ||
261 | |||
262 | if (dev->manufacturer) | ||
263 | strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); | ||
264 | |||
265 | if (dev->product) { | ||
266 | if (dev->manufacturer) | ||
267 | strlcat(kbd->name, " ", sizeof(kbd->name)); | ||
268 | strlcat(kbd->name, dev->product, sizeof(kbd->name)); | ||
269 | } | ||
270 | |||
271 | if (!strlen(kbd->name)) | ||
272 | snprintf(kbd->name, sizeof(kbd->name), | ||
273 | "USB HIDBP Keyboard %04x:%04x", | ||
274 | le16_to_cpu(dev->descriptor.idVendor), | ||
275 | le16_to_cpu(dev->descriptor.idProduct)); | ||
276 | |||
277 | usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); | ||
278 | strlcpy(kbd->phys, "/input0", sizeof(kbd->phys)); | ||
262 | 279 | ||
263 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 280 | input_dev->name = kbd->name; |
264 | kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 281 | input_dev->phys = kbd->phys; |
282 | usb_to_input_id(dev, &input_dev->id); | ||
283 | input_dev->cdev.dev = &iface->dev; | ||
284 | input_dev->private = kbd; | ||
285 | |||
286 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | ||
287 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | ||
265 | 288 | ||
266 | for (i = 0; i < 255; i++) | 289 | for (i = 0; i < 255; i++) |
267 | set_bit(usb_kbd_keycode[i], kbd->dev.keybit); | 290 | set_bit(usb_kbd_keycode[i], input_dev->keybit); |
268 | clear_bit(0, kbd->dev.keybit); | 291 | clear_bit(0, input_dev->keybit); |
269 | 292 | ||
270 | kbd->dev.private = kbd; | 293 | input_dev->event = usb_kbd_event; |
271 | kbd->dev.event = usb_kbd_event; | 294 | input_dev->open = usb_kbd_open; |
272 | kbd->dev.open = usb_kbd_open; | 295 | input_dev->close = usb_kbd_close; |
273 | kbd->dev.close = usb_kbd_close; | ||
274 | 296 | ||
275 | usb_fill_int_urb(kbd->irq, dev, pipe, | 297 | usb_fill_int_urb(kbd->irq, dev, pipe, |
276 | kbd->new, (maxp > 8 ? 8 : maxp), | 298 | kbd->new, (maxp > 8 ? 8 : maxp), |
@@ -284,37 +306,22 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
284 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); | 306 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); |
285 | kbd->cr->wLength = cpu_to_le16(1); | 307 | kbd->cr->wLength = cpu_to_le16(1); |
286 | 308 | ||
287 | usb_make_path(dev, path, 64); | ||
288 | sprintf(kbd->phys, "%s/input0", path); | ||
289 | |||
290 | kbd->dev.name = kbd->name; | ||
291 | kbd->dev.phys = kbd->phys; | ||
292 | usb_to_input_id(dev, &kbd->dev.id); | ||
293 | kbd->dev.dev = &iface->dev; | ||
294 | |||
295 | if (dev->manufacturer) | ||
296 | strcat(kbd->name, dev->manufacturer); | ||
297 | if (dev->product) | ||
298 | sprintf(kbd->name, "%s %s", kbd->name, dev->product); | ||
299 | |||
300 | if (!strlen(kbd->name)) | ||
301 | sprintf(kbd->name, "USB HIDBP Keyboard %04x:%04x", | ||
302 | kbd->dev.id.vendor, kbd->dev.id.product); | ||
303 | |||
304 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), | 309 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), |
305 | (void *) kbd->cr, kbd->leds, 1, | 310 | (void *) kbd->cr, kbd->leds, 1, |
306 | usb_kbd_led, kbd); | 311 | usb_kbd_led, kbd); |
307 | kbd->led->setup_dma = kbd->cr_dma; | 312 | kbd->led->setup_dma = kbd->cr_dma; |
308 | kbd->led->transfer_dma = kbd->leds_dma; | 313 | kbd->led->transfer_dma = kbd->leds_dma; |
309 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 314 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
310 | | URB_NO_SETUP_DMA_MAP); | ||
311 | 315 | ||
312 | input_register_device(&kbd->dev); | 316 | input_register_device(kbd->dev); |
313 | |||
314 | printk(KERN_INFO "input: %s on %s\n", kbd->name, path); | ||
315 | 317 | ||
316 | usb_set_intfdata(iface, kbd); | 318 | usb_set_intfdata(iface, kbd); |
317 | return 0; | 319 | return 0; |
320 | |||
321 | fail2: usb_kbd_free_mem(dev, kbd); | ||
322 | fail1: input_free_device(input_dev); | ||
323 | kfree(kbd); | ||
324 | return -ENOMEM; | ||
318 | } | 325 | } |
319 | 326 | ||
320 | static void usb_kbd_disconnect(struct usb_interface *intf) | 327 | static void usb_kbd_disconnect(struct usb_interface *intf) |
@@ -324,7 +331,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf) | |||
324 | usb_set_intfdata(intf, NULL); | 331 | usb_set_intfdata(intf, NULL); |
325 | if (kbd) { | 332 | if (kbd) { |
326 | usb_kill_urb(kbd->irq); | 333 | usb_kill_urb(kbd->irq); |
327 | input_unregister_device(&kbd->dev); | 334 | input_unregister_device(kbd->dev); |
328 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); | 335 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); |
329 | kfree(kbd); | 336 | kfree(kbd); |
330 | } | 337 | } |
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 4104dec847fb..230f6b1b314a 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c | |||
@@ -50,7 +50,7 @@ struct usb_mouse { | |||
50 | char name[128]; | 50 | char name[128]; |
51 | char phys[64]; | 51 | char phys[64]; |
52 | struct usb_device *usbdev; | 52 | struct usb_device *usbdev; |
53 | struct input_dev dev; | 53 | struct input_dev *dev; |
54 | struct urb *irq; | 54 | struct urb *irq; |
55 | 55 | ||
56 | signed char *data; | 56 | signed char *data; |
@@ -61,7 +61,7 @@ static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs) | |||
61 | { | 61 | { |
62 | struct usb_mouse *mouse = urb->context; | 62 | struct usb_mouse *mouse = urb->context; |
63 | signed char *data = mouse->data; | 63 | signed char *data = mouse->data; |
64 | struct input_dev *dev = &mouse->dev; | 64 | struct input_dev *dev = mouse->dev; |
65 | int status; | 65 | int status; |
66 | 66 | ||
67 | switch (urb->status) { | 67 | switch (urb->status) { |
@@ -115,14 +115,14 @@ static void usb_mouse_close(struct input_dev *dev) | |||
115 | usb_kill_urb(mouse->irq); | 115 | usb_kill_urb(mouse->irq); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) | 118 | static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id) |
119 | { | 119 | { |
120 | struct usb_device * dev = interface_to_usbdev(intf); | 120 | struct usb_device *dev = interface_to_usbdev(intf); |
121 | struct usb_host_interface *interface; | 121 | struct usb_host_interface *interface; |
122 | struct usb_endpoint_descriptor *endpoint; | 122 | struct usb_endpoint_descriptor *endpoint; |
123 | struct usb_mouse *mouse; | 123 | struct usb_mouse *mouse; |
124 | struct input_dev *input_dev; | ||
124 | int pipe, maxp; | 125 | int pipe, maxp; |
125 | char path[64]; | ||
126 | 126 | ||
127 | interface = intf->cur_altsetting; | 127 | interface = intf->cur_altsetting; |
128 | 128 | ||
@@ -130,59 +130,62 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
130 | return -ENODEV; | 130 | return -ENODEV; |
131 | 131 | ||
132 | endpoint = &interface->endpoint[0].desc; | 132 | endpoint = &interface->endpoint[0].desc; |
133 | if (!(endpoint->bEndpointAddress & 0x80)) | 133 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
134 | return -ENODEV; | 134 | return -ENODEV; |
135 | if ((endpoint->bmAttributes & 3) != 3) | 135 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
136 | return -ENODEV; | 136 | return -ENODEV; |
137 | 137 | ||
138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
140 | 140 | ||
141 | if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) | 141 | mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); |
142 | return -ENOMEM; | 142 | input_dev = input_allocate_device(); |
143 | memset(mouse, 0, sizeof(struct usb_mouse)); | 143 | if (!mouse || !input_dev) |
144 | goto fail1; | ||
144 | 145 | ||
145 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); | 146 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); |
146 | if (!mouse->data) { | 147 | if (!mouse->data) |
147 | kfree(mouse); | 148 | goto fail1; |
148 | return -ENOMEM; | ||
149 | } | ||
150 | 149 | ||
151 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); | 150 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); |
152 | if (!mouse->irq) { | 151 | if (!mouse->irq) |
153 | usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | 152 | goto fail2; |
154 | kfree(mouse); | ||
155 | return -ENODEV; | ||
156 | } | ||
157 | 153 | ||
158 | mouse->usbdev = dev; | 154 | mouse->usbdev = dev; |
155 | mouse->dev = input_dev; | ||
156 | |||
157 | if (dev->manufacturer) | ||
158 | strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); | ||
159 | 159 | ||
160 | mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 160 | if (dev->product) { |
161 | mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 161 | if (dev->manufacturer) |
162 | mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 162 | strlcat(mouse->name, " ", sizeof(mouse->name)); |
163 | mouse->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 163 | strlcat(mouse->name, dev->product, sizeof(mouse->name)); |
164 | mouse->dev.relbit[0] |= BIT(REL_WHEEL); | 164 | } |
165 | 165 | ||
166 | mouse->dev.private = mouse; | 166 | if (!strlen(mouse->name)) |
167 | mouse->dev.open = usb_mouse_open; | 167 | snprintf(mouse->name, sizeof(mouse->name), |
168 | mouse->dev.close = usb_mouse_close; | 168 | "USB HIDBP Mouse %04x:%04x", |
169 | le16_to_cpu(dev->descriptor.idVendor), | ||
170 | le16_to_cpu(dev->descriptor.idProduct)); | ||
169 | 171 | ||
170 | usb_make_path(dev, path, 64); | 172 | usb_make_path(dev, mouse->phys, sizeof(mouse->phys)); |
171 | sprintf(mouse->phys, "%s/input0", path); | 173 | strlcat(mouse->phys, "/input0", sizeof(mouse->phys)); |
172 | 174 | ||
173 | mouse->dev.name = mouse->name; | 175 | input_dev->name = mouse->name; |
174 | mouse->dev.phys = mouse->phys; | 176 | input_dev->phys = mouse->phys; |
175 | usb_to_input_id(dev, &mouse->dev.id); | 177 | usb_to_input_id(dev, &input_dev->id); |
176 | mouse->dev.dev = &intf->dev; | 178 | input_dev->cdev.dev = &intf->dev; |
177 | 179 | ||
178 | if (dev->manufacturer) | 180 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
179 | strcat(mouse->name, dev->manufacturer); | 181 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
180 | if (dev->product) | 182 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
181 | sprintf(mouse->name, "%s %s", mouse->name, dev->product); | 183 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
184 | input_dev->relbit[0] |= BIT(REL_WHEEL); | ||
182 | 185 | ||
183 | if (!strlen(mouse->name)) | 186 | input_dev->private = mouse; |
184 | sprintf(mouse->name, "USB HIDBP Mouse %04x:%04x", | 187 | input_dev->open = usb_mouse_open; |
185 | mouse->dev.id.vendor, mouse->dev.id.product); | 188 | input_dev->close = usb_mouse_close; |
186 | 189 | ||
187 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, | 190 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, |
188 | (maxp > 8 ? 8 : maxp), | 191 | (maxp > 8 ? 8 : maxp), |
@@ -190,11 +193,15 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
190 | mouse->irq->transfer_dma = mouse->data_dma; | 193 | mouse->irq->transfer_dma = mouse->data_dma; |
191 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 194 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
192 | 195 | ||
193 | input_register_device(&mouse->dev); | 196 | input_register_device(mouse->dev); |
194 | printk(KERN_INFO "input: %s on %s\n", mouse->name, path); | ||
195 | 197 | ||
196 | usb_set_intfdata(intf, mouse); | 198 | usb_set_intfdata(intf, mouse); |
197 | return 0; | 199 | return 0; |
200 | |||
201 | fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | ||
202 | fail1: input_free_device(input_dev); | ||
203 | kfree(mouse); | ||
204 | return -ENOMEM; | ||
198 | } | 205 | } |
199 | 206 | ||
200 | static void usb_mouse_disconnect(struct usb_interface *intf) | 207 | static void usb_mouse_disconnect(struct usb_interface *intf) |
@@ -204,7 +211,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf) | |||
204 | usb_set_intfdata(intf, NULL); | 211 | usb_set_intfdata(intf, NULL); |
205 | if (mouse) { | 212 | if (mouse) { |
206 | usb_kill_urb(mouse->irq); | 213 | usb_kill_urb(mouse->irq); |
207 | input_unregister_device(&mouse->dev); | 214 | input_unregister_device(mouse->dev); |
208 | usb_free_urb(mouse->irq); | 215 | usb_free_urb(mouse->irq); |
209 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); | 216 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); |
210 | kfree(mouse); | 217 | kfree(mouse); |
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index 3b266af3048a..ea0f75773ae1 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c | |||
@@ -111,7 +111,7 @@ struct wacom_features { | |||
111 | struct wacom { | 111 | struct wacom { |
112 | signed char *data; | 112 | signed char *data; |
113 | dma_addr_t data_dma; | 113 | dma_addr_t data_dma; |
114 | struct input_dev dev; | 114 | struct input_dev *dev; |
115 | struct usb_device *usbdev; | 115 | struct usb_device *usbdev; |
116 | struct urb *irq; | 116 | struct urb *irq; |
117 | struct wacom_features *features; | 117 | struct wacom_features *features; |
@@ -135,7 +135,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
135 | { | 135 | { |
136 | struct wacom *wacom = urb->context; | 136 | struct wacom *wacom = urb->context; |
137 | unsigned char *data = wacom->data; | 137 | unsigned char *data = wacom->data; |
138 | struct input_dev *dev = &wacom->dev; | 138 | struct input_dev *dev = wacom->dev; |
139 | int prox, pressure; | 139 | int prox, pressure; |
140 | int retval; | 140 | int retval; |
141 | 141 | ||
@@ -225,7 +225,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
225 | { | 225 | { |
226 | struct wacom *wacom = urb->context; | 226 | struct wacom *wacom = urb->context; |
227 | unsigned char *data = wacom->data; | 227 | unsigned char *data = wacom->data; |
228 | struct input_dev *dev = &wacom->dev; | 228 | struct input_dev *dev = wacom->dev; |
229 | int retval; | 229 | int retval; |
230 | 230 | ||
231 | switch (urb->status) { | 231 | switch (urb->status) { |
@@ -275,7 +275,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs) | |||
275 | { | 275 | { |
276 | struct wacom *wacom = urb->context; | 276 | struct wacom *wacom = urb->context; |
277 | unsigned char *data = wacom->data; | 277 | unsigned char *data = wacom->data; |
278 | struct input_dev *dev = &wacom->dev; | 278 | struct input_dev *dev = wacom->dev; |
279 | int retval; | 279 | int retval; |
280 | 280 | ||
281 | switch (urb->status) { | 281 | switch (urb->status) { |
@@ -318,7 +318,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
318 | { | 318 | { |
319 | struct wacom *wacom = urb->context; | 319 | struct wacom *wacom = urb->context; |
320 | unsigned char *data = wacom->data; | 320 | unsigned char *data = wacom->data; |
321 | struct input_dev *dev = &wacom->dev; | 321 | struct input_dev *dev = wacom->dev; |
322 | int x, y; | 322 | int x, y; |
323 | int retval; | 323 | int retval; |
324 | 324 | ||
@@ -397,7 +397,7 @@ static int wacom_intuos_inout(struct urb *urb) | |||
397 | { | 397 | { |
398 | struct wacom *wacom = urb->context; | 398 | struct wacom *wacom = urb->context; |
399 | unsigned char *data = wacom->data; | 399 | unsigned char *data = wacom->data; |
400 | struct input_dev *dev = &wacom->dev; | 400 | struct input_dev *dev = wacom->dev; |
401 | int idx; | 401 | int idx; |
402 | 402 | ||
403 | /* tool number */ | 403 | /* tool number */ |
@@ -479,7 +479,7 @@ static void wacom_intuos_general(struct urb *urb) | |||
479 | { | 479 | { |
480 | struct wacom *wacom = urb->context; | 480 | struct wacom *wacom = urb->context; |
481 | unsigned char *data = wacom->data; | 481 | unsigned char *data = wacom->data; |
482 | struct input_dev *dev = &wacom->dev; | 482 | struct input_dev *dev = wacom->dev; |
483 | unsigned int t; | 483 | unsigned int t; |
484 | 484 | ||
485 | /* general pen packet */ | 485 | /* general pen packet */ |
@@ -509,7 +509,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
509 | { | 509 | { |
510 | struct wacom *wacom = urb->context; | 510 | struct wacom *wacom = urb->context; |
511 | unsigned char *data = wacom->data; | 511 | unsigned char *data = wacom->data; |
512 | struct input_dev *dev = &wacom->dev; | 512 | struct input_dev *dev = wacom->dev; |
513 | unsigned int t; | 513 | unsigned int t; |
514 | int idx; | 514 | int idx; |
515 | int retval; | 515 | int retval; |
@@ -738,95 +738,83 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
738 | { | 738 | { |
739 | struct usb_device *dev = interface_to_usbdev(intf); | 739 | struct usb_device *dev = interface_to_usbdev(intf); |
740 | struct usb_endpoint_descriptor *endpoint; | 740 | struct usb_endpoint_descriptor *endpoint; |
741 | char rep_data[2] = {0x02, 0x02}; | ||
742 | struct wacom *wacom; | 741 | struct wacom *wacom; |
743 | char path[64]; | 742 | struct input_dev *input_dev; |
743 | char rep_data[2] = {0x02, 0x02}; | ||
744 | 744 | ||
745 | if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) | 745 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
746 | return -ENOMEM; | 746 | input_dev = input_allocate_device(); |
747 | memset(wacom, 0, sizeof(struct wacom)); | 747 | if (!wacom || !input_dev) |
748 | goto fail1; | ||
748 | 749 | ||
749 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); | 750 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); |
750 | if (!wacom->data) { | 751 | if (!wacom->data) |
751 | kfree(wacom); | 752 | goto fail1; |
752 | return -ENOMEM; | ||
753 | } | ||
754 | 753 | ||
755 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); | 754 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); |
756 | if (!wacom->irq) { | 755 | if (!wacom->irq) |
757 | usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | 756 | goto fail2; |
758 | kfree(wacom); | 757 | |
759 | return -ENOMEM; | 758 | wacom->usbdev = dev; |
760 | } | 759 | wacom->dev = input_dev; |
760 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | ||
761 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | ||
761 | 762 | ||
762 | wacom->features = wacom_features + (id - wacom_ids); | 763 | wacom->features = wacom_features + (id - wacom_ids); |
764 | if (wacom->features->pktlen > 10) | ||
765 | BUG(); | ||
766 | |||
767 | input_dev->name = wacom->features->name; | ||
768 | usb_to_input_id(dev, &input_dev->id); | ||
763 | 769 | ||
764 | wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | 770 | input_dev->cdev.dev = &intf->dev; |
765 | wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 771 | input_dev->private = wacom; |
766 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | 772 | input_dev->open = wacom_open; |
773 | input_dev->close = wacom_close; | ||
774 | |||
775 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | ||
776 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | ||
777 | input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0); | ||
778 | input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0); | ||
779 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0); | ||
767 | 780 | ||
768 | switch (wacom->features->type) { | 781 | switch (wacom->features->type) { |
769 | case GRAPHIRE: | 782 | case GRAPHIRE: |
770 | wacom->dev.evbit[0] |= BIT(EV_REL); | 783 | input_dev->evbit[0] |= BIT(EV_REL); |
771 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 784 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
772 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); | 785 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
773 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 786 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); |
774 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); | 787 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
775 | break; | 788 | break; |
776 | 789 | ||
777 | case INTUOS3: | 790 | case INTUOS3: |
778 | case CINTIQ: | 791 | case CINTIQ: |
779 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 792 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); |
780 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | 793 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); |
781 | wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); | 794 | input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); |
795 | input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); | ||
782 | /* fall through */ | 796 | /* fall through */ |
783 | 797 | ||
784 | case INTUOS: | 798 | case INTUOS: |
785 | wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); | 799 | input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); |
786 | wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); | 800 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
787 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 801 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
788 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 802 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
789 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) | 803 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) |
790 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); | 804 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); |
791 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); | 805 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
806 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | ||
807 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | ||
808 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); | ||
809 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); | ||
810 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); | ||
792 | break; | 811 | break; |
793 | 812 | ||
794 | case PL: | 813 | case PL: |
795 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); | 814 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); |
796 | break; | 815 | break; |
797 | } | 816 | } |
798 | 817 | ||
799 | wacom->dev.absmax[ABS_X] = wacom->features->x_max; | ||
800 | wacom->dev.absmax[ABS_Y] = wacom->features->y_max; | ||
801 | wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max; | ||
802 | wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max; | ||
803 | wacom->dev.absmax[ABS_TILT_X] = 127; | ||
804 | wacom->dev.absmax[ABS_TILT_Y] = 127; | ||
805 | wacom->dev.absmax[ABS_WHEEL] = 1023; | ||
806 | |||
807 | wacom->dev.absmax[ABS_RX] = 4097; | ||
808 | wacom->dev.absmax[ABS_RY] = 4097; | ||
809 | wacom->dev.absmin[ABS_RZ] = -900; | ||
810 | wacom->dev.absmax[ABS_RZ] = 899; | ||
811 | wacom->dev.absmin[ABS_THROTTLE] = -1023; | ||
812 | wacom->dev.absmax[ABS_THROTTLE] = 1023; | ||
813 | |||
814 | wacom->dev.absfuzz[ABS_X] = 4; | ||
815 | wacom->dev.absfuzz[ABS_Y] = 4; | ||
816 | |||
817 | wacom->dev.private = wacom; | ||
818 | wacom->dev.open = wacom_open; | ||
819 | wacom->dev.close = wacom_close; | ||
820 | |||
821 | usb_make_path(dev, path, 64); | ||
822 | sprintf(wacom->phys, "%s/input0", path); | ||
823 | |||
824 | wacom->dev.name = wacom->features->name; | ||
825 | wacom->dev.phys = wacom->phys; | ||
826 | usb_to_input_id(dev, &wacom->dev.id); | ||
827 | wacom->dev.dev = &intf->dev; | ||
828 | wacom->usbdev = dev; | ||
829 | |||
830 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 818 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
831 | 819 | ||
832 | if (wacom->features->pktlen > 10) | 820 | if (wacom->features->pktlen > 10) |
@@ -839,18 +827,20 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
839 | wacom->irq->transfer_dma = wacom->data_dma; | 827 | wacom->irq->transfer_dma = wacom->data_dma; |
840 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 828 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
841 | 829 | ||
842 | input_register_device(&wacom->dev); | 830 | input_register_device(wacom->dev); |
843 | 831 | ||
844 | /* ask the tablet to report tablet data */ | 832 | /* ask the tablet to report tablet data */ |
845 | usb_set_report(intf, 3, 2, rep_data, 2); | 833 | usb_set_report(intf, 3, 2, rep_data, 2); |
846 | /* repeat once (not sure why the first call often fails) */ | 834 | /* repeat once (not sure why the first call often fails) */ |
847 | usb_set_report(intf, 3, 2, rep_data, 2); | 835 | usb_set_report(intf, 3, 2, rep_data, 2); |
848 | 836 | ||
849 | printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path); | ||
850 | |||
851 | usb_set_intfdata(intf, wacom); | 837 | usb_set_intfdata(intf, wacom); |
852 | |||
853 | return 0; | 838 | return 0; |
839 | |||
840 | fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | ||
841 | fail1: input_free_device(input_dev); | ||
842 | kfree(wacom); | ||
843 | return -ENOMEM; | ||
854 | } | 844 | } |
855 | 845 | ||
856 | static void wacom_disconnect(struct usb_interface *intf) | 846 | static void wacom_disconnect(struct usb_interface *intf) |
@@ -860,7 +850,7 @@ static void wacom_disconnect(struct usb_interface *intf) | |||
860 | usb_set_intfdata(intf, NULL); | 850 | usb_set_intfdata(intf, NULL); |
861 | if (wacom) { | 851 | if (wacom) { |
862 | usb_kill_urb(wacom->irq); | 852 | usb_kill_urb(wacom->irq); |
863 | input_unregister_device(&wacom->dev); | 853 | input_unregister_device(wacom->dev); |
864 | usb_free_urb(wacom->irq); | 854 | usb_free_urb(wacom->irq); |
865 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); | 855 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); |
866 | kfree(wacom); | 856 | kfree(wacom); |
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index 18125e0bffa2..43112f040b6d 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
@@ -103,7 +103,7 @@ static struct usb_device_id xpad_table [] = { | |||
103 | MODULE_DEVICE_TABLE (usb, xpad_table); | 103 | MODULE_DEVICE_TABLE (usb, xpad_table); |
104 | 104 | ||
105 | struct usb_xpad { | 105 | struct usb_xpad { |
106 | struct input_dev dev; /* input device interface */ | 106 | struct input_dev *dev; /* input device interface */ |
107 | struct usb_device *udev; /* usb device */ | 107 | struct usb_device *udev; /* usb device */ |
108 | 108 | ||
109 | struct urb *irq_in; /* urb for interrupt in report */ | 109 | struct urb *irq_in; /* urb for interrupt in report */ |
@@ -125,7 +125,7 @@ struct usb_xpad { | |||
125 | 125 | ||
126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) | 126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) |
127 | { | 127 | { |
128 | struct input_dev *dev = &xpad->dev; | 128 | struct input_dev *dev = xpad->dev; |
129 | 129 | ||
130 | input_regs(dev, regs); | 130 | input_regs(dev, regs); |
131 | 131 | ||
@@ -214,9 +214,9 @@ static void xpad_close (struct input_dev *dev) | |||
214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) | 214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) |
215 | { | 215 | { |
216 | struct usb_device *udev = interface_to_usbdev (intf); | 216 | struct usb_device *udev = interface_to_usbdev (intf); |
217 | struct usb_xpad *xpad = NULL; | 217 | struct usb_xpad *xpad; |
218 | struct input_dev *input_dev; | ||
218 | struct usb_endpoint_descriptor *ep_irq_in; | 219 | struct usb_endpoint_descriptor *ep_irq_in; |
219 | char path[64]; | ||
220 | int i; | 220 | int i; |
221 | 221 | ||
222 | for (i = 0; xpad_device[i].idVendor; i++) { | 222 | for (i = 0; xpad_device[i].idVendor; i++) { |
@@ -225,89 +225,80 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { | 228 | xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); |
229 | err("cannot allocate memory for new pad"); | 229 | input_dev = input_allocate_device(); |
230 | return -ENOMEM; | 230 | if (!xpad || !input_dev) |
231 | } | 231 | goto fail1; |
232 | memset(xpad, 0, sizeof(struct usb_xpad)); | ||
233 | 232 | ||
234 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, | 233 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, |
235 | SLAB_ATOMIC, &xpad->idata_dma); | 234 | SLAB_ATOMIC, &xpad->idata_dma); |
236 | if (!xpad->idata) { | 235 | if (!xpad->idata) |
237 | kfree(xpad); | 236 | goto fail1; |
238 | return -ENOMEM; | ||
239 | } | ||
240 | 237 | ||
241 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); | 238 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); |
242 | if (!xpad->irq_in) { | 239 | if (!xpad->irq_in) |
243 | err("cannot allocate memory for new pad irq urb"); | 240 | goto fail2; |
244 | usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
245 | kfree(xpad); | ||
246 | return -ENOMEM; | ||
247 | } | ||
248 | |||
249 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; | ||
250 | |||
251 | usb_fill_int_urb(xpad->irq_in, udev, | ||
252 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
253 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
254 | xpad, ep_irq_in->bInterval); | ||
255 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
256 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
257 | 241 | ||
258 | xpad->udev = udev; | 242 | xpad->udev = udev; |
243 | xpad->dev = input_dev; | ||
244 | usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); | ||
245 | strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); | ||
259 | 246 | ||
260 | usb_to_input_id(udev, &xpad->dev.id); | 247 | input_dev->name = xpad_device[i].name; |
261 | xpad->dev.dev = &intf->dev; | 248 | input_dev->phys = xpad->phys; |
262 | xpad->dev.private = xpad; | 249 | usb_to_input_id(udev, &input_dev->id); |
263 | xpad->dev.name = xpad_device[i].name; | 250 | input_dev->cdev.dev = &intf->dev; |
264 | xpad->dev.phys = xpad->phys; | 251 | input_dev->private = xpad; |
265 | xpad->dev.open = xpad_open; | 252 | input_dev->open = xpad_open; |
266 | xpad->dev.close = xpad_close; | 253 | input_dev->close = xpad_close; |
267 | |||
268 | usb_make_path(udev, path, 64); | ||
269 | snprintf(xpad->phys, 64, "%s/input0", path); | ||
270 | 254 | ||
271 | xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 255 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
272 | 256 | ||
273 | for (i = 0; xpad_btn[i] >= 0; i++) | 257 | for (i = 0; xpad_btn[i] >= 0; i++) |
274 | set_bit(xpad_btn[i], xpad->dev.keybit); | 258 | set_bit(xpad_btn[i], input_dev->keybit); |
275 | 259 | ||
276 | for (i = 0; xpad_abs[i] >= 0; i++) { | 260 | for (i = 0; xpad_abs[i] >= 0; i++) { |
277 | 261 | ||
278 | signed short t = xpad_abs[i]; | 262 | signed short t = xpad_abs[i]; |
279 | 263 | ||
280 | set_bit(t, xpad->dev.absbit); | 264 | set_bit(t, input_dev->absbit); |
281 | 265 | ||
282 | switch (t) { | 266 | switch (t) { |
283 | case ABS_X: | 267 | case ABS_X: |
284 | case ABS_Y: | 268 | case ABS_Y: |
285 | case ABS_RX: | 269 | case ABS_RX: |
286 | case ABS_RY: /* the two sticks */ | 270 | case ABS_RY: /* the two sticks */ |
287 | xpad->dev.absmax[t] = 32767; | 271 | input_set_abs_params(input_dev, t, -32768, 32767, 16, 128); |
288 | xpad->dev.absmin[t] = -32768; | ||
289 | xpad->dev.absflat[t] = 128; | ||
290 | xpad->dev.absfuzz[t] = 16; | ||
291 | break; | 272 | break; |
292 | case ABS_Z: | 273 | case ABS_Z: |
293 | case ABS_RZ: /* the triggers */ | 274 | case ABS_RZ: /* the triggers */ |
294 | xpad->dev.absmax[t] = 255; | 275 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
295 | xpad->dev.absmin[t] = 0; | ||
296 | break; | 276 | break; |
297 | case ABS_HAT0X: | 277 | case ABS_HAT0X: |
298 | case ABS_HAT0Y: /* the d-pad */ | 278 | case ABS_HAT0Y: /* the d-pad */ |
299 | xpad->dev.absmax[t] = 1; | 279 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
300 | xpad->dev.absmin[t] = -1; | ||
301 | break; | 280 | break; |
302 | } | 281 | } |
303 | } | 282 | } |
304 | 283 | ||
305 | input_register_device(&xpad->dev); | 284 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; |
285 | usb_fill_int_urb(xpad->irq_in, udev, | ||
286 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
287 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
288 | xpad, ep_irq_in->bInterval); | ||
289 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
290 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
306 | 291 | ||
307 | printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); | 292 | input_register_device(xpad->dev); |
308 | 293 | ||
309 | usb_set_intfdata(intf, xpad); | 294 | usb_set_intfdata(intf, xpad); |
310 | return 0; | 295 | return 0; |
296 | |||
297 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
298 | fail1: input_free_device(input_dev); | ||
299 | kfree(xpad); | ||
300 | return -ENOMEM; | ||
301 | |||
311 | } | 302 | } |
312 | 303 | ||
313 | static void xpad_disconnect(struct usb_interface *intf) | 304 | static void xpad_disconnect(struct usb_interface *intf) |
@@ -317,7 +308,7 @@ static void xpad_disconnect(struct usb_interface *intf) | |||
317 | usb_set_intfdata(intf, NULL); | 308 | usb_set_intfdata(intf, NULL); |
318 | if (xpad) { | 309 | if (xpad) { |
319 | usb_kill_urb(xpad->irq_in); | 310 | usb_kill_urb(xpad->irq_in); |
320 | input_unregister_device(&xpad->dev); | 311 | input_unregister_device(xpad->dev); |
321 | usb_free_urb(xpad->irq_in); | 312 | usb_free_urb(xpad->irq_in); |
322 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | 313 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); |
323 | kfree(xpad); | 314 | kfree(xpad); |
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index 58a176ef96a5..f526aebea502 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/rwsem.h> | 55 | #include <linux/rwsem.h> |
56 | #include <linux/usb.h> | 56 | #include <linux/usb.h> |
57 | #include <linux/usb_input.h> | ||
57 | 58 | ||
58 | #include "map_to_7segment.h" | 59 | #include "map_to_7segment.h" |
59 | #include "yealink.h" | 60 | #include "yealink.h" |
@@ -101,12 +102,12 @@ static const struct lcd_segment_map { | |||
101 | }; | 102 | }; |
102 | 103 | ||
103 | struct yealink_dev { | 104 | struct yealink_dev { |
104 | struct input_dev idev; /* input device */ | 105 | struct input_dev *idev; /* input device */ |
105 | struct usb_device *udev; /* usb device */ | 106 | struct usb_device *udev; /* usb device */ |
106 | 107 | ||
107 | /* irq input channel */ | 108 | /* irq input channel */ |
108 | struct yld_ctl_packet *irq_data; | 109 | struct yld_ctl_packet *irq_data; |
109 | dma_addr_t irq_dma; | 110 | dma_addr_t irq_dma; |
110 | struct urb *urb_irq; | 111 | struct urb *urb_irq; |
111 | 112 | ||
112 | /* control output channel */ | 113 | /* control output channel */ |
@@ -237,7 +238,7 @@ static int map_p1k_to_key(int scancode) | |||
237 | */ | 238 | */ |
238 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) | 239 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) |
239 | { | 240 | { |
240 | struct input_dev *idev = &yld->idev; | 241 | struct input_dev *idev = yld->idev; |
241 | 242 | ||
242 | input_regs(idev, regs); | 243 | input_regs(idev, regs); |
243 | if (yld->key_code >= 0) { | 244 | if (yld->key_code >= 0) { |
@@ -809,8 +810,12 @@ static int usb_cleanup(struct yealink_dev *yld, int err) | |||
809 | } | 810 | } |
810 | if (yld->urb_ctl) | 811 | if (yld->urb_ctl) |
811 | usb_free_urb(yld->urb_ctl); | 812 | usb_free_urb(yld->urb_ctl); |
812 | if (yld->idev.dev) | 813 | if (yld->idev) { |
813 | input_unregister_device(&yld->idev); | 814 | if (err) |
815 | input_free_device(yld->idev); | ||
816 | else | ||
817 | input_unregister_device(yld->idev); | ||
818 | } | ||
814 | if (yld->ctl_req) | 819 | if (yld->ctl_req) |
815 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), | 820 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), |
816 | yld->ctl_req, yld->ctl_req_dma); | 821 | yld->ctl_req, yld->ctl_req_dma); |
@@ -857,7 +862,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
857 | struct usb_host_interface *interface; | 862 | struct usb_host_interface *interface; |
858 | struct usb_endpoint_descriptor *endpoint; | 863 | struct usb_endpoint_descriptor *endpoint; |
859 | struct yealink_dev *yld; | 864 | struct yealink_dev *yld; |
860 | char path[64]; | 865 | struct input_dev *input_dev; |
861 | int ret, pipe, i; | 866 | int ret, pipe, i; |
862 | 867 | ||
863 | i = usb_match(udev); | 868 | i = usb_match(udev); |
@@ -866,17 +871,21 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
866 | 871 | ||
867 | interface = intf->cur_altsetting; | 872 | interface = intf->cur_altsetting; |
868 | endpoint = &interface->endpoint[0].desc; | 873 | endpoint = &interface->endpoint[0].desc; |
869 | if (!(endpoint->bEndpointAddress & 0x80)) | 874 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
870 | return -EIO; | 875 | return -EIO; |
871 | if ((endpoint->bmAttributes & 3) != 3) | 876 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
872 | return -EIO; | 877 | return -EIO; |
873 | 878 | ||
874 | if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) | 879 | yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); |
880 | if (!yld) | ||
875 | return -ENOMEM; | 881 | return -ENOMEM; |
876 | 882 | ||
877 | memset(yld, 0, sizeof(*yld)); | ||
878 | yld->udev = udev; | 883 | yld->udev = udev; |
879 | 884 | ||
885 | yld->idev = input_dev = input_allocate_device(); | ||
886 | if (!input_dev) | ||
887 | return usb_cleanup(yld, -ENOMEM); | ||
888 | |||
880 | /* allocate usb buffers */ | 889 | /* allocate usb buffers */ |
881 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, | 890 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, |
882 | SLAB_ATOMIC, &yld->irq_dma); | 891 | SLAB_ATOMIC, &yld->irq_dma); |
@@ -935,42 +944,37 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
935 | yld->urb_ctl->dev = udev; | 944 | yld->urb_ctl->dev = udev; |
936 | 945 | ||
937 | /* find out the physical bus location */ | 946 | /* find out the physical bus location */ |
938 | if (usb_make_path(udev, path, sizeof(path)) > 0) | 947 | usb_make_path(udev, yld->phys, sizeof(yld->phys)); |
939 | snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); | 948 | strlcat(yld->phys, "/input0", sizeof(yld->phys)); |
940 | 949 | ||
941 | /* register settings for the input device */ | 950 | /* register settings for the input device */ |
942 | init_input_dev(&yld->idev); | 951 | input_dev->name = yld_device[i].name; |
943 | yld->idev.private = yld; | 952 | input_dev->phys = yld->phys; |
944 | yld->idev.id.bustype = BUS_USB; | 953 | usb_to_input_id(udev, &input_dev->id); |
945 | yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | 954 | input_dev->cdev.dev = &intf->dev; |
946 | yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); | 955 | |
947 | yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); | 956 | input_dev->private = yld; |
948 | yld->idev.dev = &intf->dev; | 957 | input_dev->open = input_open; |
949 | yld->idev.name = yld_device[i].name; | 958 | input_dev->close = input_close; |
950 | yld->idev.phys = yld->phys; | 959 | /* input_dev->event = input_ev; TODO */ |
951 | /* yld->idev.event = input_ev; TODO */ | ||
952 | yld->idev.open = input_open; | ||
953 | yld->idev.close = input_close; | ||
954 | 960 | ||
955 | /* register available key events */ | 961 | /* register available key events */ |
956 | yld->idev.evbit[0] = BIT(EV_KEY); | 962 | input_dev->evbit[0] = BIT(EV_KEY); |
957 | for (i = 0; i < 256; i++) { | 963 | for (i = 0; i < 256; i++) { |
958 | int k = map_p1k_to_key(i); | 964 | int k = map_p1k_to_key(i); |
959 | if (k >= 0) { | 965 | if (k >= 0) { |
960 | set_bit(k & 0xff, yld->idev.keybit); | 966 | set_bit(k & 0xff, input_dev->keybit); |
961 | if (k >> 8) | 967 | if (k >> 8) |
962 | set_bit(k >> 8, yld->idev.keybit); | 968 | set_bit(k >> 8, input_dev->keybit); |
963 | } | 969 | } |
964 | } | 970 | } |
965 | 971 | ||
966 | printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); | 972 | input_register_device(yld->idev); |
967 | |||
968 | input_register_device(&yld->idev); | ||
969 | 973 | ||
970 | usb_set_intfdata(intf, yld); | 974 | usb_set_intfdata(intf, yld); |
971 | 975 | ||
972 | /* clear visible elements */ | 976 | /* clear visible elements */ |
973 | for (i=0; i<ARRAY_SIZE(lcdMap); i++) | 977 | for (i = 0; i < ARRAY_SIZE(lcdMap); i++) |
974 | setChar(yld, i, ' '); | 978 | setChar(yld, i, ' '); |
975 | 979 | ||
976 | /* display driver version on LCD line 3 */ | 980 | /* display driver version on LCD line 3 */ |