Commit c5cbebf87f49dfb4f4ccdf86f6c24b4912a3061f
Committed by
Greg Kroah-Hartman
1 parent
10ceaac958
Exists in
master
and in
7 other branches
drivers/staging/line6/driver.c: Drop unneeded put functions.
This seems to be the result of patches ab366c1a and 1027f476 crossing each other. Patch ab366c1a adds calls to usb_put_intf and usb_put_dev at the end of the function line6_probe, in the error handling code, while patch 1027f476 moves the calls to the corresponding get function from the beginning to the end of line6_probe, making the calls to put in the error handling code unnecessary. // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 1 changed file with 0 additions and 2 deletions Inline Diff
drivers/staging/line6/driver.c
1 | /* | 1 | /* |
2 | * Line6 Linux USB driver - 0.9.1beta | 2 | * Line6 Linux USB driver - 0.9.1beta |
3 | * | 3 | * |
4 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) | 4 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 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 | 7 | * modify it under the terms of the GNU General Public License as |
8 | * published by the Free Software Foundation, version 2. | 8 | * published by the Free Software Foundation, version 2. |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
16 | 16 | ||
17 | #include "audio.h" | 17 | #include "audio.h" |
18 | #include "capture.h" | 18 | #include "capture.h" |
19 | #include "control.h" | 19 | #include "control.h" |
20 | #include "driver.h" | 20 | #include "driver.h" |
21 | #include "midi.h" | 21 | #include "midi.h" |
22 | #include "playback.h" | 22 | #include "playback.h" |
23 | #include "pod.h" | 23 | #include "pod.h" |
24 | #include "revision.h" | 24 | #include "revision.h" |
25 | #include "toneport.h" | 25 | #include "toneport.h" |
26 | #include "usbdefs.h" | 26 | #include "usbdefs.h" |
27 | #include "variax.h" | 27 | #include "variax.h" |
28 | 28 | ||
29 | #define DRIVER_AUTHOR "Markus Grabner <grabner@icg.tugraz.at>" | 29 | #define DRIVER_AUTHOR "Markus Grabner <grabner@icg.tugraz.at>" |
30 | #define DRIVER_DESC "Line6 USB Driver" | 30 | #define DRIVER_DESC "Line6 USB Driver" |
31 | #define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION | 31 | #define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION |
32 | 32 | ||
33 | /* table of devices that work with this driver */ | 33 | /* table of devices that work with this driver */ |
34 | static const struct usb_device_id line6_id_table[] = { | 34 | static const struct usb_device_id line6_id_table[] = { |
35 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT)}, | 35 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT)}, |
36 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE)}, | 36 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE)}, |
37 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO)}, | 37 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO)}, |
38 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT)}, | 38 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT)}, |
39 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD)}, | 39 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD)}, |
40 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_GX)}, | 40 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_GX)}, |
41 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX1)}, | 41 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX1)}, |
42 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX2)}, | 42 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX2)}, |
43 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3)}, | 43 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3)}, |
44 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE)}, | 44 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE)}, |
45 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT)}, | 45 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT)}, |
46 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE)}, | 46 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE)}, |
47 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO)}, | 47 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO)}, |
48 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX)}, | 48 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX)}, |
49 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1)}, | 49 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1)}, |
50 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2)}, | 50 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2)}, |
51 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX)}, | 51 | {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX)}, |
52 | {}, | 52 | {}, |
53 | }; | 53 | }; |
54 | 54 | ||
55 | MODULE_DEVICE_TABLE(usb, line6_id_table); | 55 | MODULE_DEVICE_TABLE(usb, line6_id_table); |
56 | 56 | ||
57 | /* *INDENT-OFF* */ | 57 | /* *INDENT-OFF* */ |
58 | static struct line6_properties line6_properties_table[] = { | 58 | static struct line6_properties line6_properties_table[] = { |
59 | { "BassPODxt", "BassPODxt", LINE6_BIT_BASSPODXT, LINE6_BIT_CONTROL_PCM_HWMON }, | 59 | { "BassPODxt", "BassPODxt", LINE6_BIT_BASSPODXT, LINE6_BIT_CONTROL_PCM_HWMON }, |
60 | { "BassPODxtLive", "BassPODxt Live", LINE6_BIT_BASSPODXTLIVE, LINE6_BIT_CONTROL_PCM_HWMON }, | 60 | { "BassPODxtLive", "BassPODxt Live", LINE6_BIT_BASSPODXTLIVE, LINE6_BIT_CONTROL_PCM_HWMON }, |
61 | { "BassPODxtPro", "BassPODxt Pro", LINE6_BIT_BASSPODXTPRO, LINE6_BIT_CONTROL_PCM_HWMON }, | 61 | { "BassPODxtPro", "BassPODxt Pro", LINE6_BIT_BASSPODXTPRO, LINE6_BIT_CONTROL_PCM_HWMON }, |
62 | { "GuitarPort", "GuitarPort", LINE6_BIT_GUITARPORT, LINE6_BIT_PCM }, | 62 | { "GuitarPort", "GuitarPort", LINE6_BIT_GUITARPORT, LINE6_BIT_PCM }, |
63 | { "PocketPOD", "Pocket POD", LINE6_BIT_POCKETPOD, LINE6_BIT_CONTROL }, | 63 | { "PocketPOD", "Pocket POD", LINE6_BIT_POCKETPOD, LINE6_BIT_CONTROL }, |
64 | { "PODStudioGX", "POD Studio GX", LINE6_BIT_PODSTUDIO_GX, LINE6_BIT_PCM }, | 64 | { "PODStudioGX", "POD Studio GX", LINE6_BIT_PODSTUDIO_GX, LINE6_BIT_PCM }, |
65 | { "PODStudioUX1", "POD Studio UX1", LINE6_BIT_PODSTUDIO_UX1, LINE6_BIT_PCM }, | 65 | { "PODStudioUX1", "POD Studio UX1", LINE6_BIT_PODSTUDIO_UX1, LINE6_BIT_PCM }, |
66 | { "PODStudioUX2", "POD Studio UX2", LINE6_BIT_PODSTUDIO_UX2, LINE6_BIT_PCM }, | 66 | { "PODStudioUX2", "POD Studio UX2", LINE6_BIT_PODSTUDIO_UX2, LINE6_BIT_PCM }, |
67 | { "PODX3", "POD X3", LINE6_BIT_PODX3, LINE6_BIT_PCM }, | 67 | { "PODX3", "POD X3", LINE6_BIT_PODX3, LINE6_BIT_PCM }, |
68 | { "PODX3Live", "POD X3 Live", LINE6_BIT_PODX3LIVE, LINE6_BIT_PCM }, | 68 | { "PODX3Live", "POD X3 Live", LINE6_BIT_PODX3LIVE, LINE6_BIT_PCM }, |
69 | { "PODxt", "PODxt", LINE6_BIT_PODXT, LINE6_BIT_CONTROL_PCM_HWMON }, | 69 | { "PODxt", "PODxt", LINE6_BIT_PODXT, LINE6_BIT_CONTROL_PCM_HWMON }, |
70 | { "PODxtLive", "PODxt Live", LINE6_BIT_PODXTLIVE, LINE6_BIT_CONTROL_PCM_HWMON }, | 70 | { "PODxtLive", "PODxt Live", LINE6_BIT_PODXTLIVE, LINE6_BIT_CONTROL_PCM_HWMON }, |
71 | { "PODxtPro", "PODxt Pro", LINE6_BIT_PODXTPRO, LINE6_BIT_CONTROL_PCM_HWMON }, | 71 | { "PODxtPro", "PODxt Pro", LINE6_BIT_PODXTPRO, LINE6_BIT_CONTROL_PCM_HWMON }, |
72 | { "TonePortGX", "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM }, | 72 | { "TonePortGX", "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM }, |
73 | { "TonePortUX1", "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM }, | 73 | { "TonePortUX1", "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM }, |
74 | { "TonePortUX2", "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM }, | 74 | { "TonePortUX2", "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM }, |
75 | { "Variax", "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL } | 75 | { "Variax", "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL } |
76 | }; | 76 | }; |
77 | /* *INDENT-ON* */ | 77 | /* *INDENT-ON* */ |
78 | 78 | ||
79 | /* | 79 | /* |
80 | This is Line6's MIDI manufacturer ID. | 80 | This is Line6's MIDI manufacturer ID. |
81 | */ | 81 | */ |
82 | const unsigned char line6_midi_id[] = { | 82 | const unsigned char line6_midi_id[] = { |
83 | 0x00, 0x01, 0x0c | 83 | 0x00, 0x01, 0x0c |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /* | 86 | /* |
87 | Code to request version of POD, Variax interface | 87 | Code to request version of POD, Variax interface |
88 | (and maybe other devices). | 88 | (and maybe other devices). |
89 | */ | 89 | */ |
90 | static const char line6_request_version0[] = { | 90 | static const char line6_request_version0[] = { |
91 | 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7 | 91 | 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7 |
92 | }; | 92 | }; |
93 | 93 | ||
94 | /* | 94 | /* |
95 | Copy of version request code with GFP_KERNEL flag for use in URB. | 95 | Copy of version request code with GFP_KERNEL flag for use in URB. |
96 | */ | 96 | */ |
97 | static const char *line6_request_version; | 97 | static const char *line6_request_version; |
98 | 98 | ||
99 | struct usb_line6 *line6_devices[LINE6_MAX_DEVICES]; | 99 | struct usb_line6 *line6_devices[LINE6_MAX_DEVICES]; |
100 | 100 | ||
101 | /** | 101 | /** |
102 | Class for asynchronous messages. | 102 | Class for asynchronous messages. |
103 | */ | 103 | */ |
104 | struct message { | 104 | struct message { |
105 | struct usb_line6 *line6; | 105 | struct usb_line6 *line6; |
106 | const char *buffer; | 106 | const char *buffer; |
107 | int size; | 107 | int size; |
108 | int done; | 108 | int done; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | /* | 111 | /* |
112 | Forward declarations. | 112 | Forward declarations. |
113 | */ | 113 | */ |
114 | static void line6_data_received(struct urb *urb); | 114 | static void line6_data_received(struct urb *urb); |
115 | static int line6_send_raw_message_async_part(struct message *msg, | 115 | static int line6_send_raw_message_async_part(struct message *msg, |
116 | struct urb *urb); | 116 | struct urb *urb); |
117 | 117 | ||
118 | /* | 118 | /* |
119 | Start to listen on endpoint. | 119 | Start to listen on endpoint. |
120 | */ | 120 | */ |
121 | static int line6_start_listen(struct usb_line6 *line6) | 121 | static int line6_start_listen(struct usb_line6 *line6) |
122 | { | 122 | { |
123 | int err; | 123 | int err; |
124 | usb_fill_int_urb(line6->urb_listen, line6->usbdev, | 124 | usb_fill_int_urb(line6->urb_listen, line6->usbdev, |
125 | usb_rcvintpipe(line6->usbdev, line6->ep_control_read), | 125 | usb_rcvintpipe(line6->usbdev, line6->ep_control_read), |
126 | line6->buffer_listen, LINE6_BUFSIZE_LISTEN, | 126 | line6->buffer_listen, LINE6_BUFSIZE_LISTEN, |
127 | line6_data_received, line6, line6->interval); | 127 | line6_data_received, line6, line6->interval); |
128 | line6->urb_listen->actual_length = 0; | 128 | line6->urb_listen->actual_length = 0; |
129 | err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC); | 129 | err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC); |
130 | return err; | 130 | return err; |
131 | } | 131 | } |
132 | 132 | ||
133 | /* | 133 | /* |
134 | Stop listening on endpoint. | 134 | Stop listening on endpoint. |
135 | */ | 135 | */ |
136 | static void line6_stop_listen(struct usb_line6 *line6) | 136 | static void line6_stop_listen(struct usb_line6 *line6) |
137 | { | 137 | { |
138 | usb_kill_urb(line6->urb_listen); | 138 | usb_kill_urb(line6->urb_listen); |
139 | } | 139 | } |
140 | 140 | ||
141 | #ifdef CONFIG_LINE6_USB_DUMP_ANY | 141 | #ifdef CONFIG_LINE6_USB_DUMP_ANY |
142 | /* | 142 | /* |
143 | Write hexdump to syslog. | 143 | Write hexdump to syslog. |
144 | */ | 144 | */ |
145 | void line6_write_hexdump(struct usb_line6 *line6, char dir, | 145 | void line6_write_hexdump(struct usb_line6 *line6, char dir, |
146 | const unsigned char *buffer, int size) | 146 | const unsigned char *buffer, int size) |
147 | { | 147 | { |
148 | static const int BYTES_PER_LINE = 8; | 148 | static const int BYTES_PER_LINE = 8; |
149 | char hexdump[100]; | 149 | char hexdump[100]; |
150 | char asc[BYTES_PER_LINE + 1]; | 150 | char asc[BYTES_PER_LINE + 1]; |
151 | int i, j; | 151 | int i, j; |
152 | 152 | ||
153 | for (i = 0; i < size; i += BYTES_PER_LINE) { | 153 | for (i = 0; i < size; i += BYTES_PER_LINE) { |
154 | int hexdumpsize = sizeof(hexdump); | 154 | int hexdumpsize = sizeof(hexdump); |
155 | char *p = hexdump; | 155 | char *p = hexdump; |
156 | int n = min(size - i, BYTES_PER_LINE); | 156 | int n = min(size - i, BYTES_PER_LINE); |
157 | asc[n] = 0; | 157 | asc[n] = 0; |
158 | 158 | ||
159 | for (j = 0; j < BYTES_PER_LINE; ++j) { | 159 | for (j = 0; j < BYTES_PER_LINE; ++j) { |
160 | int bytes; | 160 | int bytes; |
161 | 161 | ||
162 | if (j < n) { | 162 | if (j < n) { |
163 | unsigned char val = buffer[i + j]; | 163 | unsigned char val = buffer[i + j]; |
164 | bytes = snprintf(p, hexdumpsize, " %02X", val); | 164 | bytes = snprintf(p, hexdumpsize, " %02X", val); |
165 | asc[j] = ((val >= 0x20) | 165 | asc[j] = ((val >= 0x20) |
166 | && (val < 0x7f)) ? val : '.'; | 166 | && (val < 0x7f)) ? val : '.'; |
167 | } else | 167 | } else |
168 | bytes = snprintf(p, hexdumpsize, " "); | 168 | bytes = snprintf(p, hexdumpsize, " "); |
169 | 169 | ||
170 | if (bytes > hexdumpsize) | 170 | if (bytes > hexdumpsize) |
171 | break; /* buffer overflow */ | 171 | break; /* buffer overflow */ |
172 | 172 | ||
173 | p += bytes; | 173 | p += bytes; |
174 | hexdumpsize -= bytes; | 174 | hexdumpsize -= bytes; |
175 | } | 175 | } |
176 | 176 | ||
177 | dev_info(line6->ifcdev, "%c%04X:%s %s\n", dir, i, hexdump, asc); | 177 | dev_info(line6->ifcdev, "%c%04X:%s %s\n", dir, i, hexdump, asc); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL | 182 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL |
183 | /* | 183 | /* |
184 | Dump URB data to syslog. | 184 | Dump URB data to syslog. |
185 | */ | 185 | */ |
186 | static void line6_dump_urb(struct urb *urb) | 186 | static void line6_dump_urb(struct urb *urb) |
187 | { | 187 | { |
188 | struct usb_line6 *line6 = (struct usb_line6 *)urb->context; | 188 | struct usb_line6 *line6 = (struct usb_line6 *)urb->context; |
189 | 189 | ||
190 | if (urb->status < 0) | 190 | if (urb->status < 0) |
191 | return; | 191 | return; |
192 | 192 | ||
193 | line6_write_hexdump(line6, 'R', (unsigned char *)urb->transfer_buffer, | 193 | line6_write_hexdump(line6, 'R', (unsigned char *)urb->transfer_buffer, |
194 | urb->actual_length); | 194 | urb->actual_length); |
195 | } | 195 | } |
196 | #endif | 196 | #endif |
197 | 197 | ||
198 | /* | 198 | /* |
199 | Send raw message in pieces of wMaxPacketSize bytes. | 199 | Send raw message in pieces of wMaxPacketSize bytes. |
200 | */ | 200 | */ |
201 | int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, | 201 | int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, |
202 | int size) | 202 | int size) |
203 | { | 203 | { |
204 | int i, done = 0; | 204 | int i, done = 0; |
205 | 205 | ||
206 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL | 206 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL |
207 | line6_write_hexdump(line6, 'S', buffer, size); | 207 | line6_write_hexdump(line6, 'S', buffer, size); |
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | for (i = 0; i < size; i += line6->max_packet_size) { | 210 | for (i = 0; i < size; i += line6->max_packet_size) { |
211 | int partial; | 211 | int partial; |
212 | const char *frag_buf = buffer + i; | 212 | const char *frag_buf = buffer + i; |
213 | int frag_size = min(line6->max_packet_size, size - i); | 213 | int frag_size = min(line6->max_packet_size, size - i); |
214 | int retval; | 214 | int retval; |
215 | 215 | ||
216 | retval = usb_interrupt_msg(line6->usbdev, | 216 | retval = usb_interrupt_msg(line6->usbdev, |
217 | usb_sndintpipe(line6->usbdev, | 217 | usb_sndintpipe(line6->usbdev, |
218 | line6->ep_control_write), | 218 | line6->ep_control_write), |
219 | (char *)frag_buf, frag_size, | 219 | (char *)frag_buf, frag_size, |
220 | &partial, LINE6_TIMEOUT * HZ); | 220 | &partial, LINE6_TIMEOUT * HZ); |
221 | 221 | ||
222 | if (retval) { | 222 | if (retval) { |
223 | dev_err(line6->ifcdev, | 223 | dev_err(line6->ifcdev, |
224 | "usb_interrupt_msg failed (%d)\n", retval); | 224 | "usb_interrupt_msg failed (%d)\n", retval); |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | done += frag_size; | 228 | done += frag_size; |
229 | } | 229 | } |
230 | 230 | ||
231 | return done; | 231 | return done; |
232 | } | 232 | } |
233 | 233 | ||
234 | /* | 234 | /* |
235 | Notification of completion of asynchronous request transmission. | 235 | Notification of completion of asynchronous request transmission. |
236 | */ | 236 | */ |
237 | static void line6_async_request_sent(struct urb *urb) | 237 | static void line6_async_request_sent(struct urb *urb) |
238 | { | 238 | { |
239 | struct message *msg = (struct message *)urb->context; | 239 | struct message *msg = (struct message *)urb->context; |
240 | 240 | ||
241 | if (msg->done >= msg->size) { | 241 | if (msg->done >= msg->size) { |
242 | usb_free_urb(urb); | 242 | usb_free_urb(urb); |
243 | kfree(msg); | 243 | kfree(msg); |
244 | } else | 244 | } else |
245 | line6_send_raw_message_async_part(msg, urb); | 245 | line6_send_raw_message_async_part(msg, urb); |
246 | } | 246 | } |
247 | 247 | ||
248 | /* | 248 | /* |
249 | Asynchronously send part of a raw message. | 249 | Asynchronously send part of a raw message. |
250 | */ | 250 | */ |
251 | static int line6_send_raw_message_async_part(struct message *msg, | 251 | static int line6_send_raw_message_async_part(struct message *msg, |
252 | struct urb *urb) | 252 | struct urb *urb) |
253 | { | 253 | { |
254 | int retval; | 254 | int retval; |
255 | struct usb_line6 *line6 = msg->line6; | 255 | struct usb_line6 *line6 = msg->line6; |
256 | int done = msg->done; | 256 | int done = msg->done; |
257 | int bytes = min(msg->size - done, line6->max_packet_size); | 257 | int bytes = min(msg->size - done, line6->max_packet_size); |
258 | 258 | ||
259 | usb_fill_int_urb(urb, line6->usbdev, | 259 | usb_fill_int_urb(urb, line6->usbdev, |
260 | usb_sndintpipe(line6->usbdev, line6->ep_control_write), | 260 | usb_sndintpipe(line6->usbdev, line6->ep_control_write), |
261 | (char *)msg->buffer + done, bytes, | 261 | (char *)msg->buffer + done, bytes, |
262 | line6_async_request_sent, msg, line6->interval); | 262 | line6_async_request_sent, msg, line6->interval); |
263 | 263 | ||
264 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL | 264 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL |
265 | line6_write_hexdump(line6, 'S', (char *)msg->buffer + done, bytes); | 265 | line6_write_hexdump(line6, 'S', (char *)msg->buffer + done, bytes); |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | msg->done += bytes; | 268 | msg->done += bytes; |
269 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 269 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
270 | 270 | ||
271 | if (retval < 0) { | 271 | if (retval < 0) { |
272 | dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n", | 272 | dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n", |
273 | __func__, retval); | 273 | __func__, retval); |
274 | usb_free_urb(urb); | 274 | usb_free_urb(urb); |
275 | kfree(msg); | 275 | kfree(msg); |
276 | return -EINVAL; | 276 | return -EINVAL; |
277 | } | 277 | } |
278 | 278 | ||
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | /* | 282 | /* |
283 | Setup and start timer. | 283 | Setup and start timer. |
284 | */ | 284 | */ |
285 | void line6_start_timer(struct timer_list *timer, unsigned int msecs, | 285 | void line6_start_timer(struct timer_list *timer, unsigned int msecs, |
286 | void (*function) (unsigned long), unsigned long data) | 286 | void (*function) (unsigned long), unsigned long data) |
287 | { | 287 | { |
288 | setup_timer(timer, function, data); | 288 | setup_timer(timer, function, data); |
289 | timer->expires = jiffies + msecs * HZ / 1000; | 289 | timer->expires = jiffies + msecs * HZ / 1000; |
290 | add_timer(timer); | 290 | add_timer(timer); |
291 | } | 291 | } |
292 | 292 | ||
293 | /* | 293 | /* |
294 | Asynchronously send raw message. | 294 | Asynchronously send raw message. |
295 | */ | 295 | */ |
296 | int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, | 296 | int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, |
297 | int size) | 297 | int size) |
298 | { | 298 | { |
299 | struct message *msg; | 299 | struct message *msg; |
300 | struct urb *urb; | 300 | struct urb *urb; |
301 | 301 | ||
302 | /* create message: */ | 302 | /* create message: */ |
303 | msg = kmalloc(sizeof(struct message), GFP_ATOMIC); | 303 | msg = kmalloc(sizeof(struct message), GFP_ATOMIC); |
304 | 304 | ||
305 | if (msg == NULL) { | 305 | if (msg == NULL) { |
306 | dev_err(line6->ifcdev, "Out of memory\n"); | 306 | dev_err(line6->ifcdev, "Out of memory\n"); |
307 | return -ENOMEM; | 307 | return -ENOMEM; |
308 | } | 308 | } |
309 | 309 | ||
310 | /* create URB: */ | 310 | /* create URB: */ |
311 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 311 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
312 | 312 | ||
313 | if (urb == NULL) { | 313 | if (urb == NULL) { |
314 | kfree(msg); | 314 | kfree(msg); |
315 | dev_err(line6->ifcdev, "Out of memory\n"); | 315 | dev_err(line6->ifcdev, "Out of memory\n"); |
316 | return -ENOMEM; | 316 | return -ENOMEM; |
317 | } | 317 | } |
318 | 318 | ||
319 | /* set message data: */ | 319 | /* set message data: */ |
320 | msg->line6 = line6; | 320 | msg->line6 = line6; |
321 | msg->buffer = buffer; | 321 | msg->buffer = buffer; |
322 | msg->size = size; | 322 | msg->size = size; |
323 | msg->done = 0; | 323 | msg->done = 0; |
324 | 324 | ||
325 | /* start sending: */ | 325 | /* start sending: */ |
326 | return line6_send_raw_message_async_part(msg, urb); | 326 | return line6_send_raw_message_async_part(msg, urb); |
327 | } | 327 | } |
328 | 328 | ||
329 | /* | 329 | /* |
330 | Send asynchronous device version request. | 330 | Send asynchronous device version request. |
331 | */ | 331 | */ |
332 | int line6_version_request_async(struct usb_line6 *line6) | 332 | int line6_version_request_async(struct usb_line6 *line6) |
333 | { | 333 | { |
334 | return line6_send_raw_message_async(line6, line6_request_version, | 334 | return line6_send_raw_message_async(line6, line6_request_version, |
335 | sizeof(line6_request_version0)); | 335 | sizeof(line6_request_version0)); |
336 | } | 336 | } |
337 | 337 | ||
338 | /* | 338 | /* |
339 | Send sysex message in pieces of wMaxPacketSize bytes. | 339 | Send sysex message in pieces of wMaxPacketSize bytes. |
340 | */ | 340 | */ |
341 | int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, | 341 | int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, |
342 | int size) | 342 | int size) |
343 | { | 343 | { |
344 | return line6_send_raw_message(line6, buffer, | 344 | return line6_send_raw_message(line6, buffer, |
345 | size + SYSEX_EXTRA_SIZE) - | 345 | size + SYSEX_EXTRA_SIZE) - |
346 | SYSEX_EXTRA_SIZE; | 346 | SYSEX_EXTRA_SIZE; |
347 | } | 347 | } |
348 | 348 | ||
349 | /* | 349 | /* |
350 | Send sysex message in pieces of wMaxPacketSize bytes. | 350 | Send sysex message in pieces of wMaxPacketSize bytes. |
351 | */ | 351 | */ |
352 | int line6_send_sysex_message_async(struct usb_line6 *line6, const char *buffer, | 352 | int line6_send_sysex_message_async(struct usb_line6 *line6, const char *buffer, |
353 | int size) | 353 | int size) |
354 | { | 354 | { |
355 | return line6_send_raw_message_async(line6, buffer, | 355 | return line6_send_raw_message_async(line6, buffer, |
356 | size + SYSEX_EXTRA_SIZE) - | 356 | size + SYSEX_EXTRA_SIZE) - |
357 | SYSEX_EXTRA_SIZE; | 357 | SYSEX_EXTRA_SIZE; |
358 | } | 358 | } |
359 | 359 | ||
360 | /* | 360 | /* |
361 | Allocate buffer for sysex message and prepare header. | 361 | Allocate buffer for sysex message and prepare header. |
362 | @param code sysex message code | 362 | @param code sysex message code |
363 | @param size number of bytes between code and sysex end | 363 | @param size number of bytes between code and sysex end |
364 | */ | 364 | */ |
365 | char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, | 365 | char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, |
366 | int size) | 366 | int size) |
367 | { | 367 | { |
368 | char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC); | 368 | char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC); |
369 | 369 | ||
370 | if (!buffer) { | 370 | if (!buffer) { |
371 | dev_err(line6->ifcdev, "out of memory\n"); | 371 | dev_err(line6->ifcdev, "out of memory\n"); |
372 | return NULL; | 372 | return NULL; |
373 | } | 373 | } |
374 | 374 | ||
375 | buffer[0] = LINE6_SYSEX_BEGIN; | 375 | buffer[0] = LINE6_SYSEX_BEGIN; |
376 | memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id)); | 376 | memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id)); |
377 | buffer[sizeof(line6_midi_id) + 1] = code1; | 377 | buffer[sizeof(line6_midi_id) + 1] = code1; |
378 | buffer[sizeof(line6_midi_id) + 2] = code2; | 378 | buffer[sizeof(line6_midi_id) + 2] = code2; |
379 | buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END; | 379 | buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END; |
380 | return buffer; | 380 | return buffer; |
381 | } | 381 | } |
382 | 382 | ||
383 | /* | 383 | /* |
384 | Notification of data received from the Line6 device. | 384 | Notification of data received from the Line6 device. |
385 | */ | 385 | */ |
386 | static void line6_data_received(struct urb *urb) | 386 | static void line6_data_received(struct urb *urb) |
387 | { | 387 | { |
388 | struct usb_line6 *line6 = (struct usb_line6 *)urb->context; | 388 | struct usb_line6 *line6 = (struct usb_line6 *)urb->context; |
389 | struct MidiBuffer *mb = &line6->line6midi->midibuf_in; | 389 | struct MidiBuffer *mb = &line6->line6midi->midibuf_in; |
390 | int done; | 390 | int done; |
391 | 391 | ||
392 | if (urb->status == -ESHUTDOWN) | 392 | if (urb->status == -ESHUTDOWN) |
393 | return; | 393 | return; |
394 | 394 | ||
395 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL | 395 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL |
396 | line6_dump_urb(urb); | 396 | line6_dump_urb(urb); |
397 | #endif | 397 | #endif |
398 | 398 | ||
399 | done = | 399 | done = |
400 | line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length); | 400 | line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length); |
401 | 401 | ||
402 | if (done < urb->actual_length) { | 402 | if (done < urb->actual_length) { |
403 | line6_midibuf_ignore(mb, done); | 403 | line6_midibuf_ignore(mb, done); |
404 | DEBUG_MESSAGES(dev_err | 404 | DEBUG_MESSAGES(dev_err |
405 | (line6->ifcdev, | 405 | (line6->ifcdev, |
406 | "%d %d buffer overflow - message skipped\n", | 406 | "%d %d buffer overflow - message skipped\n", |
407 | done, urb->actual_length)); | 407 | done, urb->actual_length)); |
408 | } | 408 | } |
409 | 409 | ||
410 | for (;;) { | 410 | for (;;) { |
411 | done = | 411 | done = |
412 | line6_midibuf_read(mb, line6->buffer_message, | 412 | line6_midibuf_read(mb, line6->buffer_message, |
413 | LINE6_MESSAGE_MAXLEN); | 413 | LINE6_MESSAGE_MAXLEN); |
414 | 414 | ||
415 | if (done == 0) | 415 | if (done == 0) |
416 | break; | 416 | break; |
417 | 417 | ||
418 | /* MIDI input filter */ | 418 | /* MIDI input filter */ |
419 | if (line6_midibuf_skip_message | 419 | if (line6_midibuf_skip_message |
420 | (mb, line6->line6midi->midi_mask_receive)) | 420 | (mb, line6->line6midi->midi_mask_receive)) |
421 | continue; | 421 | continue; |
422 | 422 | ||
423 | line6->message_length = done; | 423 | line6->message_length = done; |
424 | #ifdef CONFIG_LINE6_USB_DUMP_MIDI | 424 | #ifdef CONFIG_LINE6_USB_DUMP_MIDI |
425 | line6_write_hexdump(line6, 'r', line6->buffer_message, done); | 425 | line6_write_hexdump(line6, 'r', line6->buffer_message, done); |
426 | #endif | 426 | #endif |
427 | line6_midi_receive(line6, line6->buffer_message, done); | 427 | line6_midi_receive(line6, line6->buffer_message, done); |
428 | 428 | ||
429 | switch (line6->usbdev->descriptor.idProduct) { | 429 | switch (line6->usbdev->descriptor.idProduct) { |
430 | case LINE6_DEVID_BASSPODXT: | 430 | case LINE6_DEVID_BASSPODXT: |
431 | case LINE6_DEVID_BASSPODXTLIVE: | 431 | case LINE6_DEVID_BASSPODXTLIVE: |
432 | case LINE6_DEVID_BASSPODXTPRO: | 432 | case LINE6_DEVID_BASSPODXTPRO: |
433 | case LINE6_DEVID_PODXT: | 433 | case LINE6_DEVID_PODXT: |
434 | case LINE6_DEVID_PODXTPRO: | 434 | case LINE6_DEVID_PODXTPRO: |
435 | case LINE6_DEVID_POCKETPOD: | 435 | case LINE6_DEVID_POCKETPOD: |
436 | line6_pod_process_message((struct usb_line6_pod *) | 436 | line6_pod_process_message((struct usb_line6_pod *) |
437 | line6); | 437 | line6); |
438 | break; | 438 | break; |
439 | 439 | ||
440 | case LINE6_DEVID_PODXTLIVE: | 440 | case LINE6_DEVID_PODXTLIVE: |
441 | switch (line6->interface_number) { | 441 | switch (line6->interface_number) { |
442 | case PODXTLIVE_INTERFACE_POD: | 442 | case PODXTLIVE_INTERFACE_POD: |
443 | line6_pod_process_message((struct usb_line6_pod | 443 | line6_pod_process_message((struct usb_line6_pod |
444 | *)line6); | 444 | *)line6); |
445 | break; | 445 | break; |
446 | 446 | ||
447 | case PODXTLIVE_INTERFACE_VARIAX: | 447 | case PODXTLIVE_INTERFACE_VARIAX: |
448 | line6_variax_process_message((struct | 448 | line6_variax_process_message((struct |
449 | usb_line6_variax | 449 | usb_line6_variax |
450 | *)line6); | 450 | *)line6); |
451 | break; | 451 | break; |
452 | 452 | ||
453 | default: | 453 | default: |
454 | dev_err(line6->ifcdev, | 454 | dev_err(line6->ifcdev, |
455 | "PODxt Live interface %d not supported\n", | 455 | "PODxt Live interface %d not supported\n", |
456 | line6->interface_number); | 456 | line6->interface_number); |
457 | } | 457 | } |
458 | break; | 458 | break; |
459 | 459 | ||
460 | case LINE6_DEVID_VARIAX: | 460 | case LINE6_DEVID_VARIAX: |
461 | line6_variax_process_message((struct usb_line6_variax *) | 461 | line6_variax_process_message((struct usb_line6_variax *) |
462 | line6); | 462 | line6); |
463 | break; | 463 | break; |
464 | 464 | ||
465 | default: | 465 | default: |
466 | MISSING_CASE; | 466 | MISSING_CASE; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | line6_start_listen(line6); | 470 | line6_start_listen(line6); |
471 | } | 471 | } |
472 | 472 | ||
473 | /* | 473 | /* |
474 | Send channel number (i.e., switch to a different sound). | 474 | Send channel number (i.e., switch to a different sound). |
475 | */ | 475 | */ |
476 | int line6_send_program(struct usb_line6 *line6, int value) | 476 | int line6_send_program(struct usb_line6 *line6, int value) |
477 | { | 477 | { |
478 | int retval; | 478 | int retval; |
479 | unsigned char *buffer; | 479 | unsigned char *buffer; |
480 | int partial; | 480 | int partial; |
481 | 481 | ||
482 | buffer = kmalloc(2, GFP_KERNEL); | 482 | buffer = kmalloc(2, GFP_KERNEL); |
483 | 483 | ||
484 | if (!buffer) { | 484 | if (!buffer) { |
485 | dev_err(line6->ifcdev, "out of memory\n"); | 485 | dev_err(line6->ifcdev, "out of memory\n"); |
486 | return -ENOMEM; | 486 | return -ENOMEM; |
487 | } | 487 | } |
488 | 488 | ||
489 | buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST; | 489 | buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST; |
490 | buffer[1] = value; | 490 | buffer[1] = value; |
491 | 491 | ||
492 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL | 492 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL |
493 | line6_write_hexdump(line6, 'S', buffer, 2); | 493 | line6_write_hexdump(line6, 'S', buffer, 2); |
494 | #endif | 494 | #endif |
495 | 495 | ||
496 | retval = usb_interrupt_msg(line6->usbdev, | 496 | retval = usb_interrupt_msg(line6->usbdev, |
497 | usb_sndintpipe(line6->usbdev, | 497 | usb_sndintpipe(line6->usbdev, |
498 | line6->ep_control_write), | 498 | line6->ep_control_write), |
499 | buffer, 2, &partial, LINE6_TIMEOUT * HZ); | 499 | buffer, 2, &partial, LINE6_TIMEOUT * HZ); |
500 | 500 | ||
501 | if (retval) | 501 | if (retval) |
502 | dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", | 502 | dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", |
503 | retval); | 503 | retval); |
504 | 504 | ||
505 | kfree(buffer); | 505 | kfree(buffer); |
506 | return retval; | 506 | return retval; |
507 | } | 507 | } |
508 | 508 | ||
509 | /* | 509 | /* |
510 | Transmit Line6 control parameter. | 510 | Transmit Line6 control parameter. |
511 | */ | 511 | */ |
512 | int line6_transmit_parameter(struct usb_line6 *line6, int param, int value) | 512 | int line6_transmit_parameter(struct usb_line6 *line6, int param, int value) |
513 | { | 513 | { |
514 | int retval; | 514 | int retval; |
515 | unsigned char *buffer; | 515 | unsigned char *buffer; |
516 | int partial; | 516 | int partial; |
517 | 517 | ||
518 | buffer = kmalloc(3, GFP_KERNEL); | 518 | buffer = kmalloc(3, GFP_KERNEL); |
519 | 519 | ||
520 | if (!buffer) { | 520 | if (!buffer) { |
521 | dev_err(line6->ifcdev, "out of memory\n"); | 521 | dev_err(line6->ifcdev, "out of memory\n"); |
522 | return -ENOMEM; | 522 | return -ENOMEM; |
523 | } | 523 | } |
524 | 524 | ||
525 | buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST; | 525 | buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST; |
526 | buffer[1] = param; | 526 | buffer[1] = param; |
527 | buffer[2] = value; | 527 | buffer[2] = value; |
528 | 528 | ||
529 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL | 529 | #ifdef CONFIG_LINE6_USB_DUMP_CTRL |
530 | line6_write_hexdump(line6, 'S', buffer, 3); | 530 | line6_write_hexdump(line6, 'S', buffer, 3); |
531 | #endif | 531 | #endif |
532 | 532 | ||
533 | retval = usb_interrupt_msg(line6->usbdev, | 533 | retval = usb_interrupt_msg(line6->usbdev, |
534 | usb_sndintpipe(line6->usbdev, | 534 | usb_sndintpipe(line6->usbdev, |
535 | line6->ep_control_write), | 535 | line6->ep_control_write), |
536 | buffer, 3, &partial, LINE6_TIMEOUT * HZ); | 536 | buffer, 3, &partial, LINE6_TIMEOUT * HZ); |
537 | 537 | ||
538 | if (retval) | 538 | if (retval) |
539 | dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", | 539 | dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", |
540 | retval); | 540 | retval); |
541 | 541 | ||
542 | kfree(buffer); | 542 | kfree(buffer); |
543 | return retval; | 543 | return retval; |
544 | } | 544 | } |
545 | 545 | ||
546 | /* | 546 | /* |
547 | Read data from device. | 547 | Read data from device. |
548 | */ | 548 | */ |
549 | int line6_read_data(struct usb_line6 *line6, int address, void *data, | 549 | int line6_read_data(struct usb_line6 *line6, int address, void *data, |
550 | size_t datalen) | 550 | size_t datalen) |
551 | { | 551 | { |
552 | struct usb_device *usbdev = line6->usbdev; | 552 | struct usb_device *usbdev = line6->usbdev; |
553 | int ret; | 553 | int ret; |
554 | unsigned char len; | 554 | unsigned char len; |
555 | 555 | ||
556 | /* query the serial number: */ | 556 | /* query the serial number: */ |
557 | ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, | 557 | ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, |
558 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, | 558 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
559 | (datalen << 8) | 0x21, address, | 559 | (datalen << 8) | 0x21, address, |
560 | NULL, 0, LINE6_TIMEOUT * HZ); | 560 | NULL, 0, LINE6_TIMEOUT * HZ); |
561 | 561 | ||
562 | if (ret < 0) { | 562 | if (ret < 0) { |
563 | dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); | 563 | dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); |
564 | return ret; | 564 | return ret; |
565 | } | 565 | } |
566 | 566 | ||
567 | /* Wait for data length. We'll get a couple of 0xff until length arrives. */ | 567 | /* Wait for data length. We'll get a couple of 0xff until length arrives. */ |
568 | do { | 568 | do { |
569 | ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, | 569 | ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, |
570 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | | 570 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | |
571 | USB_DIR_IN, | 571 | USB_DIR_IN, |
572 | 0x0012, 0x0000, &len, 1, | 572 | 0x0012, 0x0000, &len, 1, |
573 | LINE6_TIMEOUT * HZ); | 573 | LINE6_TIMEOUT * HZ); |
574 | if (ret < 0) { | 574 | if (ret < 0) { |
575 | dev_err(line6->ifcdev, | 575 | dev_err(line6->ifcdev, |
576 | "receive length failed (error %d)\n", ret); | 576 | "receive length failed (error %d)\n", ret); |
577 | return ret; | 577 | return ret; |
578 | } | 578 | } |
579 | } while (len == 0xff); | 579 | } while (len == 0xff); |
580 | 580 | ||
581 | if (len != datalen) { | 581 | if (len != datalen) { |
582 | /* should be equal or something went wrong */ | 582 | /* should be equal or something went wrong */ |
583 | dev_err(line6->ifcdev, | 583 | dev_err(line6->ifcdev, |
584 | "length mismatch (expected %d, got %d)\n", | 584 | "length mismatch (expected %d, got %d)\n", |
585 | (int)datalen, (int)len); | 585 | (int)datalen, (int)len); |
586 | return -EINVAL; | 586 | return -EINVAL; |
587 | } | 587 | } |
588 | 588 | ||
589 | /* receive the result: */ | 589 | /* receive the result: */ |
590 | ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, | 590 | ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, |
591 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, | 591 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, |
592 | 0x0013, 0x0000, data, datalen, | 592 | 0x0013, 0x0000, data, datalen, |
593 | LINE6_TIMEOUT * HZ); | 593 | LINE6_TIMEOUT * HZ); |
594 | 594 | ||
595 | if (ret < 0) { | 595 | if (ret < 0) { |
596 | dev_err(line6->ifcdev, "read failed (error %d)\n", ret); | 596 | dev_err(line6->ifcdev, "read failed (error %d)\n", ret); |
597 | return ret; | 597 | return ret; |
598 | } | 598 | } |
599 | 599 | ||
600 | return 0; | 600 | return 0; |
601 | } | 601 | } |
602 | 602 | ||
603 | /* | 603 | /* |
604 | Write data to device. | 604 | Write data to device. |
605 | */ | 605 | */ |
606 | int line6_write_data(struct usb_line6 *line6, int address, void *data, | 606 | int line6_write_data(struct usb_line6 *line6, int address, void *data, |
607 | size_t datalen) | 607 | size_t datalen) |
608 | { | 608 | { |
609 | struct usb_device *usbdev = line6->usbdev; | 609 | struct usb_device *usbdev = line6->usbdev; |
610 | int ret; | 610 | int ret; |
611 | unsigned char status; | 611 | unsigned char status; |
612 | 612 | ||
613 | ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, | 613 | ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, |
614 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, | 614 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
615 | 0x0022, address, data, datalen, | 615 | 0x0022, address, data, datalen, |
616 | LINE6_TIMEOUT * HZ); | 616 | LINE6_TIMEOUT * HZ); |
617 | 617 | ||
618 | if (ret < 0) { | 618 | if (ret < 0) { |
619 | dev_err(line6->ifcdev, | 619 | dev_err(line6->ifcdev, |
620 | "write request failed (error %d)\n", ret); | 620 | "write request failed (error %d)\n", ret); |
621 | return ret; | 621 | return ret; |
622 | } | 622 | } |
623 | 623 | ||
624 | do { | 624 | do { |
625 | ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), | 625 | ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), |
626 | 0x67, | 626 | 0x67, |
627 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | | 627 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | |
628 | USB_DIR_IN, | 628 | USB_DIR_IN, |
629 | 0x0012, 0x0000, | 629 | 0x0012, 0x0000, |
630 | &status, 1, LINE6_TIMEOUT * HZ); | 630 | &status, 1, LINE6_TIMEOUT * HZ); |
631 | 631 | ||
632 | if (ret < 0) { | 632 | if (ret < 0) { |
633 | dev_err(line6->ifcdev, | 633 | dev_err(line6->ifcdev, |
634 | "receiving status failed (error %d)\n", ret); | 634 | "receiving status failed (error %d)\n", ret); |
635 | return ret; | 635 | return ret; |
636 | } | 636 | } |
637 | } while (status == 0xff); | 637 | } while (status == 0xff); |
638 | 638 | ||
639 | if (status != 0) { | 639 | if (status != 0) { |
640 | dev_err(line6->ifcdev, "write failed (error %d)\n", ret); | 640 | dev_err(line6->ifcdev, "write failed (error %d)\n", ret); |
641 | return -EINVAL; | 641 | return -EINVAL; |
642 | } | 642 | } |
643 | 643 | ||
644 | return 0; | 644 | return 0; |
645 | } | 645 | } |
646 | 646 | ||
647 | /* | 647 | /* |
648 | Read Line6 device serial number. | 648 | Read Line6 device serial number. |
649 | (POD, TonePort, GuitarPort) | 649 | (POD, TonePort, GuitarPort) |
650 | */ | 650 | */ |
651 | int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) | 651 | int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) |
652 | { | 652 | { |
653 | return line6_read_data(line6, 0x80d0, serial_number, | 653 | return line6_read_data(line6, 0x80d0, serial_number, |
654 | sizeof(*serial_number)); | 654 | sizeof(*serial_number)); |
655 | } | 655 | } |
656 | 656 | ||
657 | /* | 657 | /* |
658 | No operation (i.e., unsupported). | 658 | No operation (i.e., unsupported). |
659 | */ | 659 | */ |
660 | ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, | 660 | ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, |
661 | char *buf) | 661 | char *buf) |
662 | { | 662 | { |
663 | return 0; | 663 | return 0; |
664 | } | 664 | } |
665 | 665 | ||
666 | /* | 666 | /* |
667 | No operation (i.e., unsupported). | 667 | No operation (i.e., unsupported). |
668 | */ | 668 | */ |
669 | ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr, | 669 | ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr, |
670 | const char *buf, size_t count) | 670 | const char *buf, size_t count) |
671 | { | 671 | { |
672 | return count; | 672 | return count; |
673 | } | 673 | } |
674 | 674 | ||
675 | /* | 675 | /* |
676 | "write" request on "raw" special file. | 676 | "write" request on "raw" special file. |
677 | */ | 677 | */ |
678 | #ifdef CONFIG_LINE6_USB_RAW | 678 | #ifdef CONFIG_LINE6_USB_RAW |
679 | ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, | 679 | ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, |
680 | const char *buf, size_t count) | 680 | const char *buf, size_t count) |
681 | { | 681 | { |
682 | struct usb_interface *interface = to_usb_interface(dev); | 682 | struct usb_interface *interface = to_usb_interface(dev); |
683 | struct usb_line6 *line6 = usb_get_intfdata(interface); | 683 | struct usb_line6 *line6 = usb_get_intfdata(interface); |
684 | line6_send_raw_message(line6, buf, count); | 684 | line6_send_raw_message(line6, buf, count); |
685 | return count; | 685 | return count; |
686 | } | 686 | } |
687 | #endif | 687 | #endif |
688 | 688 | ||
689 | /* | 689 | /* |
690 | Generic destructor. | 690 | Generic destructor. |
691 | */ | 691 | */ |
692 | static void line6_destruct(struct usb_interface *interface) | 692 | static void line6_destruct(struct usb_interface *interface) |
693 | { | 693 | { |
694 | struct usb_line6 *line6; | 694 | struct usb_line6 *line6; |
695 | 695 | ||
696 | if (interface == NULL) | 696 | if (interface == NULL) |
697 | return; | 697 | return; |
698 | line6 = usb_get_intfdata(interface); | 698 | line6 = usb_get_intfdata(interface); |
699 | if (line6 == NULL) | 699 | if (line6 == NULL) |
700 | return; | 700 | return; |
701 | 701 | ||
702 | /* free buffer memory first: */ | 702 | /* free buffer memory first: */ |
703 | kfree(line6->buffer_message); | 703 | kfree(line6->buffer_message); |
704 | kfree(line6->buffer_listen); | 704 | kfree(line6->buffer_listen); |
705 | 705 | ||
706 | /* then free URBs: */ | 706 | /* then free URBs: */ |
707 | usb_free_urb(line6->urb_listen); | 707 | usb_free_urb(line6->urb_listen); |
708 | 708 | ||
709 | /* make sure the device isn't destructed twice: */ | 709 | /* make sure the device isn't destructed twice: */ |
710 | usb_set_intfdata(interface, NULL); | 710 | usb_set_intfdata(interface, NULL); |
711 | 711 | ||
712 | /* free interface data: */ | 712 | /* free interface data: */ |
713 | kfree(line6); | 713 | kfree(line6); |
714 | } | 714 | } |
715 | 715 | ||
716 | /* | 716 | /* |
717 | Probe USB device. | 717 | Probe USB device. |
718 | */ | 718 | */ |
719 | static int line6_probe(struct usb_interface *interface, | 719 | static int line6_probe(struct usb_interface *interface, |
720 | const struct usb_device_id *id) | 720 | const struct usb_device_id *id) |
721 | { | 721 | { |
722 | int devtype; | 722 | int devtype; |
723 | struct usb_device *usbdev = NULL; | 723 | struct usb_device *usbdev = NULL; |
724 | struct usb_line6 *line6 = NULL; | 724 | struct usb_line6 *line6 = NULL; |
725 | const struct line6_properties *properties; | 725 | const struct line6_properties *properties; |
726 | int devnum; | 726 | int devnum; |
727 | int interface_number, alternate = 0; | 727 | int interface_number, alternate = 0; |
728 | int product; | 728 | int product; |
729 | int size = 0; | 729 | int size = 0; |
730 | int ep_read = 0, ep_write = 0; | 730 | int ep_read = 0, ep_write = 0; |
731 | int ret; | 731 | int ret; |
732 | 732 | ||
733 | if (interface == NULL) | 733 | if (interface == NULL) |
734 | return -ENODEV; | 734 | return -ENODEV; |
735 | usbdev = interface_to_usbdev(interface); | 735 | usbdev = interface_to_usbdev(interface); |
736 | if (usbdev == NULL) | 736 | if (usbdev == NULL) |
737 | return -ENODEV; | 737 | return -ENODEV; |
738 | 738 | ||
739 | /* we don't handle multiple configurations */ | 739 | /* we don't handle multiple configurations */ |
740 | if (usbdev->descriptor.bNumConfigurations != 1) { | 740 | if (usbdev->descriptor.bNumConfigurations != 1) { |
741 | ret = -ENODEV; | 741 | ret = -ENODEV; |
742 | goto err_put; | 742 | goto err_put; |
743 | } | 743 | } |
744 | 744 | ||
745 | /* check vendor and product id */ | 745 | /* check vendor and product id */ |
746 | for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) { | 746 | for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) { |
747 | u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor); | 747 | u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor); |
748 | u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct); | 748 | u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct); |
749 | 749 | ||
750 | if (idVendor == line6_id_table[devtype].idVendor && | 750 | if (idVendor == line6_id_table[devtype].idVendor && |
751 | idProduct == line6_id_table[devtype].idProduct) | 751 | idProduct == line6_id_table[devtype].idProduct) |
752 | break; | 752 | break; |
753 | } | 753 | } |
754 | 754 | ||
755 | if (devtype < 0) { | 755 | if (devtype < 0) { |
756 | ret = -ENODEV; | 756 | ret = -ENODEV; |
757 | goto err_put; | 757 | goto err_put; |
758 | } | 758 | } |
759 | 759 | ||
760 | /* find free slot in device table: */ | 760 | /* find free slot in device table: */ |
761 | for (devnum = 0; devnum < LINE6_MAX_DEVICES; ++devnum) | 761 | for (devnum = 0; devnum < LINE6_MAX_DEVICES; ++devnum) |
762 | if (line6_devices[devnum] == NULL) | 762 | if (line6_devices[devnum] == NULL) |
763 | break; | 763 | break; |
764 | 764 | ||
765 | if (devnum == LINE6_MAX_DEVICES) { | 765 | if (devnum == LINE6_MAX_DEVICES) { |
766 | ret = -ENODEV; | 766 | ret = -ENODEV; |
767 | goto err_put; | 767 | goto err_put; |
768 | } | 768 | } |
769 | 769 | ||
770 | /* initialize device info: */ | 770 | /* initialize device info: */ |
771 | properties = &line6_properties_table[devtype]; | 771 | properties = &line6_properties_table[devtype]; |
772 | dev_info(&interface->dev, "Line6 %s found\n", properties->name); | 772 | dev_info(&interface->dev, "Line6 %s found\n", properties->name); |
773 | product = le16_to_cpu(usbdev->descriptor.idProduct); | 773 | product = le16_to_cpu(usbdev->descriptor.idProduct); |
774 | 774 | ||
775 | /* query interface number */ | 775 | /* query interface number */ |
776 | interface_number = interface->cur_altsetting->desc.bInterfaceNumber; | 776 | interface_number = interface->cur_altsetting->desc.bInterfaceNumber; |
777 | 777 | ||
778 | switch (product) { | 778 | switch (product) { |
779 | case LINE6_DEVID_BASSPODXTLIVE: | 779 | case LINE6_DEVID_BASSPODXTLIVE: |
780 | case LINE6_DEVID_PODXTLIVE: | 780 | case LINE6_DEVID_PODXTLIVE: |
781 | case LINE6_DEVID_VARIAX: | 781 | case LINE6_DEVID_VARIAX: |
782 | alternate = 1; | 782 | alternate = 1; |
783 | break; | 783 | break; |
784 | 784 | ||
785 | case LINE6_DEVID_POCKETPOD: | 785 | case LINE6_DEVID_POCKETPOD: |
786 | switch (interface_number) { | 786 | switch (interface_number) { |
787 | case 0: | 787 | case 0: |
788 | return 0; /* this interface has no endpoints */ | 788 | return 0; /* this interface has no endpoints */ |
789 | case 1: | 789 | case 1: |
790 | alternate = 0; | 790 | alternate = 0; |
791 | break; | 791 | break; |
792 | default: | 792 | default: |
793 | MISSING_CASE; | 793 | MISSING_CASE; |
794 | } | 794 | } |
795 | break; | 795 | break; |
796 | 796 | ||
797 | case LINE6_DEVID_PODX3: | 797 | case LINE6_DEVID_PODX3: |
798 | case LINE6_DEVID_PODX3LIVE: | 798 | case LINE6_DEVID_PODX3LIVE: |
799 | switch (interface_number) { | 799 | switch (interface_number) { |
800 | case 0: | 800 | case 0: |
801 | alternate = 1; | 801 | alternate = 1; |
802 | break; | 802 | break; |
803 | case 1: | 803 | case 1: |
804 | alternate = 0; | 804 | alternate = 0; |
805 | break; | 805 | break; |
806 | default: | 806 | default: |
807 | MISSING_CASE; | 807 | MISSING_CASE; |
808 | } | 808 | } |
809 | break; | 809 | break; |
810 | 810 | ||
811 | case LINE6_DEVID_BASSPODXT: | 811 | case LINE6_DEVID_BASSPODXT: |
812 | case LINE6_DEVID_BASSPODXTPRO: | 812 | case LINE6_DEVID_BASSPODXTPRO: |
813 | case LINE6_DEVID_PODXT: | 813 | case LINE6_DEVID_PODXT: |
814 | case LINE6_DEVID_PODXTPRO: | 814 | case LINE6_DEVID_PODXTPRO: |
815 | alternate = 5; | 815 | alternate = 5; |
816 | break; | 816 | break; |
817 | 817 | ||
818 | case LINE6_DEVID_GUITARPORT: | 818 | case LINE6_DEVID_GUITARPORT: |
819 | case LINE6_DEVID_PODSTUDIO_GX: | 819 | case LINE6_DEVID_PODSTUDIO_GX: |
820 | case LINE6_DEVID_PODSTUDIO_UX1: | 820 | case LINE6_DEVID_PODSTUDIO_UX1: |
821 | case LINE6_DEVID_TONEPORT_GX: | 821 | case LINE6_DEVID_TONEPORT_GX: |
822 | case LINE6_DEVID_TONEPORT_UX1: | 822 | case LINE6_DEVID_TONEPORT_UX1: |
823 | alternate = 2; /* 1..4 seem to be ok */ | 823 | alternate = 2; /* 1..4 seem to be ok */ |
824 | break; | 824 | break; |
825 | 825 | ||
826 | case LINE6_DEVID_TONEPORT_UX2: | 826 | case LINE6_DEVID_TONEPORT_UX2: |
827 | case LINE6_DEVID_PODSTUDIO_UX2: | 827 | case LINE6_DEVID_PODSTUDIO_UX2: |
828 | switch (interface_number) { | 828 | switch (interface_number) { |
829 | case 0: | 829 | case 0: |
830 | /* defaults to 44.1kHz, 16-bit */ | 830 | /* defaults to 44.1kHz, 16-bit */ |
831 | alternate = 2; | 831 | alternate = 2; |
832 | break; | 832 | break; |
833 | case 1: | 833 | case 1: |
834 | /* don't know yet what this is ... | 834 | /* don't know yet what this is ... |
835 | alternate = 1; | 835 | alternate = 1; |
836 | break; | 836 | break; |
837 | */ | 837 | */ |
838 | return -ENODEV; | 838 | return -ENODEV; |
839 | default: | 839 | default: |
840 | MISSING_CASE; | 840 | MISSING_CASE; |
841 | } | 841 | } |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | MISSING_CASE; | 845 | MISSING_CASE; |
846 | ret = -ENODEV; | 846 | ret = -ENODEV; |
847 | goto err_put; | 847 | goto err_put; |
848 | } | 848 | } |
849 | 849 | ||
850 | ret = usb_set_interface(usbdev, interface_number, alternate); | 850 | ret = usb_set_interface(usbdev, interface_number, alternate); |
851 | if (ret < 0) { | 851 | if (ret < 0) { |
852 | dev_err(&interface->dev, "set_interface failed\n"); | 852 | dev_err(&interface->dev, "set_interface failed\n"); |
853 | goto err_put; | 853 | goto err_put; |
854 | } | 854 | } |
855 | 855 | ||
856 | /* initialize device data based on product id: */ | 856 | /* initialize device data based on product id: */ |
857 | switch (product) { | 857 | switch (product) { |
858 | case LINE6_DEVID_BASSPODXT: | 858 | case LINE6_DEVID_BASSPODXT: |
859 | case LINE6_DEVID_BASSPODXTLIVE: | 859 | case LINE6_DEVID_BASSPODXTLIVE: |
860 | case LINE6_DEVID_BASSPODXTPRO: | 860 | case LINE6_DEVID_BASSPODXTPRO: |
861 | case LINE6_DEVID_PODXT: | 861 | case LINE6_DEVID_PODXT: |
862 | case LINE6_DEVID_PODXTPRO: | 862 | case LINE6_DEVID_PODXTPRO: |
863 | size = sizeof(struct usb_line6_pod); | 863 | size = sizeof(struct usb_line6_pod); |
864 | ep_read = 0x84; | 864 | ep_read = 0x84; |
865 | ep_write = 0x03; | 865 | ep_write = 0x03; |
866 | break; | 866 | break; |
867 | 867 | ||
868 | case LINE6_DEVID_POCKETPOD: | 868 | case LINE6_DEVID_POCKETPOD: |
869 | size = sizeof(struct usb_line6_pod); | 869 | size = sizeof(struct usb_line6_pod); |
870 | ep_read = 0x82; | 870 | ep_read = 0x82; |
871 | ep_write = 0x02; | 871 | ep_write = 0x02; |
872 | break; | 872 | break; |
873 | 873 | ||
874 | case LINE6_DEVID_PODX3: | 874 | case LINE6_DEVID_PODX3: |
875 | case LINE6_DEVID_PODX3LIVE: | 875 | case LINE6_DEVID_PODX3LIVE: |
876 | /* currently unused! */ | 876 | /* currently unused! */ |
877 | size = sizeof(struct usb_line6_pod); | 877 | size = sizeof(struct usb_line6_pod); |
878 | ep_read = 0x81; | 878 | ep_read = 0x81; |
879 | ep_write = 0x01; | 879 | ep_write = 0x01; |
880 | break; | 880 | break; |
881 | 881 | ||
882 | case LINE6_DEVID_PODSTUDIO_GX: | 882 | case LINE6_DEVID_PODSTUDIO_GX: |
883 | case LINE6_DEVID_PODSTUDIO_UX1: | 883 | case LINE6_DEVID_PODSTUDIO_UX1: |
884 | case LINE6_DEVID_PODSTUDIO_UX2: | 884 | case LINE6_DEVID_PODSTUDIO_UX2: |
885 | case LINE6_DEVID_TONEPORT_GX: | 885 | case LINE6_DEVID_TONEPORT_GX: |
886 | case LINE6_DEVID_TONEPORT_UX1: | 886 | case LINE6_DEVID_TONEPORT_UX1: |
887 | case LINE6_DEVID_TONEPORT_UX2: | 887 | case LINE6_DEVID_TONEPORT_UX2: |
888 | case LINE6_DEVID_GUITARPORT: | 888 | case LINE6_DEVID_GUITARPORT: |
889 | size = sizeof(struct usb_line6_toneport); | 889 | size = sizeof(struct usb_line6_toneport); |
890 | /* these don't have a control channel */ | 890 | /* these don't have a control channel */ |
891 | break; | 891 | break; |
892 | 892 | ||
893 | case LINE6_DEVID_PODXTLIVE: | 893 | case LINE6_DEVID_PODXTLIVE: |
894 | switch (interface_number) { | 894 | switch (interface_number) { |
895 | case PODXTLIVE_INTERFACE_POD: | 895 | case PODXTLIVE_INTERFACE_POD: |
896 | size = sizeof(struct usb_line6_pod); | 896 | size = sizeof(struct usb_line6_pod); |
897 | ep_read = 0x84; | 897 | ep_read = 0x84; |
898 | ep_write = 0x03; | 898 | ep_write = 0x03; |
899 | break; | 899 | break; |
900 | 900 | ||
901 | case PODXTLIVE_INTERFACE_VARIAX: | 901 | case PODXTLIVE_INTERFACE_VARIAX: |
902 | size = sizeof(struct usb_line6_variax); | 902 | size = sizeof(struct usb_line6_variax); |
903 | ep_read = 0x86; | 903 | ep_read = 0x86; |
904 | ep_write = 0x05; | 904 | ep_write = 0x05; |
905 | break; | 905 | break; |
906 | 906 | ||
907 | default: | 907 | default: |
908 | ret = -ENODEV; | 908 | ret = -ENODEV; |
909 | goto err_put; | 909 | goto err_put; |
910 | } | 910 | } |
911 | break; | 911 | break; |
912 | 912 | ||
913 | case LINE6_DEVID_VARIAX: | 913 | case LINE6_DEVID_VARIAX: |
914 | size = sizeof(struct usb_line6_variax); | 914 | size = sizeof(struct usb_line6_variax); |
915 | ep_read = 0x82; | 915 | ep_read = 0x82; |
916 | ep_write = 0x01; | 916 | ep_write = 0x01; |
917 | break; | 917 | break; |
918 | 918 | ||
919 | default: | 919 | default: |
920 | MISSING_CASE; | 920 | MISSING_CASE; |
921 | ret = -ENODEV; | 921 | ret = -ENODEV; |
922 | goto err_put; | 922 | goto err_put; |
923 | } | 923 | } |
924 | 924 | ||
925 | if (size == 0) { | 925 | if (size == 0) { |
926 | dev_err(line6->ifcdev, | 926 | dev_err(line6->ifcdev, |
927 | "driver bug: interface data size not set\n"); | 927 | "driver bug: interface data size not set\n"); |
928 | ret = -ENODEV; | 928 | ret = -ENODEV; |
929 | goto err_put; | 929 | goto err_put; |
930 | } | 930 | } |
931 | 931 | ||
932 | line6 = kzalloc(size, GFP_KERNEL); | 932 | line6 = kzalloc(size, GFP_KERNEL); |
933 | 933 | ||
934 | if (line6 == NULL) { | 934 | if (line6 == NULL) { |
935 | dev_err(&interface->dev, "Out of memory\n"); | 935 | dev_err(&interface->dev, "Out of memory\n"); |
936 | ret = -ENODEV; | 936 | ret = -ENODEV; |
937 | goto err_put; | 937 | goto err_put; |
938 | } | 938 | } |
939 | 939 | ||
940 | /* store basic data: */ | 940 | /* store basic data: */ |
941 | line6->interface_number = interface_number; | 941 | line6->interface_number = interface_number; |
942 | line6->properties = properties; | 942 | line6->properties = properties; |
943 | line6->usbdev = usbdev; | 943 | line6->usbdev = usbdev; |
944 | line6->ifcdev = &interface->dev; | 944 | line6->ifcdev = &interface->dev; |
945 | line6->ep_control_read = ep_read; | 945 | line6->ep_control_read = ep_read; |
946 | line6->ep_control_write = ep_write; | 946 | line6->ep_control_write = ep_write; |
947 | line6->product = product; | 947 | line6->product = product; |
948 | 948 | ||
949 | /* get data from endpoint descriptor (see usb_maxpacket): */ | 949 | /* get data from endpoint descriptor (see usb_maxpacket): */ |
950 | { | 950 | { |
951 | struct usb_host_endpoint *ep; | 951 | struct usb_host_endpoint *ep; |
952 | unsigned epnum = | 952 | unsigned epnum = |
953 | usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read)); | 953 | usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read)); |
954 | ep = usbdev->ep_in[epnum]; | 954 | ep = usbdev->ep_in[epnum]; |
955 | 955 | ||
956 | if (ep != NULL) { | 956 | if (ep != NULL) { |
957 | line6->interval = ep->desc.bInterval; | 957 | line6->interval = ep->desc.bInterval; |
958 | line6->max_packet_size = | 958 | line6->max_packet_size = |
959 | le16_to_cpu(ep->desc.wMaxPacketSize); | 959 | le16_to_cpu(ep->desc.wMaxPacketSize); |
960 | } else { | 960 | } else { |
961 | line6->interval = LINE6_FALLBACK_INTERVAL; | 961 | line6->interval = LINE6_FALLBACK_INTERVAL; |
962 | line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE; | 962 | line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE; |
963 | dev_err(line6->ifcdev, | 963 | dev_err(line6->ifcdev, |
964 | "endpoint not available, using fallback values"); | 964 | "endpoint not available, using fallback values"); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | usb_set_intfdata(interface, line6); | 968 | usb_set_intfdata(interface, line6); |
969 | 969 | ||
970 | if (properties->capabilities & LINE6_BIT_CONTROL) { | 970 | if (properties->capabilities & LINE6_BIT_CONTROL) { |
971 | /* initialize USB buffers: */ | 971 | /* initialize USB buffers: */ |
972 | line6->buffer_listen = | 972 | line6->buffer_listen = |
973 | kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); | 973 | kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); |
974 | 974 | ||
975 | if (line6->buffer_listen == NULL) { | 975 | if (line6->buffer_listen == NULL) { |
976 | dev_err(&interface->dev, "Out of memory\n"); | 976 | dev_err(&interface->dev, "Out of memory\n"); |
977 | ret = -ENOMEM; | 977 | ret = -ENOMEM; |
978 | goto err_destruct; | 978 | goto err_destruct; |
979 | } | 979 | } |
980 | 980 | ||
981 | line6->buffer_message = | 981 | line6->buffer_message = |
982 | kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); | 982 | kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); |
983 | 983 | ||
984 | if (line6->buffer_message == NULL) { | 984 | if (line6->buffer_message == NULL) { |
985 | dev_err(&interface->dev, "Out of memory\n"); | 985 | dev_err(&interface->dev, "Out of memory\n"); |
986 | ret = -ENOMEM; | 986 | ret = -ENOMEM; |
987 | goto err_destruct; | 987 | goto err_destruct; |
988 | } | 988 | } |
989 | 989 | ||
990 | line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL); | 990 | line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL); |
991 | 991 | ||
992 | if (line6->urb_listen == NULL) { | 992 | if (line6->urb_listen == NULL) { |
993 | dev_err(&interface->dev, "Out of memory\n"); | 993 | dev_err(&interface->dev, "Out of memory\n"); |
994 | line6_destruct(interface); | 994 | line6_destruct(interface); |
995 | ret = -ENOMEM; | 995 | ret = -ENOMEM; |
996 | goto err_destruct; | 996 | goto err_destruct; |
997 | } | 997 | } |
998 | 998 | ||
999 | ret = line6_start_listen(line6); | 999 | ret = line6_start_listen(line6); |
1000 | if (ret < 0) { | 1000 | if (ret < 0) { |
1001 | dev_err(&interface->dev, "%s: usb_submit_urb failed\n", | 1001 | dev_err(&interface->dev, "%s: usb_submit_urb failed\n", |
1002 | __func__); | 1002 | __func__); |
1003 | goto err_destruct; | 1003 | goto err_destruct; |
1004 | } | 1004 | } |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | /* initialize device data based on product id: */ | 1007 | /* initialize device data based on product id: */ |
1008 | switch (product) { | 1008 | switch (product) { |
1009 | case LINE6_DEVID_BASSPODXT: | 1009 | case LINE6_DEVID_BASSPODXT: |
1010 | case LINE6_DEVID_BASSPODXTLIVE: | 1010 | case LINE6_DEVID_BASSPODXTLIVE: |
1011 | case LINE6_DEVID_BASSPODXTPRO: | 1011 | case LINE6_DEVID_BASSPODXTPRO: |
1012 | case LINE6_DEVID_POCKETPOD: | 1012 | case LINE6_DEVID_POCKETPOD: |
1013 | case LINE6_DEVID_PODX3: | 1013 | case LINE6_DEVID_PODX3: |
1014 | case LINE6_DEVID_PODX3LIVE: | 1014 | case LINE6_DEVID_PODX3LIVE: |
1015 | case LINE6_DEVID_PODXT: | 1015 | case LINE6_DEVID_PODXT: |
1016 | case LINE6_DEVID_PODXTPRO: | 1016 | case LINE6_DEVID_PODXTPRO: |
1017 | ret = line6_pod_init(interface, (struct usb_line6_pod *)line6); | 1017 | ret = line6_pod_init(interface, (struct usb_line6_pod *)line6); |
1018 | break; | 1018 | break; |
1019 | 1019 | ||
1020 | case LINE6_DEVID_PODXTLIVE: | 1020 | case LINE6_DEVID_PODXTLIVE: |
1021 | switch (interface_number) { | 1021 | switch (interface_number) { |
1022 | case PODXTLIVE_INTERFACE_POD: | 1022 | case PODXTLIVE_INTERFACE_POD: |
1023 | ret = | 1023 | ret = |
1024 | line6_pod_init(interface, | 1024 | line6_pod_init(interface, |
1025 | (struct usb_line6_pod *)line6); | 1025 | (struct usb_line6_pod *)line6); |
1026 | break; | 1026 | break; |
1027 | 1027 | ||
1028 | case PODXTLIVE_INTERFACE_VARIAX: | 1028 | case PODXTLIVE_INTERFACE_VARIAX: |
1029 | ret = | 1029 | ret = |
1030 | line6_variax_init(interface, | 1030 | line6_variax_init(interface, |
1031 | (struct usb_line6_variax *)line6); | 1031 | (struct usb_line6_variax *)line6); |
1032 | break; | 1032 | break; |
1033 | 1033 | ||
1034 | default: | 1034 | default: |
1035 | dev_err(&interface->dev, | 1035 | dev_err(&interface->dev, |
1036 | "PODxt Live interface %d not supported\n", | 1036 | "PODxt Live interface %d not supported\n", |
1037 | interface_number); | 1037 | interface_number); |
1038 | ret = -ENODEV; | 1038 | ret = -ENODEV; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | break; | 1041 | break; |
1042 | 1042 | ||
1043 | case LINE6_DEVID_VARIAX: | 1043 | case LINE6_DEVID_VARIAX: |
1044 | ret = | 1044 | ret = |
1045 | line6_variax_init(interface, | 1045 | line6_variax_init(interface, |
1046 | (struct usb_line6_variax *)line6); | 1046 | (struct usb_line6_variax *)line6); |
1047 | break; | 1047 | break; |
1048 | 1048 | ||
1049 | case LINE6_DEVID_PODSTUDIO_GX: | 1049 | case LINE6_DEVID_PODSTUDIO_GX: |
1050 | case LINE6_DEVID_PODSTUDIO_UX1: | 1050 | case LINE6_DEVID_PODSTUDIO_UX1: |
1051 | case LINE6_DEVID_PODSTUDIO_UX2: | 1051 | case LINE6_DEVID_PODSTUDIO_UX2: |
1052 | case LINE6_DEVID_TONEPORT_GX: | 1052 | case LINE6_DEVID_TONEPORT_GX: |
1053 | case LINE6_DEVID_TONEPORT_UX1: | 1053 | case LINE6_DEVID_TONEPORT_UX1: |
1054 | case LINE6_DEVID_TONEPORT_UX2: | 1054 | case LINE6_DEVID_TONEPORT_UX2: |
1055 | case LINE6_DEVID_GUITARPORT: | 1055 | case LINE6_DEVID_GUITARPORT: |
1056 | ret = | 1056 | ret = |
1057 | line6_toneport_init(interface, | 1057 | line6_toneport_init(interface, |
1058 | (struct usb_line6_toneport *)line6); | 1058 | (struct usb_line6_toneport *)line6); |
1059 | break; | 1059 | break; |
1060 | 1060 | ||
1061 | default: | 1061 | default: |
1062 | MISSING_CASE; | 1062 | MISSING_CASE; |
1063 | ret = -ENODEV; | 1063 | ret = -ENODEV; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | if (ret < 0) | 1066 | if (ret < 0) |
1067 | goto err_destruct; | 1067 | goto err_destruct; |
1068 | 1068 | ||
1069 | ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj, | 1069 | ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj, |
1070 | "usb_device"); | 1070 | "usb_device"); |
1071 | if (ret < 0) | 1071 | if (ret < 0) |
1072 | goto err_destruct; | 1072 | goto err_destruct; |
1073 | 1073 | ||
1074 | /* creation of additional special files should go here */ | 1074 | /* creation of additional special files should go here */ |
1075 | 1075 | ||
1076 | dev_info(&interface->dev, "Line6 %s now attached\n", | 1076 | dev_info(&interface->dev, "Line6 %s now attached\n", |
1077 | line6->properties->name); | 1077 | line6->properties->name); |
1078 | line6_devices[devnum] = line6; | 1078 | line6_devices[devnum] = line6; |
1079 | 1079 | ||
1080 | switch (product) { | 1080 | switch (product) { |
1081 | case LINE6_DEVID_PODX3: | 1081 | case LINE6_DEVID_PODX3: |
1082 | case LINE6_DEVID_PODX3LIVE: | 1082 | case LINE6_DEVID_PODX3LIVE: |
1083 | dev_info(&interface->dev, | 1083 | dev_info(&interface->dev, |
1084 | "NOTE: the Line6 %s is detected, but not yet supported\n", | 1084 | "NOTE: the Line6 %s is detected, but not yet supported\n", |
1085 | line6->properties->name); | 1085 | line6->properties->name); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | /* increment reference counters: */ | 1088 | /* increment reference counters: */ |
1089 | usb_get_intf(interface); | 1089 | usb_get_intf(interface); |
1090 | usb_get_dev(usbdev); | 1090 | usb_get_dev(usbdev); |
1091 | 1091 | ||
1092 | return 0; | 1092 | return 0; |
1093 | 1093 | ||
1094 | err_destruct: | 1094 | err_destruct: |
1095 | line6_destruct(interface); | 1095 | line6_destruct(interface); |
1096 | err_put: | 1096 | err_put: |
1097 | usb_put_intf(interface); | ||
1098 | usb_put_dev(usbdev); | ||
1099 | return ret; | 1097 | return ret; |
1100 | } | 1098 | } |
1101 | 1099 | ||
1102 | /* | 1100 | /* |
1103 | Line6 device disconnected. | 1101 | Line6 device disconnected. |
1104 | */ | 1102 | */ |
1105 | static void line6_disconnect(struct usb_interface *interface) | 1103 | static void line6_disconnect(struct usb_interface *interface) |
1106 | { | 1104 | { |
1107 | struct usb_line6 *line6; | 1105 | struct usb_line6 *line6; |
1108 | struct usb_device *usbdev; | 1106 | struct usb_device *usbdev; |
1109 | int interface_number, i; | 1107 | int interface_number, i; |
1110 | 1108 | ||
1111 | if (interface == NULL) | 1109 | if (interface == NULL) |
1112 | return; | 1110 | return; |
1113 | usbdev = interface_to_usbdev(interface); | 1111 | usbdev = interface_to_usbdev(interface); |
1114 | if (usbdev == NULL) | 1112 | if (usbdev == NULL) |
1115 | return; | 1113 | return; |
1116 | 1114 | ||
1117 | /* removal of additional special files should go here */ | 1115 | /* removal of additional special files should go here */ |
1118 | 1116 | ||
1119 | sysfs_remove_link(&interface->dev.kobj, "usb_device"); | 1117 | sysfs_remove_link(&interface->dev.kobj, "usb_device"); |
1120 | 1118 | ||
1121 | interface_number = interface->cur_altsetting->desc.bInterfaceNumber; | 1119 | interface_number = interface->cur_altsetting->desc.bInterfaceNumber; |
1122 | line6 = usb_get_intfdata(interface); | 1120 | line6 = usb_get_intfdata(interface); |
1123 | 1121 | ||
1124 | if (line6 != NULL) { | 1122 | if (line6 != NULL) { |
1125 | if (line6->urb_listen != NULL) | 1123 | if (line6->urb_listen != NULL) |
1126 | line6_stop_listen(line6); | 1124 | line6_stop_listen(line6); |
1127 | 1125 | ||
1128 | if (usbdev != line6->usbdev) | 1126 | if (usbdev != line6->usbdev) |
1129 | dev_err(line6->ifcdev, | 1127 | dev_err(line6->ifcdev, |
1130 | "driver bug: inconsistent usb device\n"); | 1128 | "driver bug: inconsistent usb device\n"); |
1131 | 1129 | ||
1132 | switch (line6->usbdev->descriptor.idProduct) { | 1130 | switch (line6->usbdev->descriptor.idProduct) { |
1133 | case LINE6_DEVID_BASSPODXT: | 1131 | case LINE6_DEVID_BASSPODXT: |
1134 | case LINE6_DEVID_BASSPODXTLIVE: | 1132 | case LINE6_DEVID_BASSPODXTLIVE: |
1135 | case LINE6_DEVID_BASSPODXTPRO: | 1133 | case LINE6_DEVID_BASSPODXTPRO: |
1136 | case LINE6_DEVID_POCKETPOD: | 1134 | case LINE6_DEVID_POCKETPOD: |
1137 | case LINE6_DEVID_PODX3: | 1135 | case LINE6_DEVID_PODX3: |
1138 | case LINE6_DEVID_PODX3LIVE: | 1136 | case LINE6_DEVID_PODX3LIVE: |
1139 | case LINE6_DEVID_PODXT: | 1137 | case LINE6_DEVID_PODXT: |
1140 | case LINE6_DEVID_PODXTPRO: | 1138 | case LINE6_DEVID_PODXTPRO: |
1141 | line6_pod_disconnect(interface); | 1139 | line6_pod_disconnect(interface); |
1142 | break; | 1140 | break; |
1143 | 1141 | ||
1144 | case LINE6_DEVID_PODXTLIVE: | 1142 | case LINE6_DEVID_PODXTLIVE: |
1145 | switch (interface_number) { | 1143 | switch (interface_number) { |
1146 | case PODXTLIVE_INTERFACE_POD: | 1144 | case PODXTLIVE_INTERFACE_POD: |
1147 | line6_pod_disconnect(interface); | 1145 | line6_pod_disconnect(interface); |
1148 | break; | 1146 | break; |
1149 | 1147 | ||
1150 | case PODXTLIVE_INTERFACE_VARIAX: | 1148 | case PODXTLIVE_INTERFACE_VARIAX: |
1151 | line6_variax_disconnect(interface); | 1149 | line6_variax_disconnect(interface); |
1152 | break; | 1150 | break; |
1153 | } | 1151 | } |
1154 | 1152 | ||
1155 | break; | 1153 | break; |
1156 | 1154 | ||
1157 | case LINE6_DEVID_VARIAX: | 1155 | case LINE6_DEVID_VARIAX: |
1158 | line6_variax_disconnect(interface); | 1156 | line6_variax_disconnect(interface); |
1159 | break; | 1157 | break; |
1160 | 1158 | ||
1161 | case LINE6_DEVID_PODSTUDIO_GX: | 1159 | case LINE6_DEVID_PODSTUDIO_GX: |
1162 | case LINE6_DEVID_PODSTUDIO_UX1: | 1160 | case LINE6_DEVID_PODSTUDIO_UX1: |
1163 | case LINE6_DEVID_PODSTUDIO_UX2: | 1161 | case LINE6_DEVID_PODSTUDIO_UX2: |
1164 | case LINE6_DEVID_TONEPORT_GX: | 1162 | case LINE6_DEVID_TONEPORT_GX: |
1165 | case LINE6_DEVID_TONEPORT_UX1: | 1163 | case LINE6_DEVID_TONEPORT_UX1: |
1166 | case LINE6_DEVID_TONEPORT_UX2: | 1164 | case LINE6_DEVID_TONEPORT_UX2: |
1167 | case LINE6_DEVID_GUITARPORT: | 1165 | case LINE6_DEVID_GUITARPORT: |
1168 | line6_toneport_disconnect(interface); | 1166 | line6_toneport_disconnect(interface); |
1169 | break; | 1167 | break; |
1170 | 1168 | ||
1171 | default: | 1169 | default: |
1172 | MISSING_CASE; | 1170 | MISSING_CASE; |
1173 | } | 1171 | } |
1174 | 1172 | ||
1175 | dev_info(&interface->dev, "Line6 %s now disconnected\n", | 1173 | dev_info(&interface->dev, "Line6 %s now disconnected\n", |
1176 | line6->properties->name); | 1174 | line6->properties->name); |
1177 | 1175 | ||
1178 | for (i = LINE6_MAX_DEVICES; i--;) | 1176 | for (i = LINE6_MAX_DEVICES; i--;) |
1179 | if (line6_devices[i] == line6) | 1177 | if (line6_devices[i] == line6) |
1180 | line6_devices[i] = NULL; | 1178 | line6_devices[i] = NULL; |
1181 | } | 1179 | } |
1182 | 1180 | ||
1183 | line6_destruct(interface); | 1181 | line6_destruct(interface); |
1184 | 1182 | ||
1185 | /* decrement reference counters: */ | 1183 | /* decrement reference counters: */ |
1186 | usb_put_intf(interface); | 1184 | usb_put_intf(interface); |
1187 | usb_put_dev(usbdev); | 1185 | usb_put_dev(usbdev); |
1188 | } | 1186 | } |
1189 | 1187 | ||
1190 | #ifdef CONFIG_PM | 1188 | #ifdef CONFIG_PM |
1191 | 1189 | ||
1192 | /* | 1190 | /* |
1193 | Suspend Line6 device. | 1191 | Suspend Line6 device. |
1194 | */ | 1192 | */ |
1195 | static int line6_suspend(struct usb_interface *interface, pm_message_t message) | 1193 | static int line6_suspend(struct usb_interface *interface, pm_message_t message) |
1196 | { | 1194 | { |
1197 | struct usb_line6 *line6 = usb_get_intfdata(interface); | 1195 | struct usb_line6 *line6 = usb_get_intfdata(interface); |
1198 | struct snd_line6_pcm *line6pcm = line6->line6pcm; | 1196 | struct snd_line6_pcm *line6pcm = line6->line6pcm; |
1199 | 1197 | ||
1200 | snd_power_change_state(line6->card, SNDRV_CTL_POWER_D3hot); | 1198 | snd_power_change_state(line6->card, SNDRV_CTL_POWER_D3hot); |
1201 | 1199 | ||
1202 | if (line6->properties->capabilities & LINE6_BIT_CONTROL) | 1200 | if (line6->properties->capabilities & LINE6_BIT_CONTROL) |
1203 | line6_stop_listen(line6); | 1201 | line6_stop_listen(line6); |
1204 | 1202 | ||
1205 | if (line6pcm != NULL) { | 1203 | if (line6pcm != NULL) { |
1206 | snd_pcm_suspend_all(line6pcm->pcm); | 1204 | snd_pcm_suspend_all(line6pcm->pcm); |
1207 | line6_pcm_disconnect(line6pcm); | 1205 | line6_pcm_disconnect(line6pcm); |
1208 | line6pcm->flags = 0; | 1206 | line6pcm->flags = 0; |
1209 | } | 1207 | } |
1210 | 1208 | ||
1211 | return 0; | 1209 | return 0; |
1212 | } | 1210 | } |
1213 | 1211 | ||
1214 | /* | 1212 | /* |
1215 | Resume Line6 device. | 1213 | Resume Line6 device. |
1216 | */ | 1214 | */ |
1217 | static int line6_resume(struct usb_interface *interface) | 1215 | static int line6_resume(struct usb_interface *interface) |
1218 | { | 1216 | { |
1219 | struct usb_line6 *line6 = usb_get_intfdata(interface); | 1217 | struct usb_line6 *line6 = usb_get_intfdata(interface); |
1220 | 1218 | ||
1221 | if (line6->properties->capabilities & LINE6_BIT_CONTROL) | 1219 | if (line6->properties->capabilities & LINE6_BIT_CONTROL) |
1222 | line6_start_listen(line6); | 1220 | line6_start_listen(line6); |
1223 | 1221 | ||
1224 | snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0); | 1222 | snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0); |
1225 | return 0; | 1223 | return 0; |
1226 | } | 1224 | } |
1227 | 1225 | ||
1228 | /* | 1226 | /* |
1229 | Resume Line6 device after reset. | 1227 | Resume Line6 device after reset. |
1230 | */ | 1228 | */ |
1231 | static int line6_reset_resume(struct usb_interface *interface) | 1229 | static int line6_reset_resume(struct usb_interface *interface) |
1232 | { | 1230 | { |
1233 | struct usb_line6 *line6 = usb_get_intfdata(interface); | 1231 | struct usb_line6 *line6 = usb_get_intfdata(interface); |
1234 | 1232 | ||
1235 | switch (line6->usbdev->descriptor.idProduct) { | 1233 | switch (line6->usbdev->descriptor.idProduct) { |
1236 | case LINE6_DEVID_PODSTUDIO_GX: | 1234 | case LINE6_DEVID_PODSTUDIO_GX: |
1237 | case LINE6_DEVID_PODSTUDIO_UX1: | 1235 | case LINE6_DEVID_PODSTUDIO_UX1: |
1238 | case LINE6_DEVID_PODSTUDIO_UX2: | 1236 | case LINE6_DEVID_PODSTUDIO_UX2: |
1239 | case LINE6_DEVID_TONEPORT_GX: | 1237 | case LINE6_DEVID_TONEPORT_GX: |
1240 | case LINE6_DEVID_TONEPORT_UX1: | 1238 | case LINE6_DEVID_TONEPORT_UX1: |
1241 | case LINE6_DEVID_TONEPORT_UX2: | 1239 | case LINE6_DEVID_TONEPORT_UX2: |
1242 | case LINE6_DEVID_GUITARPORT: | 1240 | case LINE6_DEVID_GUITARPORT: |
1243 | line6_toneport_reset_resume((struct usb_line6_toneport *)line6); | 1241 | line6_toneport_reset_resume((struct usb_line6_toneport *)line6); |
1244 | } | 1242 | } |
1245 | 1243 | ||
1246 | return line6_resume(interface); | 1244 | return line6_resume(interface); |
1247 | } | 1245 | } |
1248 | 1246 | ||
1249 | #endif /* CONFIG_PM */ | 1247 | #endif /* CONFIG_PM */ |
1250 | 1248 | ||
1251 | static struct usb_driver line6_driver = { | 1249 | static struct usb_driver line6_driver = { |
1252 | .name = DRIVER_NAME, | 1250 | .name = DRIVER_NAME, |
1253 | .probe = line6_probe, | 1251 | .probe = line6_probe, |
1254 | .disconnect = line6_disconnect, | 1252 | .disconnect = line6_disconnect, |
1255 | #ifdef CONFIG_PM | 1253 | #ifdef CONFIG_PM |
1256 | .suspend = line6_suspend, | 1254 | .suspend = line6_suspend, |
1257 | .resume = line6_resume, | 1255 | .resume = line6_resume, |
1258 | .reset_resume = line6_reset_resume, | 1256 | .reset_resume = line6_reset_resume, |
1259 | #endif | 1257 | #endif |
1260 | .id_table = line6_id_table, | 1258 | .id_table = line6_id_table, |
1261 | }; | 1259 | }; |
1262 | 1260 | ||
1263 | /* | 1261 | /* |
1264 | Module initialization. | 1262 | Module initialization. |
1265 | */ | 1263 | */ |
1266 | static int __init line6_init(void) | 1264 | static int __init line6_init(void) |
1267 | { | 1265 | { |
1268 | int i, retval; | 1266 | int i, retval; |
1269 | 1267 | ||
1270 | printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION); | 1268 | printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION); |
1271 | 1269 | ||
1272 | for (i = LINE6_MAX_DEVICES; i--;) | 1270 | for (i = LINE6_MAX_DEVICES; i--;) |
1273 | line6_devices[i] = NULL; | 1271 | line6_devices[i] = NULL; |
1274 | 1272 | ||
1275 | retval = usb_register(&line6_driver); | 1273 | retval = usb_register(&line6_driver); |
1276 | 1274 | ||
1277 | if (retval) { | 1275 | if (retval) { |
1278 | err("usb_register failed. Error number %d", retval); | 1276 | err("usb_register failed. Error number %d", retval); |
1279 | return retval; | 1277 | return retval; |
1280 | } | 1278 | } |
1281 | 1279 | ||
1282 | line6_request_version = kmalloc(sizeof(line6_request_version0), | 1280 | line6_request_version = kmalloc(sizeof(line6_request_version0), |
1283 | GFP_KERNEL); | 1281 | GFP_KERNEL); |
1284 | 1282 | ||
1285 | if (line6_request_version == NULL) { | 1283 | if (line6_request_version == NULL) { |
1286 | err("Out of memory"); | 1284 | err("Out of memory"); |
1287 | return -ENOMEM; | 1285 | return -ENOMEM; |
1288 | } | 1286 | } |
1289 | 1287 | ||
1290 | memcpy((char *)line6_request_version, line6_request_version0, | 1288 | memcpy((char *)line6_request_version, line6_request_version0, |
1291 | sizeof(line6_request_version0)); | 1289 | sizeof(line6_request_version0)); |
1292 | 1290 | ||
1293 | return retval; | 1291 | return retval; |
1294 | } | 1292 | } |
1295 | 1293 | ||
1296 | /* | 1294 | /* |
1297 | Module cleanup. | 1295 | Module cleanup. |
1298 | */ | 1296 | */ |
1299 | static void __exit line6_exit(void) | 1297 | static void __exit line6_exit(void) |
1300 | { | 1298 | { |
1301 | int i; | 1299 | int i; |
1302 | struct usb_line6 *line6; | 1300 | struct usb_line6 *line6; |
1303 | struct snd_line6_pcm *line6pcm; | 1301 | struct snd_line6_pcm *line6pcm; |
1304 | 1302 | ||
1305 | /* stop all PCM channels */ | 1303 | /* stop all PCM channels */ |
1306 | for (i = LINE6_MAX_DEVICES; i--;) { | 1304 | for (i = LINE6_MAX_DEVICES; i--;) { |
1307 | line6 = line6_devices[i]; | 1305 | line6 = line6_devices[i]; |
1308 | 1306 | ||
1309 | if (line6 == NULL) | 1307 | if (line6 == NULL) |
1310 | continue; | 1308 | continue; |
1311 | 1309 | ||
1312 | line6pcm = line6->line6pcm; | 1310 | line6pcm = line6->line6pcm; |
1313 | 1311 | ||
1314 | if (line6pcm == NULL) | 1312 | if (line6pcm == NULL) |
1315 | continue; | 1313 | continue; |
1316 | 1314 | ||
1317 | line6_pcm_stop(line6pcm, ~0); | 1315 | line6_pcm_stop(line6pcm, ~0); |
1318 | } | 1316 | } |
1319 | 1317 | ||
1320 | usb_deregister(&line6_driver); | 1318 | usb_deregister(&line6_driver); |
1321 | kfree(line6_request_version); | 1319 | kfree(line6_request_version); |
1322 | } | 1320 | } |
1323 | 1321 | ||
1324 | module_init(line6_init); | 1322 | module_init(line6_init); |
1325 | module_exit(line6_exit); | 1323 | module_exit(line6_exit); |
1326 | 1324 | ||
1327 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1325 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1328 | MODULE_DESCRIPTION(DRIVER_DESC); | 1326 | MODULE_DESCRIPTION(DRIVER_DESC); |
1329 | MODULE_LICENSE("GPL"); | 1327 | MODULE_LICENSE("GPL"); |
1330 | MODULE_VERSION(DRIVER_VERSION); | 1328 | MODULE_VERSION(DRIVER_VERSION); |
1331 | 1329 |