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