2 * Line6 Linux USB driver - 0.8.0
4 * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <linux/usb.h>
31 #define DRIVER_AUTHOR "Markus Grabner <grabner@icg.tugraz.at>"
32 #define DRIVER_DESC "Line6 USB Driver"
33 #define DRIVER_VERSION "0.8.0"
36 /* table of devices that work with this driver */
37 static const struct usb_device_id line6_id_table[] = {
38 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT) },
39 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE) },
40 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO) },
41 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT) },
42 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD) },
43 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3) },
44 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE) },
45 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT) },
46 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE) },
47 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO) },
48 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX) },
49 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1) },
50 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2) },
51 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX) },
54 MODULE_DEVICE_TABLE(usb, line6_id_table);
56 static struct line6_properties line6_properties_table[] = {
57 { "BassPODxt", LINE6_BIT_BASSPODXT, LINE6_BIT_CONTROL_PCM },
58 { "BassPODxt Live", LINE6_BIT_BASSPODXTLIVE, LINE6_BIT_CONTROL_PCM },
59 { "BassPODxt Pro", LINE6_BIT_BASSPODXTPRO, LINE6_BIT_CONTROL_PCM },
60 { "GuitarPort", LINE6_BIT_GUITARPORT, LINE6_BIT_PCM },
61 { "Pocket POD", LINE6_BIT_POCKETPOD, LINE6_BIT_CONTROL_PCM },
62 { "POD X3", LINE6_BIT_PODX3, LINE6_BIT_PCM },
63 { "POD X3 Live", LINE6_BIT_PODX3LIVE, LINE6_BIT_PCM },
64 { "PODxt", LINE6_BIT_PODXT, LINE6_BIT_CONTROL_PCM },
65 { "PODxt Live", LINE6_BIT_PODXTLIVE, LINE6_BIT_CONTROL_PCM },
66 { "PODxt Pro", LINE6_BIT_PODXTPRO, LINE6_BIT_CONTROL_PCM },
67 { "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM },
68 { "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM },
69 { "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM },
70 { "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL }
75 This is Line6's MIDI manufacturer ID.
77 const unsigned char line6_midi_id[] = { 0x00, 0x01, 0x0c };
79 struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
80 struct workqueue_struct *line6_workqueue;
84 Class for asynchronous messages.
87 struct usb_line6 *line6;
97 static void line6_data_received(struct urb *urb);
98 static int line6_send_raw_message_async_part(struct message *msg,
103 Start to listen on endpoint.
105 static int line6_start_listen(struct usb_line6 *line6)
107 usb_fill_int_urb(line6->urb_listen, line6->usbdev,
108 usb_rcvintpipe(line6->usbdev, line6->ep_control_read),
109 line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
110 line6_data_received, line6, line6->interval);
111 line6->urb_listen->actual_length = 0;
112 return usb_submit_urb(line6->urb_listen, GFP_KERNEL);
117 Write hexdump to syslog.
119 void line6_write_hexdump(struct usb_line6 *line6, char dir,
120 const unsigned char *buffer, int size)
122 static const int BYTES_PER_LINE = 8;
124 char asc[BYTES_PER_LINE + 1];
127 for (i = 0; i < size; i += BYTES_PER_LINE) {
128 int hexdumpsize = sizeof(hexdump);
130 int n = min(size - i, BYTES_PER_LINE);
133 for (j = 0; j < BYTES_PER_LINE; ++j) {
137 unsigned char val = buffer[i + j];
138 bytes = snprintf(p, hexdumpsize, " %02X", val);
139 asc[j] = ((val >= 0x20) && (val < 0x7f)) ? val : '.';
141 bytes = snprintf(p, hexdumpsize, " ");
143 if (bytes > hexdumpsize)
144 break; /* buffer overflow */
147 hexdumpsize -= bytes;
150 dev_info(line6->ifcdev, "%c%04X:%s %s\n", dir, i, hexdump, asc);
155 #if DO_DUMP_URB_RECEIVE
157 Dump URB data to syslog.
159 static void line6_dump_urb(struct urb *urb)
161 struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
166 line6_write_hexdump(line6, 'R', (unsigned char *)urb->transfer_buffer,
172 Send raw message in pieces of max_packet_size bytes.
174 int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
181 line6_write_hexdump(line6, 'S', buffer, size);
184 for (i = 0; i < size; i += actual_size) {
185 const char *frag_buf = buffer + i;
186 int frag_size = min(line6->max_packet_size, size - i);
189 retval = usb_interrupt_msg(line6->usbdev,
190 usb_sndintpipe(line6->usbdev,
191 line6->ep_control_write),
192 (char *)frag_buf, frag_size,
193 &actual_size, LINE6_TIMEOUT * HZ);
196 dev_err(line6->ifcdev,
197 "usb_interrupt_msg failed (%d)\n", retval);
208 Notification of completion of asynchronous request transmission.
210 static void line6_async_request_sent(struct urb *urb)
212 struct message *msg = (struct message *)urb->context;
214 if (msg->done >= msg->size) {
218 line6_send_raw_message_async_part(msg, urb);
222 Asynchronously send part of a raw message.
224 static int line6_send_raw_message_async_part(struct message *msg,
228 struct usb_line6 *line6 = msg->line6;
229 int done = msg->done;
230 int bytes = min(msg->size - done, line6->max_packet_size);
232 usb_fill_int_urb(urb, line6->usbdev,
233 usb_sndintpipe(line6->usbdev, line6->ep_control_write),
234 (char *)msg->buffer + done, bytes,
235 line6_async_request_sent, msg, line6->interval);
238 line6_write_hexdump(line6, 'S', (char *)msg->buffer + done, bytes);
242 retval = usb_submit_urb(urb, GFP_ATOMIC);
245 dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n",
256 Asynchronously send raw message.
258 int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
264 /* create message: */
265 msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
268 dev_err(line6->ifcdev, "Out of memory\n");
273 urb = usb_alloc_urb(0, GFP_ATOMIC);
277 dev_err(line6->ifcdev, "Out of memory\n");
281 /* set message data: */
283 msg->buffer = buffer;
288 return line6_send_raw_message_async_part(msg, urb);
292 Send sysex message in pieces of wMaxPacketSize bytes.
294 int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
297 return line6_send_raw_message(line6, buffer, size + SYSEX_EXTRA_SIZE) - SYSEX_EXTRA_SIZE;
301 Allocate buffer for sysex message and prepare header.
302 @param code sysex message code
303 @param size number of bytes between code and sysex end
305 char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,
308 char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_KERNEL);
311 dev_err(line6->ifcdev, "out of memory\n");
315 buffer[0] = LINE6_SYSEX_BEGIN;
316 memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id));
317 buffer[sizeof(line6_midi_id) + 1] = code1;
318 buffer[sizeof(line6_midi_id) + 2] = code2;
319 buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END;
324 Notification of data received from the Line6 device.
326 static void line6_data_received(struct urb *urb)
328 struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
329 struct MidiBuffer *mb = &line6->line6midi->midibuf_in;
332 if (urb->status == -ESHUTDOWN)
335 #if DO_DUMP_URB_RECEIVE
339 done = midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
341 if (done < urb->actual_length) {
342 midibuf_ignore(mb, done);
343 DEBUG_MESSAGES(dev_err(line6->ifcdev, "%d %d buffer overflow - message skipped\n", done, urb->actual_length));
347 done = midibuf_read(mb, line6->buffer_message, LINE6_MESSAGE_MAXLEN);
352 /* MIDI input filter */
353 if (midibuf_skip_message(mb, line6->line6midi->midi_mask_receive))
356 line6->message_length = done;
357 #if DO_DUMP_MIDI_RECEIVE
358 line6_write_hexdump(line6, 'r', line6->buffer_message, done);
360 line6_midi_receive(line6, line6->buffer_message, done);
362 switch (line6->usbdev->descriptor.idProduct) {
363 case LINE6_DEVID_BASSPODXT:
364 case LINE6_DEVID_BASSPODXTLIVE:
365 case LINE6_DEVID_BASSPODXTPRO:
366 case LINE6_DEVID_PODXT:
367 case LINE6_DEVID_PODXTPRO:
368 case LINE6_DEVID_POCKETPOD:
369 pod_process_message((struct usb_line6_pod *)line6);
372 case LINE6_DEVID_PODXTLIVE:
373 switch (line6->interface_number) {
374 case PODXTLIVE_INTERFACE_POD:
375 pod_process_message((struct usb_line6_pod *)line6);
378 case PODXTLIVE_INTERFACE_VARIAX:
379 variax_process_message((struct usb_line6_variax *)line6);
383 dev_err(line6->ifcdev, "PODxt Live interface %d not supported\n", line6->interface_number);
387 case LINE6_DEVID_VARIAX:
388 variax_process_message((struct usb_line6_variax *)line6);
396 line6_start_listen(line6);
399 static int line6_send(struct usb_line6 *line6, unsigned char *buf, size_t len)
402 unsigned int partial;
405 line6_write_hexdump(line6, 'S', buf, len);
408 retval = usb_interrupt_msg(line6->usbdev,
409 usb_sndintpipe(line6->usbdev,
410 line6->ep_control_write),
415 dev_err(line6->ifcdev,
416 "usb_interrupt_msg failed (%d)\n", retval);
419 if (partial != len) {
420 dev_err(line6->ifcdev,
421 "usb_interrupt_msg sent partial message (%d)\n",
429 Send channel number (i.e., switch to a different sound).
431 int line6_send_program(struct usb_line6 *line6, int value)
433 unsigned char *buffer;
436 buffer = kmalloc(len, GFP_KERNEL);
438 dev_err(line6->ifcdev, "out of memory\n");
442 buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST;
445 return line6_send(line6, buffer, len);
449 Transmit Line6 control parameter.
451 int line6_transmit_parameter(struct usb_line6 *line6, int param, int value)
453 unsigned char *buffer;
456 buffer = kmalloc(len, GFP_KERNEL);
458 dev_err(line6->ifcdev, "out of memory\n");
462 buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST;
466 return line6_send(line6, buffer, len);
470 Read data from device.
472 int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen)
474 struct usb_device *usbdev = line6->usbdev;
478 /* query the serial number: */
479 ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
480 USB_TYPE_VENDOR | USB_RECIP_DEVICE
482 (datalen << 8) | 0x21, address,
483 NULL, 0, LINE6_TIMEOUT * HZ);
486 dev_err(line6->ifcdev, "read request failed (error %d)\n", ret);
490 /* Wait for data length. We'll get a couple of 0xff until length arrives. */
492 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
493 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
495 0x0012, 0x0000, &len, 1,
498 dev_err(line6->ifcdev,
499 "receive length failed (error %d)\n", ret);
502 } while (len == 0xff);
504 if (len != datalen) {
505 /* should be equal or something went wrong */
506 dev_err(line6->ifcdev,
507 "length mismatch (expected %d, got %d)\n",
508 (int)datalen, (int)len);
512 /* receive the result: */
513 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
514 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
515 0x0013, 0x0000, data, datalen,
519 dev_err(line6->ifcdev, "read failed (error %d)\n", ret);
527 Write data to device.
529 int line6_write_data(struct usb_line6 *line6, int address, void *data,
532 struct usb_device *usbdev = line6->usbdev;
534 unsigned char status;
536 ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
537 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
538 0x0022, address, data, datalen,
542 dev_err(line6->ifcdev,
543 "write request failed (error %d)\n", ret);
548 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
550 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
553 &status, 1, LINE6_TIMEOUT * HZ);
556 dev_err(line6->ifcdev,
557 "receiving status failed (error %d)\n", ret);
561 while (status == 0xff)
565 dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
573 Read Line6 device serial number.
574 (POD, TonePort, GuitarPort)
576 int line6_read_serial_number(struct usb_line6 *line6, int *serial_number)
578 return line6_read_data(line6, 0x80d0, serial_number, sizeof(*serial_number));
582 No operation (i.e., unsupported).
584 ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
591 No operation (i.e., unsupported).
593 ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
594 const char *buf, size_t count)
600 "write" request on "raw" special file.
603 ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
604 const char *buf, size_t count)
606 struct usb_interface *interface = to_usb_interface(dev);
607 struct usb_line6 *line6 = usb_get_intfdata(interface);
608 line6_send_raw_message(line6, buf, count);
616 static void line6_destruct(struct usb_interface *interface)
618 struct usb_line6 *line6;
620 if (interface == NULL)
622 line6 = usb_get_intfdata(interface);
626 /* free buffer memory first: */
627 kfree(line6->buffer_message);
628 kfree(line6->buffer_listen);
630 /* then free URBs: */
631 usb_free_urb(line6->urb_listen);
633 /* make sure the device isn't destructed twice: */
634 usb_set_intfdata(interface, NULL);
636 /* free interface data: */
640 static void line6_list_devices(void)
644 for (i = 0; i < LINE6_MAX_DEVICES; ++i) {
645 struct usb_line6 *dev = line6_devices[i];
646 printk(KERN_INFO "Line6 device %d: ", i);
649 printk("(not used)\n");
651 printk("%s:%d\n", dev->properties->name, dev->interface_number);
658 static int line6_probe(struct usb_interface *interface, const struct usb_device_id *id)
661 struct usb_device *usbdev = NULL;
662 struct usb_line6 *line6 = NULL;
663 const struct line6_properties *properties;
665 int interface_number, alternate = 0;
668 int ep_read = 0, ep_write = 0;
671 if (interface == NULL)
673 usbdev = interface_to_usbdev(interface);
677 /* increment reference counters: */
678 usb_get_intf(interface);
681 /* we don't handle multiple configurations */
682 if (usbdev->descriptor.bNumConfigurations != 1)
685 /* check vendor and product id */
686 for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) {
687 u16 vendor = le16_to_cpu(usbdev->descriptor.idVendor);
688 u16 product = le16_to_cpu(usbdev->descriptor.idProduct);
690 if (vendor == line6_id_table[devtype].idVendor
691 && product == line6_id_table[devtype].idProduct)
698 /* find free slot in device table: */
699 for (devnum = 0; devnum < LINE6_MAX_DEVICES; ++devnum)
700 if (line6_devices[devnum] == NULL)
703 if (devnum == LINE6_MAX_DEVICES)
706 /* initialize device info: */
707 properties = &line6_properties_table[devtype];
708 dev_info(&interface->dev, "Line6 %s found\n", properties->name);
709 product = le16_to_cpu(usbdev->descriptor.idProduct);
711 /* query interface number */
712 interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
715 case LINE6_DEVID_BASSPODXTLIVE:
716 case LINE6_DEVID_POCKETPOD:
717 case LINE6_DEVID_PODXTLIVE:
718 case LINE6_DEVID_VARIAX:
722 case LINE6_DEVID_PODX3:
723 case LINE6_DEVID_PODX3LIVE:
724 switch (interface_number) {
736 case LINE6_DEVID_BASSPODXT:
737 case LINE6_DEVID_BASSPODXTPRO:
738 case LINE6_DEVID_PODXT:
739 case LINE6_DEVID_PODXTPRO:
743 case LINE6_DEVID_TONEPORT_GX:
744 case LINE6_DEVID_GUITARPORT:
745 alternate = 2; /* 1..4 seem to be ok */
748 case LINE6_DEVID_TONEPORT_UX1:
749 case LINE6_DEVID_TONEPORT_UX2:
750 switch (interface_number) {
752 /* defaults to 44.1kHz, 16-bit */
768 ret = usb_set_interface(usbdev, interface_number, alternate);
770 dev_err(&interface->dev, "set_interface failed\n");
774 /* initialize device data based on product id: */
776 case LINE6_DEVID_BASSPODXT:
777 case LINE6_DEVID_BASSPODXTLIVE:
778 case LINE6_DEVID_BASSPODXTPRO:
779 case LINE6_DEVID_POCKETPOD:
780 case LINE6_DEVID_PODXT:
781 case LINE6_DEVID_PODXTPRO:
782 size = sizeof(struct usb_line6_pod);
787 case LINE6_DEVID_PODX3:
788 case LINE6_DEVID_PODX3LIVE:
789 /* currently unused! */
790 size = sizeof(struct usb_line6_pod);
795 case LINE6_DEVID_TONEPORT_GX:
796 case LINE6_DEVID_TONEPORT_UX1:
797 case LINE6_DEVID_TONEPORT_UX2:
798 case LINE6_DEVID_GUITARPORT:
799 size = sizeof(struct usb_line6_toneport);
800 /* these don't have a control channel */
803 case LINE6_DEVID_PODXTLIVE:
804 switch (interface_number) {
805 case PODXTLIVE_INTERFACE_POD:
806 size = sizeof(struct usb_line6_pod);
811 case PODXTLIVE_INTERFACE_VARIAX:
812 size = sizeof(struct usb_line6_variax);
822 case LINE6_DEVID_VARIAX:
823 size = sizeof(struct usb_line6_variax);
834 dev_err(line6->ifcdev, "driver bug: interface data size not set\n");
838 line6 = kzalloc(size, GFP_KERNEL);
841 dev_err(&interface->dev, "Out of memory\n");
845 /* store basic data: */
846 line6->interface_number = interface_number;
847 line6->properties = properties;
848 line6->usbdev = usbdev;
849 line6->ifcdev = &interface->dev;
850 line6->ep_control_read = ep_read;
851 line6->ep_control_write = ep_write;
852 line6->product = product;
854 /* get data from endpoint descriptor (see usb_maxpacket): */
856 struct usb_host_endpoint *ep;
857 unsigned epnum = usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read));
858 ep = usbdev->ep_in[epnum];
861 line6->interval = ep->desc.bInterval;
862 line6->max_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
864 line6->interval = LINE6_FALLBACK_INTERVAL;
865 line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE;
866 dev_err(line6->ifcdev, "endpoint not available, using fallback values");
870 usb_set_intfdata(interface, line6);
872 if (properties->capabilities & LINE6_BIT_CONTROL) {
873 /* initialize USB buffers: */
874 line6->buffer_listen = kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL);
876 if (line6->buffer_listen == NULL) {
877 dev_err(&interface->dev, "Out of memory\n");
878 line6_destruct(interface);
882 line6->buffer_message = kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL);
884 if (line6->buffer_message == NULL) {
885 dev_err(&interface->dev, "Out of memory\n");
886 line6_destruct(interface);
890 line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL);
892 if (line6->urb_listen == NULL) {
893 dev_err(&interface->dev, "Out of memory\n");
894 line6_destruct(interface);
898 ret = line6_start_listen(line6);
900 dev_err(&interface->dev, "%s: usb_submit_urb failed\n",
902 line6_destruct(interface);
907 /* initialize device data based on product id: */
909 case LINE6_DEVID_BASSPODXT:
910 case LINE6_DEVID_BASSPODXTLIVE:
911 case LINE6_DEVID_BASSPODXTPRO:
912 case LINE6_DEVID_POCKETPOD:
913 case LINE6_DEVID_PODX3:
914 case LINE6_DEVID_PODX3LIVE:
915 case LINE6_DEVID_PODXT:
916 case LINE6_DEVID_PODXTPRO:
917 ret = pod_init(interface, (struct usb_line6_pod *)line6);
920 case LINE6_DEVID_PODXTLIVE:
921 switch (interface_number) {
922 case PODXTLIVE_INTERFACE_POD:
923 ret = pod_init(interface, (struct usb_line6_pod *)line6);
926 case PODXTLIVE_INTERFACE_VARIAX:
927 ret = variax_init(interface, (struct usb_line6_variax *)line6);
931 dev_err(&interface->dev,
932 "PODxt Live interface %d not supported\n",
939 case LINE6_DEVID_VARIAX:
940 ret = variax_init(interface, (struct usb_line6_variax *)line6);
943 case LINE6_DEVID_TONEPORT_GX:
944 case LINE6_DEVID_TONEPORT_UX1:
945 case LINE6_DEVID_TONEPORT_UX2:
946 case LINE6_DEVID_GUITARPORT:
947 ret = toneport_init(interface, (struct usb_line6_toneport *)line6);
956 line6_destruct(interface);
960 ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj,
963 line6_destruct(interface);
967 dev_info(&interface->dev, "Line6 %s now attached\n",
968 line6->properties->name);
969 line6_devices[devnum] = line6;
970 line6_list_devices();
975 Line6 device disconnected.
977 static void line6_disconnect(struct usb_interface *interface)
979 struct usb_line6 *line6;
980 struct usb_device *usbdev;
981 int interface_number, i;
983 if (interface == NULL)
985 usbdev = interface_to_usbdev(interface);
989 sysfs_remove_link(&interface->dev.kobj, "usb_device");
991 interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
992 line6 = usb_get_intfdata(interface);
995 if (line6->urb_listen != NULL)
996 usb_kill_urb(line6->urb_listen);
998 if (usbdev != line6->usbdev)
999 dev_err(line6->ifcdev,
1000 "driver bug: inconsistent usb device\n");
1002 switch (line6->usbdev->descriptor.idProduct) {
1003 case LINE6_DEVID_BASSPODXT:
1004 case LINE6_DEVID_BASSPODXTLIVE:
1005 case LINE6_DEVID_BASSPODXTPRO:
1006 case LINE6_DEVID_POCKETPOD:
1007 case LINE6_DEVID_PODX3:
1008 case LINE6_DEVID_PODX3LIVE:
1009 case LINE6_DEVID_PODXT:
1010 case LINE6_DEVID_PODXTPRO:
1011 pod_disconnect(interface);
1014 case LINE6_DEVID_PODXTLIVE:
1015 switch (interface_number) {
1016 case PODXTLIVE_INTERFACE_POD:
1017 pod_disconnect(interface);
1020 case PODXTLIVE_INTERFACE_VARIAX:
1021 variax_disconnect(interface);
1027 case LINE6_DEVID_VARIAX:
1028 variax_disconnect(interface);
1031 case LINE6_DEVID_TONEPORT_GX:
1032 case LINE6_DEVID_TONEPORT_UX1:
1033 case LINE6_DEVID_TONEPORT_UX2:
1034 case LINE6_DEVID_GUITARPORT:
1035 toneport_disconnect(interface);
1042 dev_info(&interface->dev, "Line6 %s now disconnected\n", line6->properties->name);
1044 for (i = LINE6_MAX_DEVICES; i--;) {
1045 if (line6_devices[i] == line6)
1046 line6_devices[i] = NULL;
1050 line6_destruct(interface);
1052 /* decrement reference counters: */
1053 usb_put_intf(interface);
1054 usb_put_dev(usbdev);
1056 line6_list_devices();
1059 static struct usb_driver line6_driver = {
1060 .name = DRIVER_NAME,
1061 .probe = line6_probe,
1062 .disconnect = line6_disconnect,
1063 .id_table = line6_id_table,
1067 Module initialization.
1069 static int __init line6_init(void)
1073 printk(KERN_INFO "%s driver version %s%s\n",
1074 DRIVER_NAME, DRIVER_VERSION, DRIVER_REVISION);
1075 line6_workqueue = create_workqueue(DRIVER_NAME);
1077 if (line6_workqueue == NULL) {
1078 err("couldn't create workqueue");
1082 for (i = LINE6_MAX_DEVICES; i--;)
1083 line6_devices[i] = NULL;
1085 retval = usb_register(&line6_driver);
1088 err("usb_register failed. Error number %d", retval);
1096 static void __exit line6_exit(void)
1098 destroy_workqueue(line6_workqueue);
1099 usb_deregister(&line6_driver);
1102 module_init(line6_init);
1103 module_exit(line6_exit);
1105 MODULE_AUTHOR(DRIVER_AUTHOR);
1106 MODULE_DESCRIPTION(DRIVER_DESC);
1107 MODULE_LICENSE("GPL");
1108 MODULE_VERSION(DRIVER_VERSION);