diff options
Diffstat (limited to 'drivers/usb/input/acecad.c')
-rw-r--r-- | drivers/usb/input/acecad.c | 76 |
1 files changed, 39 insertions, 37 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); |