Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB PhidgetInterfaceKit driver 1.0 |
| 3 | * |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 4 | * Copyright (C) 2004, 2006 Sean Young <sean@mess.org> |
| 5 | * Copyright (C) 2005 Daniel Saakes <daniel@saakes.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This is a driver for the USB PhidgetInterfaceKit. |
| 14 | */ |
| 15 | |
| 16 | #include <linux/config.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/usb.h> |
| 23 | |
| 24 | #define DRIVER_AUTHOR "Sean Young <sean@mess.org>" |
| 25 | #define DRIVER_DESC "USB PhidgetInterfaceKit Driver" |
| 26 | |
| 27 | #define USB_VENDOR_ID_GLAB 0x06c2 |
| 28 | #define USB_DEVICE_ID_INTERFACEKIT004 0x0040 |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 29 | #define USB_DEVICE_ID_INTERFACEKIT01616 0x0044 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #define USB_DEVICE_ID_INTERFACEKIT888 0x0045 |
| 31 | #define USB_DEVICE_ID_INTERFACEKIT047 0x0051 |
| 32 | #define USB_DEVICE_ID_INTERFACEKIT088 0x0053 |
| 33 | |
| 34 | #define USB_VENDOR_ID_WISEGROUP 0x0925 |
| 35 | #define USB_DEVICE_ID_INTERFACEKIT884 0x8201 |
| 36 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 37 | #define MAX_INTERFACES 16 |
| 38 | |
| 39 | #define URB_INT_SIZE 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | struct driver_interfacekit { |
| 42 | int sensors; |
| 43 | int inputs; |
| 44 | int outputs; |
| 45 | int has_lcd; |
| 46 | }; |
| 47 | #define ifkit(_sensors, _inputs, _outputs, _lcd) \ |
| 48 | static struct driver_interfacekit ph_##_sensors##_inputs##_outputs = { \ |
| 49 | .sensors = _sensors, \ |
| 50 | .inputs = _inputs, \ |
| 51 | .outputs = _outputs, \ |
| 52 | .has_lcd = _lcd, \ |
| 53 | }; |
| 54 | ifkit(0, 0, 4, 0); |
| 55 | ifkit(8, 8, 8, 0); |
| 56 | ifkit(0, 4, 7, 1); |
| 57 | ifkit(8, 8, 4, 0); |
| 58 | ifkit(0, 8, 8, 1); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 59 | ifkit(0, 16, 16, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 61 | struct interfacekit { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | struct usb_device *udev; |
| 63 | struct usb_interface *intf; |
| 64 | struct driver_interfacekit *ifkit; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 65 | unsigned long outputs; |
| 66 | u8 inputs[MAX_INTERFACES]; |
| 67 | u16 sensors[MAX_INTERFACES]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | u8 lcd_files_on; |
| 69 | |
| 70 | struct urb *irq; |
| 71 | unsigned char *data; |
| 72 | dma_addr_t data_dma; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 73 | |
| 74 | struct work_struct do_notify; |
| 75 | unsigned long input_events; |
| 76 | unsigned long sensor_events; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static struct usb_device_id id_table[] = { |
| 80 | {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT004), |
| 81 | .driver_info = (kernel_ulong_t)&ph_004}, |
| 82 | {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888), |
| 83 | .driver_info = (kernel_ulong_t)&ph_888}, |
| 84 | {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT047), |
| 85 | .driver_info = (kernel_ulong_t)&ph_047}, |
| 86 | {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT088), |
| 87 | .driver_info = (kernel_ulong_t)&ph_088}, |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 88 | {USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT01616), |
| 89 | .driver_info = (kernel_ulong_t)&ph_01616}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | {USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_INTERFACEKIT884), |
| 91 | .driver_info = (kernel_ulong_t)&ph_884}, |
| 92 | {} |
| 93 | }; |
| 94 | MODULE_DEVICE_TABLE(usb, id_table); |
| 95 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 96 | static int change_outputs(struct interfacekit *kit, int output_num, int enable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | { |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 98 | u8 *buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | int retval; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 100 | |
| 101 | if (enable) |
| 102 | set_bit(output_num, &kit->outputs); |
| 103 | else |
| 104 | clear_bit(output_num, &kit->outputs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Oliver Neukum | 1759084 | 2006-01-06 22:41:51 +0100 | [diff] [blame] | 106 | buffer = kzalloc(4, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | if (!buffer) { |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 108 | dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | return -ENOMEM; |
| 110 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 111 | buffer[0] = (u8)kit->outputs; |
| 112 | buffer[1] = (u8)(kit->outputs >> 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 114 | dev_dbg(&kit->udev->dev, "sending data: 0x%04x\n", (u16)kit->outputs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | retval = usb_control_msg(kit->udev, |
| 117 | usb_sndctrlpipe(kit->udev, 0), |
| 118 | 0x09, 0x21, 0x0200, 0x0000, buffer, 4, 2000); |
| 119 | |
| 120 | if (retval != 4) |
| 121 | dev_err(&kit->udev->dev, "usb_control_msg returned %d\n", |
| 122 | retval); |
| 123 | kfree(buffer); |
| 124 | |
| 125 | return retval < 0 ? retval : 0; |
| 126 | } |
| 127 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 128 | static int change_string(struct interfacekit *kit, const char *display, unsigned char row) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | { |
| 130 | unsigned char *buffer; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 131 | unsigned char *form_buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | int retval = -ENOMEM; |
| 133 | int i,j, len, buf_ptr; |
| 134 | |
| 135 | buffer = kmalloc(8, GFP_KERNEL); |
| 136 | form_buffer = kmalloc(30, GFP_KERNEL); |
| 137 | if ((!buffer) || (!form_buffer)) { |
| 138 | dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); |
| 139 | goto exit; |
| 140 | } |
| 141 | |
| 142 | len = strlen(display); |
| 143 | if (len > 20) |
| 144 | len = 20; |
| 145 | |
| 146 | dev_dbg(&kit->udev->dev, "Setting LCD line %d to %s\n", row, display); |
| 147 | |
| 148 | form_buffer[0] = row * 0x40 + 0x80; |
| 149 | form_buffer[1] = 0x02; |
| 150 | buf_ptr = 2; |
| 151 | for (i = 0; i<len; i++) |
| 152 | form_buffer[buf_ptr++] = display[i]; |
| 153 | |
| 154 | for (i = 0; i < (20 - len); i++) |
| 155 | form_buffer[buf_ptr++] = 0x20; |
| 156 | form_buffer[buf_ptr++] = 0x01; |
| 157 | form_buffer[buf_ptr++] = row * 0x40 + 0x80 + strlen(display); |
| 158 | |
| 159 | for (i = 0; i < buf_ptr; i += 7) { |
| 160 | if ((buf_ptr - i) > 7) |
| 161 | len = 7; |
| 162 | else |
| 163 | len = (buf_ptr - i); |
| 164 | for (j = 0; j < len; j++) |
| 165 | buffer[j] = form_buffer[i + j]; |
| 166 | buffer[7] = len; |
| 167 | |
| 168 | retval = usb_control_msg(kit->udev, |
| 169 | usb_sndctrlpipe(kit->udev, 0), |
| 170 | 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2000); |
| 171 | if (retval < 0) |
| 172 | goto exit; |
| 173 | } |
| 174 | |
| 175 | retval = 0; |
| 176 | exit: |
| 177 | kfree(buffer); |
| 178 | kfree(form_buffer); |
| 179 | |
| 180 | return retval; |
| 181 | } |
| 182 | |
| 183 | #define set_lcd_line(number) \ |
Yani Ioannou | 060b884 | 2005-05-17 06:44:04 -0400 | [diff] [blame] | 184 | static ssize_t lcd_line_##number(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | { \ |
| 186 | struct usb_interface *intf = to_usb_interface(dev); \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 187 | struct interfacekit *kit = usb_get_intfdata(intf); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | change_string(kit, buf, number - 1); \ |
| 189 | return count; \ |
| 190 | } \ |
| 191 | static DEVICE_ATTR(lcd_line_##number, S_IWUGO, NULL, lcd_line_##number); |
| 192 | set_lcd_line(1); |
| 193 | set_lcd_line(2); |
| 194 | |
Yani Ioannou | 060b884 | 2005-05-17 06:44:04 -0400 | [diff] [blame] | 195 | static ssize_t set_backlight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | { |
| 197 | struct usb_interface *intf = to_usb_interface(dev); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 198 | struct interfacekit *kit = usb_get_intfdata(intf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | int enabled; |
| 200 | unsigned char *buffer; |
| 201 | int retval = -ENOMEM; |
| 202 | |
Oliver Neukum | 1759084 | 2006-01-06 22:41:51 +0100 | [diff] [blame] | 203 | buffer = kzalloc(8, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | if (!buffer) { |
| 205 | dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__); |
| 206 | goto exit; |
| 207 | } |
| 208 | |
| 209 | if (sscanf(buf, "%d", &enabled) < 1) { |
| 210 | retval = -EINVAL; |
| 211 | goto exit; |
| 212 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | if (enabled) |
| 214 | buffer[0] = 0x01; |
| 215 | buffer[7] = 0x11; |
| 216 | |
| 217 | dev_dbg(&kit->udev->dev, "Setting backlight to %s\n", enabled ? "on" : "off"); |
| 218 | |
| 219 | retval = usb_control_msg(kit->udev, |
| 220 | usb_sndctrlpipe(kit->udev, 0), |
| 221 | 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2000); |
| 222 | if (retval < 0) |
| 223 | goto exit; |
| 224 | |
| 225 | retval = count; |
| 226 | exit: |
| 227 | kfree(buffer); |
| 228 | return retval; |
| 229 | } |
| 230 | static DEVICE_ATTR(backlight, S_IWUGO, NULL, set_backlight); |
| 231 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 232 | static void remove_lcd_files(struct interfacekit *kit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
| 234 | if (kit->lcd_files_on) { |
| 235 | dev_dbg(&kit->udev->dev, "Removing lcd files\n"); |
| 236 | device_remove_file(&kit->intf->dev, &dev_attr_lcd_line_1); |
| 237 | device_remove_file(&kit->intf->dev, &dev_attr_lcd_line_2); |
| 238 | device_remove_file(&kit->intf->dev, &dev_attr_backlight); |
| 239 | } |
| 240 | } |
| 241 | |
Yani Ioannou | 060b884 | 2005-05-17 06:44:04 -0400 | [diff] [blame] | 242 | static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | { |
| 244 | struct usb_interface *intf = to_usb_interface(dev); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 245 | struct interfacekit *kit = usb_get_intfdata(intf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | int enable; |
| 247 | |
| 248 | if (kit->ifkit->has_lcd == 0) |
| 249 | return -ENODEV; |
| 250 | |
| 251 | if (sscanf(buf, "%d", &enable) < 1) |
| 252 | return -EINVAL; |
| 253 | |
| 254 | if (enable) { |
| 255 | if (!kit->lcd_files_on) { |
| 256 | dev_dbg(&kit->udev->dev, "Adding lcd files\n"); |
| 257 | device_create_file(&kit->intf->dev, &dev_attr_lcd_line_1); |
| 258 | device_create_file(&kit->intf->dev, &dev_attr_lcd_line_2); |
| 259 | device_create_file(&kit->intf->dev, &dev_attr_backlight); |
| 260 | kit->lcd_files_on = 1; |
| 261 | } |
| 262 | } else { |
| 263 | if (kit->lcd_files_on) { |
| 264 | remove_lcd_files(kit); |
| 265 | kit->lcd_files_on = 0; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | return count; |
| 270 | } |
| 271 | static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files); |
| 272 | |
| 273 | static void interfacekit_irq(struct urb *urb, struct pt_regs *regs) |
| 274 | { |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 275 | struct interfacekit *kit = urb->context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | unsigned char *buffer = kit->data; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 277 | int i, level, sensor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
| 280 | switch (urb->status) { |
| 281 | case 0: /* success */ |
| 282 | break; |
| 283 | case -ECONNRESET: /* unlink */ |
| 284 | case -ENOENT: |
| 285 | case -ESHUTDOWN: |
| 286 | return; |
| 287 | /* -EPIPE: should clear the halt */ |
| 288 | default: /* error */ |
| 289 | goto resubmit; |
| 290 | } |
| 291 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 292 | /* digital inputs */ |
| 293 | if (kit->ifkit->inputs == 16) { |
| 294 | for (i=0; i < 8; i++) { |
| 295 | level = (buffer[0] >> i) & 1; |
| 296 | if (kit->inputs[i] != level) { |
| 297 | kit->inputs[i] = level; |
| 298 | set_bit(i, &kit->input_events); |
| 299 | } |
| 300 | level = (buffer[1] >> i) & 1; |
| 301 | if (kit->inputs[8 + i] != level) { |
| 302 | kit->inputs[8 + i] = level; |
| 303 | set_bit(8 + i, &kit->input_events); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | else if (kit->ifkit->inputs == 8) { |
| 308 | for (i=0; i < 8; i++) { |
| 309 | level = (buffer[1] >> i) & 1; |
| 310 | if (kit->inputs[i] != level) { |
| 311 | kit->inputs[i] = level; |
| 312 | set_bit(i, &kit->input_events); |
| 313 | } |
| 314 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 317 | /* analog inputs */ |
| 318 | if (kit->ifkit->sensors) { |
| 319 | sensor = (buffer[0] & 1) ? 4 : 0; |
| 320 | |
| 321 | level = buffer[2] + (buffer[3] & 0x0f) * 256; |
| 322 | if (level != kit->sensors[sensor]) { |
| 323 | kit->sensors[sensor] = level; |
| 324 | set_bit(sensor, &kit->sensor_events); |
| 325 | } |
| 326 | sensor++; |
| 327 | level = buffer[4] + (buffer[3] & 0xf0) * 16; |
| 328 | if (level != kit->sensors[sensor]) { |
| 329 | kit->sensors[sensor] = level; |
| 330 | set_bit(sensor, &kit->sensor_events); |
| 331 | } |
| 332 | sensor++; |
| 333 | level = buffer[5] + (buffer[6] & 0x0f) * 256; |
| 334 | if (level != kit->sensors[sensor]) { |
| 335 | kit->sensors[sensor] = level; |
| 336 | set_bit(sensor, &kit->sensor_events); |
| 337 | } |
| 338 | sensor++; |
| 339 | level = buffer[7] + (buffer[6] & 0xf0) * 16; |
| 340 | if (level != kit->sensors[sensor]) { |
| 341 | kit->sensors[sensor] = level; |
| 342 | set_bit(sensor, &kit->sensor_events); |
| 343 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | } |
| 345 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 346 | if (kit->input_events || kit->sensor_events) |
| 347 | schedule_work(&kit->do_notify); |
| 348 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | resubmit: |
| 350 | status = usb_submit_urb(urb, SLAB_ATOMIC); |
| 351 | if (status) |
| 352 | err("can't resubmit intr, %s-%s/interfacekit0, status %d", |
| 353 | kit->udev->bus->bus_name, |
| 354 | kit->udev->devpath, status); |
| 355 | } |
| 356 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 357 | static void do_notify(void *data) |
| 358 | { |
| 359 | struct interfacekit *kit = data; |
| 360 | int i; |
| 361 | char sysfs_file[8]; |
| 362 | |
| 363 | for (i=0; i<kit->ifkit->inputs; i++) { |
| 364 | if (test_and_clear_bit(i, &kit->input_events)) { |
| 365 | sprintf(sysfs_file, "input%d", i + 1); |
| 366 | sysfs_notify(&kit->intf->dev.kobj, NULL, sysfs_file); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | for (i=0; i<kit->ifkit->sensors; i++) { |
| 371 | if (test_and_clear_bit(i, &kit->sensor_events)) { |
| 372 | sprintf(sysfs_file, "sensor%d", i + 1); |
| 373 | sysfs_notify(&kit->intf->dev.kobj, NULL, sysfs_file); |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | #define show_set_output(value) \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 379 | static ssize_t set_output##value(struct device *dev, struct device_attribute *attr, const char *buf, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | size_t count) \ |
| 381 | { \ |
| 382 | struct usb_interface *intf = to_usb_interface(dev); \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 383 | struct interfacekit *kit = usb_get_intfdata(intf); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | int enabled; \ |
| 385 | int retval; \ |
| 386 | \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 387 | if (sscanf(buf, "%d", &enabled) < 1) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | return -EINVAL; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 390 | retval = change_outputs(kit, value - 1, enabled); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | \ |
| 392 | return retval ? retval : count; \ |
| 393 | } \ |
| 394 | \ |
Yani Ioannou | 060b884 | 2005-05-17 06:44:04 -0400 | [diff] [blame] | 395 | static ssize_t show_output##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | { \ |
| 397 | struct usb_interface *intf = to_usb_interface(dev); \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 398 | struct interfacekit *kit = usb_get_intfdata(intf); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 400 | return sprintf(buf, "%d\n", !!test_bit(value - 1, &kit->outputs));\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | } \ |
| 402 | static DEVICE_ATTR(output##value, S_IWUGO | S_IRUGO, \ |
| 403 | show_output##value, set_output##value); |
| 404 | show_set_output(1); |
| 405 | show_set_output(2); |
| 406 | show_set_output(3); |
| 407 | show_set_output(4); |
| 408 | show_set_output(5); |
| 409 | show_set_output(6); |
| 410 | show_set_output(7); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 411 | show_set_output(8); |
| 412 | show_set_output(9); |
| 413 | show_set_output(10); |
| 414 | show_set_output(11); |
| 415 | show_set_output(12); |
| 416 | show_set_output(13); |
| 417 | show_set_output(14); |
| 418 | show_set_output(15); |
| 419 | show_set_output(16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
| 421 | #define show_input(value) \ |
Yani Ioannou | 060b884 | 2005-05-17 06:44:04 -0400 | [diff] [blame] | 422 | static ssize_t show_input##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | { \ |
| 424 | struct usb_interface *intf = to_usb_interface(dev); \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 425 | struct interfacekit *kit = usb_get_intfdata(intf); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 427 | return sprintf(buf, "%d\n", (int)kit->inputs[value - 1]); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } \ |
| 429 | static DEVICE_ATTR(input##value, S_IRUGO, show_input##value, NULL); |
| 430 | |
| 431 | show_input(1); |
| 432 | show_input(2); |
| 433 | show_input(3); |
| 434 | show_input(4); |
| 435 | show_input(5); |
| 436 | show_input(6); |
| 437 | show_input(7); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 438 | show_input(8); |
| 439 | show_input(9); |
| 440 | show_input(10); |
| 441 | show_input(11); |
| 442 | show_input(12); |
| 443 | show_input(13); |
| 444 | show_input(14); |
| 445 | show_input(15); |
| 446 | show_input(16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
| 448 | #define show_sensor(value) \ |
Yani Ioannou | 060b884 | 2005-05-17 06:44:04 -0400 | [diff] [blame] | 449 | static ssize_t show_sensor##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | { \ |
| 451 | struct usb_interface *intf = to_usb_interface(dev); \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 452 | struct interfacekit *kit = usb_get_intfdata(intf); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | \ |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 454 | return sprintf(buf, "%d\n", (int)kit->sensors[value - 1]); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | } \ |
| 456 | static DEVICE_ATTR(sensor##value, S_IRUGO, show_sensor##value, NULL); |
| 457 | |
| 458 | show_sensor(1); |
| 459 | show_sensor(2); |
| 460 | show_sensor(3); |
| 461 | show_sensor(4); |
| 462 | show_sensor(5); |
| 463 | show_sensor(6); |
| 464 | show_sensor(7); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 465 | show_sensor(8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
| 467 | static int interfacekit_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 468 | { |
| 469 | struct usb_device *dev = interface_to_usbdev(intf); |
| 470 | struct usb_host_interface *interface; |
| 471 | struct usb_endpoint_descriptor *endpoint; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 472 | struct interfacekit *kit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | struct driver_interfacekit *ifkit; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 474 | int pipe, maxp, rc = -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
| 476 | ifkit = (struct driver_interfacekit *)id->driver_info; |
| 477 | if (!ifkit) |
| 478 | return -ENODEV; |
| 479 | |
| 480 | interface = intf->cur_altsetting; |
| 481 | if (interface->desc.bNumEndpoints != 1) |
| 482 | return -ENODEV; |
| 483 | |
| 484 | endpoint = &interface->endpoint[0].desc; |
| 485 | if (!(endpoint->bEndpointAddress & 0x80)) |
| 486 | return -ENODEV; |
| 487 | /* |
| 488 | * bmAttributes |
| 489 | */ |
| 490 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
| 491 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
| 492 | |
Oliver Neukum | 1759084 | 2006-01-06 22:41:51 +0100 | [diff] [blame] | 493 | kit = kzalloc(sizeof(*kit), GFP_KERNEL); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 494 | if (!kit) |
| 495 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 497 | kit->ifkit = ifkit; |
| 498 | kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma); |
| 499 | if (!kit->data) |
| 500 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
| 502 | kit->irq = usb_alloc_urb(0, GFP_KERNEL); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 503 | if (!kit->irq) |
| 504 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | kit->udev = usb_get_dev(dev); |
| 507 | kit->intf = intf; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 508 | INIT_WORK(&kit->do_notify, do_notify, kit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data, |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 510 | maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | interfacekit_irq, kit, endpoint->bInterval); |
| 512 | kit->irq->transfer_dma = kit->data_dma; |
| 513 | kit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 514 | |
| 515 | usb_set_intfdata(intf, kit); |
| 516 | |
| 517 | if (usb_submit_urb(kit->irq, GFP_KERNEL)) { |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 518 | rc = -EIO; |
| 519 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | if (ifkit->outputs >= 4) { |
| 523 | device_create_file(&intf->dev, &dev_attr_output1); |
| 524 | device_create_file(&intf->dev, &dev_attr_output2); |
| 525 | device_create_file(&intf->dev, &dev_attr_output3); |
| 526 | device_create_file(&intf->dev, &dev_attr_output4); |
| 527 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 528 | if (ifkit->outputs >= 8) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | device_create_file(&intf->dev, &dev_attr_output5); |
| 530 | device_create_file(&intf->dev, &dev_attr_output6); |
| 531 | device_create_file(&intf->dev, &dev_attr_output7); |
| 532 | device_create_file(&intf->dev, &dev_attr_output8); |
| 533 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 534 | if (ifkit->outputs == 16) { |
| 535 | device_create_file(&intf->dev, &dev_attr_output9); |
| 536 | device_create_file(&intf->dev, &dev_attr_output10); |
| 537 | device_create_file(&intf->dev, &dev_attr_output11); |
| 538 | device_create_file(&intf->dev, &dev_attr_output12); |
| 539 | device_create_file(&intf->dev, &dev_attr_output13); |
| 540 | device_create_file(&intf->dev, &dev_attr_output14); |
| 541 | device_create_file(&intf->dev, &dev_attr_output15); |
| 542 | device_create_file(&intf->dev, &dev_attr_output16); |
| 543 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | |
| 545 | if (ifkit->inputs >= 4) { |
| 546 | device_create_file(&intf->dev, &dev_attr_input1); |
| 547 | device_create_file(&intf->dev, &dev_attr_input2); |
| 548 | device_create_file(&intf->dev, &dev_attr_input3); |
| 549 | device_create_file(&intf->dev, &dev_attr_input4); |
| 550 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 551 | if (ifkit->inputs >= 8) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | device_create_file(&intf->dev, &dev_attr_input5); |
| 553 | device_create_file(&intf->dev, &dev_attr_input6); |
| 554 | device_create_file(&intf->dev, &dev_attr_input7); |
| 555 | device_create_file(&intf->dev, &dev_attr_input8); |
| 556 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 557 | if (ifkit->inputs == 16) { |
| 558 | device_create_file(&intf->dev, &dev_attr_input9); |
| 559 | device_create_file(&intf->dev, &dev_attr_input10); |
| 560 | device_create_file(&intf->dev, &dev_attr_input11); |
| 561 | device_create_file(&intf->dev, &dev_attr_input12); |
| 562 | device_create_file(&intf->dev, &dev_attr_input13); |
| 563 | device_create_file(&intf->dev, &dev_attr_input14); |
| 564 | device_create_file(&intf->dev, &dev_attr_input15); |
| 565 | device_create_file(&intf->dev, &dev_attr_input16); |
| 566 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
| 568 | if (ifkit->sensors >= 4) { |
| 569 | device_create_file(&intf->dev, &dev_attr_sensor1); |
| 570 | device_create_file(&intf->dev, &dev_attr_sensor2); |
| 571 | device_create_file(&intf->dev, &dev_attr_sensor3); |
| 572 | device_create_file(&intf->dev, &dev_attr_sensor4); |
| 573 | } |
| 574 | if (ifkit->sensors >= 7) { |
| 575 | device_create_file(&intf->dev, &dev_attr_sensor5); |
| 576 | device_create_file(&intf->dev, &dev_attr_sensor6); |
| 577 | device_create_file(&intf->dev, &dev_attr_sensor7); |
| 578 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 579 | if (ifkit->sensors == 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | device_create_file(&intf->dev, &dev_attr_sensor8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | |
| 582 | if (ifkit->has_lcd) |
| 583 | device_create_file(&intf->dev, &dev_attr_lcd); |
| 584 | |
| 585 | dev_info(&intf->dev, "USB PhidgetInterfaceKit %d/%d/%d attached\n", |
| 586 | ifkit->sensors, ifkit->inputs, ifkit->outputs); |
| 587 | |
| 588 | return 0; |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 589 | |
| 590 | out: |
| 591 | if (kit) { |
| 592 | if (kit->irq) |
| 593 | usb_free_urb(kit->irq); |
| 594 | if (kit->data) |
| 595 | usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma); |
| 596 | kfree(kit); |
| 597 | } |
| 598 | |
| 599 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | static void interfacekit_disconnect(struct usb_interface *interface) |
| 603 | { |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 604 | struct interfacekit *kit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
| 606 | kit = usb_get_intfdata(interface); |
| 607 | usb_set_intfdata(interface, NULL); |
| 608 | if (!kit) |
| 609 | return; |
| 610 | |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 611 | usb_kill_urb(kit->irq); |
| 612 | usb_free_urb(kit->irq); |
| 613 | usb_buffer_free(kit->udev, URB_INT_SIZE, kit->data, kit->data_dma); |
| 614 | |
| 615 | cancel_delayed_work(&kit->do_notify); |
| 616 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | if (kit->ifkit->outputs >= 4) { |
| 618 | device_remove_file(&interface->dev, &dev_attr_output1); |
| 619 | device_remove_file(&interface->dev, &dev_attr_output2); |
| 620 | device_remove_file(&interface->dev, &dev_attr_output3); |
| 621 | device_remove_file(&interface->dev, &dev_attr_output4); |
| 622 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 623 | if (kit->ifkit->outputs >= 8) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | device_remove_file(&interface->dev, &dev_attr_output5); |
| 625 | device_remove_file(&interface->dev, &dev_attr_output6); |
| 626 | device_remove_file(&interface->dev, &dev_attr_output7); |
| 627 | device_remove_file(&interface->dev, &dev_attr_output8); |
| 628 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 629 | if (kit->ifkit->outputs == 16) { |
| 630 | device_remove_file(&interface->dev, &dev_attr_output9); |
| 631 | device_remove_file(&interface->dev, &dev_attr_output10); |
| 632 | device_remove_file(&interface->dev, &dev_attr_output11); |
| 633 | device_remove_file(&interface->dev, &dev_attr_output12); |
| 634 | device_remove_file(&interface->dev, &dev_attr_output13); |
| 635 | device_remove_file(&interface->dev, &dev_attr_output14); |
| 636 | device_remove_file(&interface->dev, &dev_attr_output15); |
| 637 | device_remove_file(&interface->dev, &dev_attr_output16); |
| 638 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
| 640 | if (kit->ifkit->inputs >= 4) { |
| 641 | device_remove_file(&interface->dev, &dev_attr_input1); |
| 642 | device_remove_file(&interface->dev, &dev_attr_input2); |
| 643 | device_remove_file(&interface->dev, &dev_attr_input3); |
| 644 | device_remove_file(&interface->dev, &dev_attr_input4); |
| 645 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 646 | if (kit->ifkit->inputs >= 8) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | device_remove_file(&interface->dev, &dev_attr_input5); |
| 648 | device_remove_file(&interface->dev, &dev_attr_input6); |
| 649 | device_remove_file(&interface->dev, &dev_attr_input7); |
| 650 | device_remove_file(&interface->dev, &dev_attr_input8); |
| 651 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 652 | if (kit->ifkit->inputs == 16) { |
| 653 | device_remove_file(&interface->dev, &dev_attr_input9); |
| 654 | device_remove_file(&interface->dev, &dev_attr_input10); |
| 655 | device_remove_file(&interface->dev, &dev_attr_input11); |
| 656 | device_remove_file(&interface->dev, &dev_attr_input12); |
| 657 | device_remove_file(&interface->dev, &dev_attr_input13); |
| 658 | device_remove_file(&interface->dev, &dev_attr_input14); |
| 659 | device_remove_file(&interface->dev, &dev_attr_input15); |
| 660 | device_remove_file(&interface->dev, &dev_attr_input16); |
| 661 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
| 663 | if (kit->ifkit->sensors >= 4) { |
| 664 | device_remove_file(&interface->dev, &dev_attr_sensor1); |
| 665 | device_remove_file(&interface->dev, &dev_attr_sensor2); |
| 666 | device_remove_file(&interface->dev, &dev_attr_sensor3); |
| 667 | device_remove_file(&interface->dev, &dev_attr_sensor4); |
| 668 | } |
| 669 | if (kit->ifkit->sensors >= 7) { |
| 670 | device_remove_file(&interface->dev, &dev_attr_sensor5); |
| 671 | device_remove_file(&interface->dev, &dev_attr_sensor6); |
| 672 | device_remove_file(&interface->dev, &dev_attr_sensor7); |
| 673 | } |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 674 | if (kit->ifkit->sensors == 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | device_remove_file(&interface->dev, &dev_attr_sensor8); |
Sean Young | 69165c2 | 2006-05-02 11:44:43 +0000 | [diff] [blame] | 676 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | if (kit->ifkit->has_lcd) |
| 678 | device_remove_file(&interface->dev, &dev_attr_lcd); |
| 679 | |
| 680 | dev_info(&interface->dev, "USB PhidgetInterfaceKit %d/%d/%d detached\n", |
| 681 | kit->ifkit->sensors, kit->ifkit->inputs, kit->ifkit->outputs); |
| 682 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | usb_put_dev(kit->udev); |
| 684 | kfree(kit); |
| 685 | } |
| 686 | |
| 687 | static struct usb_driver interfacekit_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | .name = "phidgetkit", |
| 689 | .probe = interfacekit_probe, |
| 690 | .disconnect = interfacekit_disconnect, |
| 691 | .id_table = id_table |
| 692 | }; |
| 693 | |
| 694 | static int __init interfacekit_init(void) |
| 695 | { |
| 696 | int retval = 0; |
| 697 | |
| 698 | retval = usb_register(&interfacekit_driver); |
| 699 | if (retval) |
| 700 | err("usb_register failed. Error number %d", retval); |
| 701 | |
| 702 | return retval; |
| 703 | } |
| 704 | |
| 705 | static void __exit interfacekit_exit(void) |
| 706 | { |
| 707 | usb_deregister(&interfacekit_driver); |
| 708 | } |
| 709 | |
| 710 | module_init(interfacekit_init); |
| 711 | module_exit(interfacekit_exit); |
| 712 | |
| 713 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 714 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 715 | MODULE_LICENSE("GPL"); |