Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * $Id: usbkbd.c,v 1.27 2001/12/27 10:37:41 vojtech Exp $ |
| 3 | * |
| 4 | * Copyright (c) 1999-2001 Vojtech Pavlik |
| 5 | * |
| 6 | * USB HIDBP Keyboard support |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 12 | * the Free Software Foundation; either version 2 of the License, or |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * (at your option) any later version. |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 14 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 19 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 23 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | * Should you need to contact me, the author, you can do so either by |
| 25 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
| 26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
| 27 | */ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/slab.h> |
| 31 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/init.h> |
David Brownell | ae0dadc | 2006-06-13 10:04:34 -0700 | [diff] [blame] | 33 | #include <linux/usb/input.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * Version Information |
| 37 | */ |
| 38 | #define DRIVER_VERSION "" |
| 39 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" |
| 40 | #define DRIVER_DESC "USB HID Boot Protocol keyboard driver" |
| 41 | #define DRIVER_LICENSE "GPL" |
| 42 | |
| 43 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 44 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 45 | MODULE_LICENSE(DRIVER_LICENSE); |
| 46 | |
| 47 | static unsigned char usb_kbd_keycode[256] = { |
| 48 | 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, |
| 49 | 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, |
| 50 | 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26, |
| 51 | 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, |
| 52 | 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106, |
| 53 | 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, |
| 54 | 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190, |
| 55 | 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113, |
| 56 | 115,114, 0, 0, 0,121, 0, 89, 93,124, 92, 94, 95, 0, 0, 0, |
| 57 | 122,123, 90, 91, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 58 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 59 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 60 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 61 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 62 | 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113, |
| 63 | 150,158,159,128,136,177,178,176,142,152,173,140 |
| 64 | }; |
| 65 | |
| 66 | struct usb_kbd { |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 67 | struct input_dev *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | struct usb_device *usbdev; |
| 69 | unsigned char old[8]; |
| 70 | struct urb *irq, *led; |
| 71 | unsigned char newleds; |
| 72 | char name[128]; |
| 73 | char phys[64]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | unsigned char *new; |
| 76 | struct usb_ctrlrequest *cr; |
| 77 | unsigned char *leds; |
| 78 | dma_addr_t cr_dma; |
| 79 | dma_addr_t new_dma; |
| 80 | dma_addr_t leds_dma; |
| 81 | }; |
| 82 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 83 | static void usb_kbd_irq(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
| 85 | struct usb_kbd *kbd = urb->context; |
| 86 | int i; |
| 87 | |
| 88 | switch (urb->status) { |
| 89 | case 0: /* success */ |
| 90 | break; |
| 91 | case -ECONNRESET: /* unlink */ |
| 92 | case -ENOENT: |
| 93 | case -ESHUTDOWN: |
| 94 | return; |
| 95 | /* -EPIPE: should clear the halt */ |
| 96 | default: /* error */ |
| 97 | goto resubmit; |
| 98 | } |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | for (i = 0; i < 8; i++) |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 101 | input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | for (i = 2; i < 8; i++) { |
| 104 | |
| 105 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { |
| 106 | if (usb_kbd_keycode[kbd->old[i]]) |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 107 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | else |
| 109 | info("Unknown key (scancode %#x) released.", kbd->old[i]); |
| 110 | } |
| 111 | |
| 112 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { |
| 113 | if (usb_kbd_keycode[kbd->new[i]]) |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 114 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | else |
| 116 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); |
| 117 | } |
| 118 | } |
| 119 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 120 | input_sync(kbd->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
| 122 | memcpy(kbd->old, kbd->new, 8); |
| 123 | |
| 124 | resubmit: |
| 125 | i = usb_submit_urb (urb, SLAB_ATOMIC); |
| 126 | if (i) |
| 127 | err ("can't resubmit intr, %s-%s/input0, status %d", |
| 128 | kbd->usbdev->bus->bus_name, |
| 129 | kbd->usbdev->devpath, i); |
| 130 | } |
| 131 | |
Adrian Bunk | be5e3383 | 2005-04-22 15:07:00 -0700 | [diff] [blame] | 132 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, |
| 133 | unsigned int code, int value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { |
| 135 | struct usb_kbd *kbd = dev->private; |
| 136 | |
| 137 | if (type != EV_LED) |
| 138 | return -1; |
| 139 | |
| 140 | |
| 141 | kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | |
| 142 | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | |
| 143 | (!!test_bit(LED_NUML, dev->led)); |
| 144 | |
| 145 | if (kbd->led->status == -EINPROGRESS) |
| 146 | return 0; |
| 147 | |
| 148 | if (*(kbd->leds) == kbd->newleds) |
| 149 | return 0; |
| 150 | |
| 151 | *(kbd->leds) = kbd->newleds; |
| 152 | kbd->led->dev = kbd->usbdev; |
| 153 | if (usb_submit_urb(kbd->led, GFP_ATOMIC)) |
| 154 | err("usb_submit_urb(leds) failed"); |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 159 | static void usb_kbd_led(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | { |
| 161 | struct usb_kbd *kbd = urb->context; |
| 162 | |
| 163 | if (urb->status) |
| 164 | warn("led urb status %d received", urb->status); |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | if (*(kbd->leds) == kbd->newleds) |
| 167 | return; |
| 168 | |
| 169 | *(kbd->leds) = kbd->newleds; |
| 170 | kbd->led->dev = kbd->usbdev; |
| 171 | if (usb_submit_urb(kbd->led, GFP_ATOMIC)) |
| 172 | err("usb_submit_urb(leds) failed"); |
| 173 | } |
| 174 | |
| 175 | static int usb_kbd_open(struct input_dev *dev) |
| 176 | { |
| 177 | struct usb_kbd *kbd = dev->private; |
| 178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | kbd->irq->dev = kbd->usbdev; |
Dmitry Torokhov | 65cde54 | 2005-05-29 02:29:38 -0500 | [diff] [blame] | 180 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | static void usb_kbd_close(struct input_dev *dev) |
| 187 | { |
| 188 | struct usb_kbd *kbd = dev->private; |
| 189 | |
Dmitry Torokhov | 65cde54 | 2005-05-29 02:29:38 -0500 | [diff] [blame] | 190 | usb_kill_urb(kbd->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) |
| 194 | { |
| 195 | if (!(kbd->irq = usb_alloc_urb(0, GFP_KERNEL))) |
| 196 | return -1; |
| 197 | if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) |
| 198 | return -1; |
| 199 | if (!(kbd->new = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbd->new_dma))) |
| 200 | return -1; |
| 201 | if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), SLAB_ATOMIC, &kbd->cr_dma))) |
| 202 | return -1; |
| 203 | if (!(kbd->leds = usb_buffer_alloc(dev, 1, SLAB_ATOMIC, &kbd->leds_dma))) |
| 204 | return -1; |
| 205 | |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) |
| 210 | { |
| 211 | if (kbd->irq) |
| 212 | usb_free_urb(kbd->irq); |
| 213 | if (kbd->led) |
| 214 | usb_free_urb(kbd->led); |
| 215 | if (kbd->new) |
| 216 | usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); |
| 217 | if (kbd->cr) |
| 218 | usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma); |
| 219 | if (kbd->leds) |
| 220 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); |
| 221 | } |
| 222 | |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 223 | static int usb_kbd_probe(struct usb_interface *iface, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | const struct usb_device_id *id) |
| 225 | { |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 226 | struct usb_device *dev = interface_to_usbdev(iface); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | struct usb_host_interface *interface; |
| 228 | struct usb_endpoint_descriptor *endpoint; |
| 229 | struct usb_kbd *kbd; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 230 | struct input_dev *input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | int i, pipe, maxp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
| 233 | interface = iface->cur_altsetting; |
| 234 | |
| 235 | if (interface->desc.bNumEndpoints != 1) |
| 236 | return -ENODEV; |
| 237 | |
| 238 | endpoint = &interface->endpoint[0].desc; |
Luiz Fernando N. Capitulino | a20c314 | 2006-10-26 13:02:59 -0300 | [diff] [blame^] | 239 | if (!usb_endpoint_is_int_in(endpoint)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | return -ENODEV; |
| 241 | |
| 242 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
| 243 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
| 244 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 245 | kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); |
| 246 | input_dev = input_allocate_device(); |
| 247 | if (!kbd || !input_dev) |
| 248 | goto fail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 250 | if (usb_kbd_alloc_mem(dev, kbd)) |
| 251 | goto fail2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | |
| 253 | kbd->usbdev = dev; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 254 | kbd->dev = input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 256 | if (dev->manufacturer) |
| 257 | strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); |
| 258 | |
| 259 | if (dev->product) { |
| 260 | if (dev->manufacturer) |
| 261 | strlcat(kbd->name, " ", sizeof(kbd->name)); |
| 262 | strlcat(kbd->name, dev->product, sizeof(kbd->name)); |
| 263 | } |
| 264 | |
| 265 | if (!strlen(kbd->name)) |
| 266 | snprintf(kbd->name, sizeof(kbd->name), |
| 267 | "USB HIDBP Keyboard %04x:%04x", |
| 268 | le16_to_cpu(dev->descriptor.idVendor), |
| 269 | le16_to_cpu(dev->descriptor.idProduct)); |
| 270 | |
| 271 | usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); |
| 272 | strlcpy(kbd->phys, "/input0", sizeof(kbd->phys)); |
| 273 | |
| 274 | input_dev->name = kbd->name; |
| 275 | input_dev->phys = kbd->phys; |
| 276 | usb_to_input_id(dev, &input_dev->id); |
| 277 | input_dev->cdev.dev = &iface->dev; |
| 278 | input_dev->private = kbd; |
| 279 | |
| 280 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); |
| 281 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
| 283 | for (i = 0; i < 255; i++) |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 284 | set_bit(usb_kbd_keycode[i], input_dev->keybit); |
| 285 | clear_bit(0, input_dev->keybit); |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 286 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 287 | input_dev->event = usb_kbd_event; |
| 288 | input_dev->open = usb_kbd_open; |
| 289 | input_dev->close = usb_kbd_close; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
| 291 | usb_fill_int_urb(kbd->irq, dev, pipe, |
| 292 | kbd->new, (maxp > 8 ? 8 : maxp), |
| 293 | usb_kbd_irq, kbd, endpoint->bInterval); |
| 294 | kbd->irq->transfer_dma = kbd->new_dma; |
| 295 | kbd->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 296 | |
| 297 | kbd->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE; |
| 298 | kbd->cr->bRequest = 0x09; |
| 299 | kbd->cr->wValue = cpu_to_le16(0x200); |
| 300 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); |
| 301 | kbd->cr->wLength = cpu_to_le16(1); |
| 302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), |
| 304 | (void *) kbd->cr, kbd->leds, 1, |
| 305 | usb_kbd_led, kbd); |
| 306 | kbd->led->setup_dma = kbd->cr_dma; |
| 307 | kbd->led->transfer_dma = kbd->leds_dma; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 308 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 310 | input_register_device(kbd->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
| 312 | usb_set_intfdata(iface, kbd); |
| 313 | return 0; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 314 | |
| 315 | fail2: usb_kbd_free_mem(dev, kbd); |
| 316 | fail1: input_free_device(input_dev); |
| 317 | kfree(kbd); |
| 318 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | static void usb_kbd_disconnect(struct usb_interface *intf) |
| 322 | { |
| 323 | struct usb_kbd *kbd = usb_get_intfdata (intf); |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | usb_set_intfdata(intf, NULL); |
| 326 | if (kbd) { |
| 327 | usb_kill_urb(kbd->irq); |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 328 | input_unregister_device(kbd->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); |
| 330 | kfree(kbd); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static struct usb_device_id usb_kbd_id_table [] = { |
| 335 | { USB_INTERFACE_INFO(3, 1, 1) }, |
| 336 | { } /* Terminating entry */ |
| 337 | }; |
| 338 | |
| 339 | MODULE_DEVICE_TABLE (usb, usb_kbd_id_table); |
| 340 | |
| 341 | static struct usb_driver usb_kbd_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | .name = "usbkbd", |
| 343 | .probe = usb_kbd_probe, |
| 344 | .disconnect = usb_kbd_disconnect, |
| 345 | .id_table = usb_kbd_id_table, |
| 346 | }; |
| 347 | |
| 348 | static int __init usb_kbd_init(void) |
| 349 | { |
| 350 | int result = usb_register(&usb_kbd_driver); |
| 351 | if (result == 0) |
| 352 | info(DRIVER_VERSION ":" DRIVER_DESC); |
| 353 | return result; |
| 354 | } |
| 355 | |
| 356 | static void __exit usb_kbd_exit(void) |
| 357 | { |
| 358 | usb_deregister(&usb_kbd_driver); |
| 359 | } |
| 360 | |
| 361 | module_init(usb_kbd_init); |
| 362 | module_exit(usb_kbd_exit); |