aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/caiaq/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/caiaq/input.c')
-rw-r--r--sound/usb/caiaq/input.c328
1 files changed, 166 insertions, 162 deletions
diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c
index 26a121b42c3c..efc70ae915c5 100644
--- a/sound/usb/caiaq/input.c
+++ b/sound/usb/caiaq/input.c
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <linux/device.h>
19#include <linux/gfp.h> 20#include <linux/gfp.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
@@ -199,55 +200,55 @@ static unsigned int decode_erp(unsigned char a, unsigned char b)
199#undef HIGH_PEAK 200#undef HIGH_PEAK
200#undef LOW_PEAK 201#undef LOW_PEAK
201 202
202static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *dev, 203static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *cdev,
203 int axis, const unsigned char *buf, 204 int axis, const unsigned char *buf,
204 int offset) 205 int offset)
205{ 206{
206 input_report_abs(dev->input_dev, axis, 207 input_report_abs(cdev->input_dev, axis,
207 (buf[offset * 2] << 8) | buf[offset * 2 + 1]); 208 (buf[offset * 2] << 8) | buf[offset * 2 + 1]);
208} 209}
209 210
210static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev, 211static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *cdev,
211 const unsigned char *buf, 212 const unsigned char *buf,
212 unsigned int len) 213 unsigned int len)
213{ 214{
214 struct input_dev *input_dev = dev->input_dev; 215 struct input_dev *input_dev = cdev->input_dev;
215 216
216 switch (dev->chip.usb_id) { 217 switch (cdev->chip.usb_id) {
217 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): 218 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
218 snd_caiaq_input_report_abs(dev, ABS_X, buf, 2); 219 snd_caiaq_input_report_abs(cdev, ABS_X, buf, 2);
219 snd_caiaq_input_report_abs(dev, ABS_Y, buf, 0); 220 snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 0);
220 snd_caiaq_input_report_abs(dev, ABS_Z, buf, 1); 221 snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 1);
221 break; 222 break;
222 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 223 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
223 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): 224 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
224 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): 225 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
225 snd_caiaq_input_report_abs(dev, ABS_X, buf, 0); 226 snd_caiaq_input_report_abs(cdev, ABS_X, buf, 0);
226 snd_caiaq_input_report_abs(dev, ABS_Y, buf, 1); 227 snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 1);
227 snd_caiaq_input_report_abs(dev, ABS_Z, buf, 2); 228 snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 2);
228 break; 229 break;
229 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): 230 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
230 snd_caiaq_input_report_abs(dev, ABS_HAT0X, buf, 4); 231 snd_caiaq_input_report_abs(cdev, ABS_HAT0X, buf, 4);
231 snd_caiaq_input_report_abs(dev, ABS_HAT0Y, buf, 2); 232 snd_caiaq_input_report_abs(cdev, ABS_HAT0Y, buf, 2);
232 snd_caiaq_input_report_abs(dev, ABS_HAT1X, buf, 6); 233 snd_caiaq_input_report_abs(cdev, ABS_HAT1X, buf, 6);
233 snd_caiaq_input_report_abs(dev, ABS_HAT1Y, buf, 1); 234 snd_caiaq_input_report_abs(cdev, ABS_HAT1Y, buf, 1);
234 snd_caiaq_input_report_abs(dev, ABS_HAT2X, buf, 7); 235 snd_caiaq_input_report_abs(cdev, ABS_HAT2X, buf, 7);
235 snd_caiaq_input_report_abs(dev, ABS_HAT2Y, buf, 0); 236 snd_caiaq_input_report_abs(cdev, ABS_HAT2Y, buf, 0);
236 snd_caiaq_input_report_abs(dev, ABS_HAT3X, buf, 5); 237 snd_caiaq_input_report_abs(cdev, ABS_HAT3X, buf, 5);
237 snd_caiaq_input_report_abs(dev, ABS_HAT3Y, buf, 3); 238 snd_caiaq_input_report_abs(cdev, ABS_HAT3Y, buf, 3);
238 break; 239 break;
239 } 240 }
240 241
241 input_sync(input_dev); 242 input_sync(input_dev);
242} 243}
243 244
244static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, 245static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *cdev,
245 const char *buf, unsigned int len) 246 const char *buf, unsigned int len)
246{ 247{
247 struct input_dev *input_dev = dev->input_dev; 248 struct input_dev *input_dev = cdev->input_dev;
248 int i; 249 int i;
249 250
250 switch (dev->chip.usb_id) { 251 switch (cdev->chip.usb_id) {
251 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 252 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
252 i = decode_erp(buf[0], buf[1]); 253 i = decode_erp(buf[0], buf[1]);
253 input_report_abs(input_dev, ABS_X, i); 254 input_report_abs(input_dev, ABS_X, i);
@@ -299,10 +300,10 @@ static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev,
299 } 300 }
300} 301}
301 302
302static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, 303static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *cdev,
303 unsigned char *buf, unsigned int len) 304 unsigned char *buf, unsigned int len)
304{ 305{
305 struct input_dev *input_dev = dev->input_dev; 306 struct input_dev *input_dev = cdev->input_dev;
306 unsigned short *keycode = input_dev->keycode; 307 unsigned short *keycode = input_dev->keycode;
307 int i; 308 int i;
308 309
@@ -317,17 +318,17 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
317 input_report_key(input_dev, keycode[i], 318 input_report_key(input_dev, keycode[i],
318 buf[i / 8] & (1 << (i % 8))); 319 buf[i / 8] & (1 << (i % 8)));
319 320
320 switch (dev->chip.usb_id) { 321 switch (cdev->chip.usb_id) {
321 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): 322 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
322 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): 323 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
323 input_report_abs(dev->input_dev, ABS_MISC, 255 - buf[4]); 324 input_report_abs(cdev->input_dev, ABS_MISC, 255 - buf[4]);
324 break; 325 break;
325 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): 326 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
326 /* rotary encoders */ 327 /* rotary encoders */
327 input_report_abs(dev->input_dev, ABS_X, buf[5] & 0xf); 328 input_report_abs(cdev->input_dev, ABS_X, buf[5] & 0xf);
328 input_report_abs(dev->input_dev, ABS_Y, buf[5] >> 4); 329 input_report_abs(cdev->input_dev, ABS_Y, buf[5] >> 4);
329 input_report_abs(dev->input_dev, ABS_Z, buf[6] & 0xf); 330 input_report_abs(cdev->input_dev, ABS_Z, buf[6] & 0xf);
330 input_report_abs(dev->input_dev, ABS_MISC, buf[6] >> 4); 331 input_report_abs(cdev->input_dev, ABS_MISC, buf[6] >> 4);
331 break; 332 break;
332 } 333 }
333 334
@@ -336,10 +337,12 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
336 337
337#define TKS4_MSGBLOCK_SIZE 16 338#define TKS4_MSGBLOCK_SIZE 16
338 339
339static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, 340static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *cdev,
340 const unsigned char *buf, 341 const unsigned char *buf,
341 unsigned int len) 342 unsigned int len)
342{ 343{
344 struct device *dev = caiaqdev_to_dev(cdev);
345
343 while (len) { 346 while (len) {
344 unsigned int i, block_id = (buf[0] << 8) | buf[1]; 347 unsigned int i, block_id = (buf[0] << 8) | buf[1];
345 348
@@ -347,126 +350,126 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev,
347 case 0: 350 case 0:
348 /* buttons */ 351 /* buttons */
349 for (i = 0; i < KONTROLS4_BUTTONS; i++) 352 for (i = 0; i < KONTROLS4_BUTTONS; i++)
350 input_report_key(dev->input_dev, KONTROLS4_BUTTON(i), 353 input_report_key(cdev->input_dev, KONTROLS4_BUTTON(i),
351 (buf[4 + (i / 8)] >> (i % 8)) & 1); 354 (buf[4 + (i / 8)] >> (i % 8)) & 1);
352 break; 355 break;
353 356
354 case 1: 357 case 1:
355 /* left wheel */ 358 /* left wheel */
356 input_report_abs(dev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8)); 359 input_report_abs(cdev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8));
357 /* right wheel */ 360 /* right wheel */
358 input_report_abs(dev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8)); 361 input_report_abs(cdev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8));
359 362
360 /* rotary encoders */ 363 /* rotary encoders */
361 input_report_abs(dev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf); 364 input_report_abs(cdev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf);
362 input_report_abs(dev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4); 365 input_report_abs(cdev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4);
363 input_report_abs(dev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf); 366 input_report_abs(cdev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf);
364 input_report_abs(dev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4); 367 input_report_abs(cdev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4);
365 input_report_abs(dev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf); 368 input_report_abs(cdev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf);
366 input_report_abs(dev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4); 369 input_report_abs(cdev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4);
367 input_report_abs(dev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf); 370 input_report_abs(cdev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf);
368 input_report_abs(dev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4); 371 input_report_abs(cdev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4);
369 input_report_abs(dev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf); 372 input_report_abs(cdev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf);
370 373
371 break; 374 break;
372 case 2: 375 case 2:
373 /* Volume Fader Channel D */ 376 /* Volume Fader Channel D */
374 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(0), buf, 1); 377 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(0), buf, 1);
375 /* Volume Fader Channel B */ 378 /* Volume Fader Channel B */
376 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(1), buf, 2); 379 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(1), buf, 2);
377 /* Volume Fader Channel A */ 380 /* Volume Fader Channel A */
378 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(2), buf, 3); 381 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(2), buf, 3);
379 /* Volume Fader Channel C */ 382 /* Volume Fader Channel C */
380 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(3), buf, 4); 383 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(3), buf, 4);
381 /* Loop Volume */ 384 /* Loop Volume */
382 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(4), buf, 6); 385 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(4), buf, 6);
383 /* Crossfader */ 386 /* Crossfader */
384 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(7), buf, 7); 387 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(7), buf, 7);
385 388
386 break; 389 break;
387 390
388 case 3: 391 case 3:
389 /* Tempo Fader R */ 392 /* Tempo Fader R */
390 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(6), buf, 3); 393 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(6), buf, 3);
391 /* Tempo Fader L */ 394 /* Tempo Fader L */
392 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(5), buf, 4); 395 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(5), buf, 4);
393 /* Mic Volume */ 396 /* Mic Volume */
394 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(8), buf, 6); 397 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(8), buf, 6);
395 /* Cue Mix */ 398 /* Cue Mix */
396 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(9), buf, 7); 399 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(9), buf, 7);
397 400
398 break; 401 break;
399 402
400 case 4: 403 case 4:
401 /* Wheel distance sensor L */ 404 /* Wheel distance sensor L */
402 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(10), buf, 1); 405 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(10), buf, 1);
403 /* Wheel distance sensor R */ 406 /* Wheel distance sensor R */
404 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(11), buf, 2); 407 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(11), buf, 2);
405 /* Channel D EQ - Filter */ 408 /* Channel D EQ - Filter */
406 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(12), buf, 3); 409 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(12), buf, 3);
407 /* Channel D EQ - Low */ 410 /* Channel D EQ - Low */
408 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(13), buf, 4); 411 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(13), buf, 4);
409 /* Channel D EQ - Mid */ 412 /* Channel D EQ - Mid */
410 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(14), buf, 5); 413 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(14), buf, 5);
411 /* Channel D EQ - Hi */ 414 /* Channel D EQ - Hi */
412 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(15), buf, 6); 415 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(15), buf, 6);
413 /* FX2 - dry/wet */ 416 /* FX2 - dry/wet */
414 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(16), buf, 7); 417 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(16), buf, 7);
415 418
416 break; 419 break;
417 420
418 case 5: 421 case 5:
419 /* FX2 - 1 */ 422 /* FX2 - 1 */
420 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(17), buf, 1); 423 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(17), buf, 1);
421 /* FX2 - 2 */ 424 /* FX2 - 2 */
422 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(18), buf, 2); 425 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(18), buf, 2);
423 /* FX2 - 3 */ 426 /* FX2 - 3 */
424 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(19), buf, 3); 427 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(19), buf, 3);
425 /* Channel B EQ - Filter */ 428 /* Channel B EQ - Filter */
426 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(20), buf, 4); 429 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(20), buf, 4);
427 /* Channel B EQ - Low */ 430 /* Channel B EQ - Low */
428 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(21), buf, 5); 431 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(21), buf, 5);
429 /* Channel B EQ - Mid */ 432 /* Channel B EQ - Mid */
430 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(22), buf, 6); 433 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(22), buf, 6);
431 /* Channel B EQ - Hi */ 434 /* Channel B EQ - Hi */
432 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(23), buf, 7); 435 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(23), buf, 7);
433 436
434 break; 437 break;
435 438
436 case 6: 439 case 6:
437 /* Channel A EQ - Filter */ 440 /* Channel A EQ - Filter */
438 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(24), buf, 1); 441 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(24), buf, 1);
439 /* Channel A EQ - Low */ 442 /* Channel A EQ - Low */
440 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(25), buf, 2); 443 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(25), buf, 2);
441 /* Channel A EQ - Mid */ 444 /* Channel A EQ - Mid */
442 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(26), buf, 3); 445 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(26), buf, 3);
443 /* Channel A EQ - Hi */ 446 /* Channel A EQ - Hi */
444 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(27), buf, 4); 447 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(27), buf, 4);
445 /* Channel C EQ - Filter */ 448 /* Channel C EQ - Filter */
446 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(28), buf, 5); 449 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(28), buf, 5);
447 /* Channel C EQ - Low */ 450 /* Channel C EQ - Low */
448 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(29), buf, 6); 451 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(29), buf, 6);
449 /* Channel C EQ - Mid */ 452 /* Channel C EQ - Mid */
450 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(30), buf, 7); 453 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(30), buf, 7);
451 454
452 break; 455 break;
453 456
454 case 7: 457 case 7:
455 /* Channel C EQ - Hi */ 458 /* Channel C EQ - Hi */
456 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(31), buf, 1); 459 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(31), buf, 1);
457 /* FX1 - wet/dry */ 460 /* FX1 - wet/dry */
458 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(32), buf, 2); 461 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(32), buf, 2);
459 /* FX1 - 1 */ 462 /* FX1 - 1 */
460 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(33), buf, 3); 463 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(33), buf, 3);
461 /* FX1 - 2 */ 464 /* FX1 - 2 */
462 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(34), buf, 4); 465 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(34), buf, 4);
463 /* FX1 - 3 */ 466 /* FX1 - 3 */
464 snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(35), buf, 5); 467 snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(35), buf, 5);
465 468
466 break; 469 break;
467 470
468 default: 471 default:
469 debug("%s(): bogus block (id %d)\n", 472 dev_dbg(dev, "%s(): bogus block (id %d)\n",
470 __func__, block_id); 473 __func__, block_id);
471 return; 474 return;
472 } 475 }
@@ -475,12 +478,12 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev,
475 buf += TKS4_MSGBLOCK_SIZE; 478 buf += TKS4_MSGBLOCK_SIZE;
476 } 479 }
477 480
478 input_sync(dev->input_dev); 481 input_sync(cdev->input_dev);
479} 482}
480 483
481#define MASCHINE_MSGBLOCK_SIZE 2 484#define MASCHINE_MSGBLOCK_SIZE 2
482 485
483static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, 486static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev,
484 const unsigned char *buf, 487 const unsigned char *buf,
485 unsigned int len) 488 unsigned int len)
486{ 489{
@@ -491,65 +494,66 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev,
491 pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); 494 pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]);
492 pad_id = pressure >> 12; 495 pad_id = pressure >> 12;
493 496
494 input_report_abs(dev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); 497 input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff);
495 } 498 }
496 499
497 input_sync(dev->input_dev); 500 input_sync(cdev->input_dev);
498} 501}
499 502
500static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) 503static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb)
501{ 504{
502 struct snd_usb_caiaqdev *dev = urb->context; 505 struct snd_usb_caiaqdev *cdev = urb->context;
503 unsigned char *buf = urb->transfer_buffer; 506 unsigned char *buf = urb->transfer_buffer;
507 struct device *dev = &urb->dev->dev;
504 int ret; 508 int ret;
505 509
506 if (urb->status || !dev || urb != dev->ep4_in_urb) 510 if (urb->status || !cdev || urb != cdev->ep4_in_urb)
507 return; 511 return;
508 512
509 switch (dev->chip.usb_id) { 513 switch (cdev->chip.usb_id) {
510 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): 514 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
511 if (urb->actual_length < 24) 515 if (urb->actual_length < 24)
512 goto requeue; 516 goto requeue;
513 517
514 if (buf[0] & 0x3) 518 if (buf[0] & 0x3)
515 snd_caiaq_input_read_io(dev, buf + 1, 7); 519 snd_caiaq_input_read_io(cdev, buf + 1, 7);
516 520
517 if (buf[0] & 0x4) 521 if (buf[0] & 0x4)
518 snd_caiaq_input_read_analog(dev, buf + 8, 16); 522 snd_caiaq_input_read_analog(cdev, buf + 8, 16);
519 523
520 break; 524 break;
521 525
522 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): 526 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
523 snd_usb_caiaq_tks4_dispatch(dev, buf, urb->actual_length); 527 snd_usb_caiaq_tks4_dispatch(cdev, buf, urb->actual_length);
524 break; 528 break;
525 529
526 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): 530 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
527 if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) 531 if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE))
528 goto requeue; 532 goto requeue;
529 533
530 snd_usb_caiaq_maschine_dispatch(dev, buf, urb->actual_length); 534 snd_usb_caiaq_maschine_dispatch(cdev, buf, urb->actual_length);
531 break; 535 break;
532 } 536 }
533 537
534requeue: 538requeue:
535 dev->ep4_in_urb->actual_length = 0; 539 cdev->ep4_in_urb->actual_length = 0;
536 ret = usb_submit_urb(dev->ep4_in_urb, GFP_ATOMIC); 540 ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC);
537 if (ret < 0) 541 if (ret < 0)
538 log("unable to submit urb. OOM!?\n"); 542 dev_err(dev, "unable to submit urb. OOM!?\n");
539} 543}
540 544
541static int snd_usb_caiaq_input_open(struct input_dev *idev) 545static int snd_usb_caiaq_input_open(struct input_dev *idev)
542{ 546{
543 struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); 547 struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev);
544 548
545 if (!dev) 549 if (!cdev)
546 return -EINVAL; 550 return -EINVAL;
547 551
548 switch (dev->chip.usb_id) { 552 switch (cdev->chip.usb_id) {
549 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): 553 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
550 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): 554 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
551 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): 555 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
552 if (usb_submit_urb(dev->ep4_in_urb, GFP_KERNEL) != 0) 556 if (usb_submit_urb(cdev->ep4_in_urb, GFP_KERNEL) != 0)
553 return -EIO; 557 return -EIO;
554 break; 558 break;
555 } 559 }
@@ -559,43 +563,43 @@ static int snd_usb_caiaq_input_open(struct input_dev *idev)
559 563
560static void snd_usb_caiaq_input_close(struct input_dev *idev) 564static void snd_usb_caiaq_input_close(struct input_dev *idev)
561{ 565{
562 struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); 566 struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev);
563 567
564 if (!dev) 568 if (!cdev)
565 return; 569 return;
566 570
567 switch (dev->chip.usb_id) { 571 switch (cdev->chip.usb_id) {
568 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): 572 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
569 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): 573 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
570 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): 574 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
571 usb_kill_urb(dev->ep4_in_urb); 575 usb_kill_urb(cdev->ep4_in_urb);
572 break; 576 break;
573 } 577 }
574} 578}
575 579
576void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, 580void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev,
577 char *buf, 581 char *buf,
578 unsigned int len) 582 unsigned int len)
579{ 583{
580 if (!dev->input_dev || len < 1) 584 if (!cdev->input_dev || len < 1)
581 return; 585 return;
582 586
583 switch (buf[0]) { 587 switch (buf[0]) {
584 case EP1_CMD_READ_ANALOG: 588 case EP1_CMD_READ_ANALOG:
585 snd_caiaq_input_read_analog(dev, buf + 1, len - 1); 589 snd_caiaq_input_read_analog(cdev, buf + 1, len - 1);
586 break; 590 break;
587 case EP1_CMD_READ_ERP: 591 case EP1_CMD_READ_ERP:
588 snd_caiaq_input_read_erp(dev, buf + 1, len - 1); 592 snd_caiaq_input_read_erp(cdev, buf + 1, len - 1);
589 break; 593 break;
590 case EP1_CMD_READ_IO: 594 case EP1_CMD_READ_IO:
591 snd_caiaq_input_read_io(dev, buf + 1, len - 1); 595 snd_caiaq_input_read_io(cdev, buf + 1, len - 1);
592 break; 596 break;
593 } 597 }
594} 598}
595 599
596int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) 600int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev)
597{ 601{
598 struct usb_device *usb_dev = dev->chip.dev; 602 struct usb_device *usb_dev = cdev->chip.dev;
599 struct input_dev *input; 603 struct input_dev *input;
600 int i, ret = 0; 604 int i, ret = 0;
601 605
@@ -603,49 +607,49 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
603 if (!input) 607 if (!input)
604 return -ENOMEM; 608 return -ENOMEM;
605 609
606 usb_make_path(usb_dev, dev->phys, sizeof(dev->phys)); 610 usb_make_path(usb_dev, cdev->phys, sizeof(cdev->phys));
607 strlcat(dev->phys, "/input0", sizeof(dev->phys)); 611 strlcat(cdev->phys, "/input0", sizeof(cdev->phys));
608 612
609 input->name = dev->product_name; 613 input->name = cdev->product_name;
610 input->phys = dev->phys; 614 input->phys = cdev->phys;
611 usb_to_input_id(usb_dev, &input->id); 615 usb_to_input_id(usb_dev, &input->id);
612 input->dev.parent = &usb_dev->dev; 616 input->dev.parent = &usb_dev->dev;
613 617
614 input_set_drvdata(input, dev); 618 input_set_drvdata(input, cdev);
615 619
616 switch (dev->chip.usb_id) { 620 switch (cdev->chip.usb_id) {
617 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): 621 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
618 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 622 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
619 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | 623 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
620 BIT_MASK(ABS_Z); 624 BIT_MASK(ABS_Z);
621 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2)); 625 BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk2));
622 memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2)); 626 memcpy(cdev->keycode, keycode_rk2, sizeof(keycode_rk2));
623 input->keycodemax = ARRAY_SIZE(keycode_rk2); 627 input->keycodemax = ARRAY_SIZE(keycode_rk2);
624 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); 628 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);
625 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); 629 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
626 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); 630 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
627 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); 631 snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0);
628 break; 632 break;
629 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 633 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
630 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 634 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
631 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | 635 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
632 BIT_MASK(ABS_Z); 636 BIT_MASK(ABS_Z);
633 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3)); 637 BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk3));
634 memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3)); 638 memcpy(cdev->keycode, keycode_rk3, sizeof(keycode_rk3));
635 input->keycodemax = ARRAY_SIZE(keycode_rk3); 639 input->keycodemax = ARRAY_SIZE(keycode_rk3);
636 input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); 640 input_set_abs_params(input, ABS_X, 0, 1024, 0, 10);
637 input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); 641 input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10);
638 input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); 642 input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10);
639 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); 643 snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0);
640 break; 644 break;
641 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 645 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
642 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 646 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
643 input->absbit[0] = BIT_MASK(ABS_X); 647 input->absbit[0] = BIT_MASK(ABS_X);
644 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1)); 648 BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_ak1));
645 memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1)); 649 memcpy(cdev->keycode, keycode_ak1, sizeof(keycode_ak1));
646 input->keycodemax = ARRAY_SIZE(keycode_ak1); 650 input->keycodemax = ARRAY_SIZE(keycode_ak1);
647 input_set_abs_params(input, ABS_X, 0, 999, 0, 10); 651 input_set_abs_params(input, ABS_X, 0, 999, 0, 10);
648 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); 652 snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 5);
649 break; 653 break;
650 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): 654 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
651 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): 655 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
@@ -657,8 +661,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
657 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | 661 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
658 BIT_MASK(ABS_Z); 662 BIT_MASK(ABS_Z);
659 input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); 663 input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
660 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore)); 664 BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_kore));
661 memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore)); 665 memcpy(cdev->keycode, keycode_kore, sizeof(keycode_kore));
662 input->keycodemax = ARRAY_SIZE(keycode_kore); 666 input->keycodemax = ARRAY_SIZE(keycode_kore);
663 input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); 667 input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10);
664 input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); 668 input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10);
@@ -672,7 +676,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
672 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); 676 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
673 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); 677 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
674 input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); 678 input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1);
675 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); 679 snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
676 break; 680 break;
677 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): 681 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
678 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 682 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
@@ -683,9 +687,9 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
683 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | 687 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
684 BIT_MASK(ABS_Z); 688 BIT_MASK(ABS_Z);
685 input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); 689 input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
686 BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLX1_INPUTS); 690 BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLX1_INPUTS);
687 for (i = 0; i < KONTROLX1_INPUTS; i++) 691 for (i = 0; i < KONTROLX1_INPUTS; i++)
688 dev->keycode[i] = BTN_MISC + i; 692 cdev->keycode[i] = BTN_MISC + i;
689 input->keycodemax = KONTROLX1_INPUTS; 693 input->keycodemax = KONTROLX1_INPUTS;
690 694
691 /* analog potentiometers */ 695 /* analog potentiometers */
@@ -704,26 +708,26 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
704 input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1); 708 input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1);
705 input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1); 709 input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1);
706 710
707 dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); 711 cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL);
708 if (!dev->ep4_in_urb) { 712 if (!cdev->ep4_in_urb) {
709 ret = -ENOMEM; 713 ret = -ENOMEM;
710 goto exit_free_idev; 714 goto exit_free_idev;
711 } 715 }
712 716
713 usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, 717 usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev,
714 usb_rcvbulkpipe(usb_dev, 0x4), 718 usb_rcvbulkpipe(usb_dev, 0x4),
715 dev->ep4_in_buf, EP4_BUFSIZE, 719 cdev->ep4_in_buf, EP4_BUFSIZE,
716 snd_usb_caiaq_ep4_reply_dispatch, dev); 720 snd_usb_caiaq_ep4_reply_dispatch, cdev);
717 721
718 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); 722 snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
719 723
720 break; 724 break;
721 725
722 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): 726 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
723 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 727 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
724 BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLS4_BUTTONS); 728 BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLS4_BUTTONS);
725 for (i = 0; i < KONTROLS4_BUTTONS; i++) 729 for (i = 0; i < KONTROLS4_BUTTONS; i++)
726 dev->keycode[i] = KONTROLS4_BUTTON(i); 730 cdev->keycode[i] = KONTROLS4_BUTTON(i);
727 input->keycodemax = KONTROLS4_BUTTONS; 731 input->keycodemax = KONTROLS4_BUTTONS;
728 732
729 for (i = 0; i < KONTROLS4_AXIS; i++) { 733 for (i = 0; i < KONTROLS4_AXIS; i++) {
@@ -743,18 +747,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
743 for (i = 0; i < 9; i++) 747 for (i = 0; i < 9; i++)
744 input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1); 748 input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1);
745 749
746 dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); 750 cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL);
747 if (!dev->ep4_in_urb) { 751 if (!cdev->ep4_in_urb) {
748 ret = -ENOMEM; 752 ret = -ENOMEM;
749 goto exit_free_idev; 753 goto exit_free_idev;
750 } 754 }
751 755
752 usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, 756 usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev,
753 usb_rcvbulkpipe(usb_dev, 0x4), 757 usb_rcvbulkpipe(usb_dev, 0x4),
754 dev->ep4_in_buf, EP4_BUFSIZE, 758 cdev->ep4_in_buf, EP4_BUFSIZE,
755 snd_usb_caiaq_ep4_reply_dispatch, dev); 759 snd_usb_caiaq_ep4_reply_dispatch, cdev);
756 760
757 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); 761 snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
758 762
759 break; 763 break;
760 764
@@ -767,8 +771,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
767 BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) | 771 BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) |
768 BIT_MASK(ABS_RZ); 772 BIT_MASK(ABS_RZ);
769 773
770 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_maschine)); 774 BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_maschine));
771 memcpy(dev->keycode, keycode_maschine, sizeof(keycode_maschine)); 775 memcpy(cdev->keycode, keycode_maschine, sizeof(keycode_maschine));
772 input->keycodemax = ARRAY_SIZE(keycode_maschine); 776 input->keycodemax = ARRAY_SIZE(keycode_maschine);
773 777
774 for (i = 0; i < MASCHINE_PADS; i++) { 778 for (i = 0; i < MASCHINE_PADS; i++) {
@@ -788,18 +792,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
788 input_set_abs_params(input, ABS_RY, 0, 999, 0, 10); 792 input_set_abs_params(input, ABS_RY, 0, 999, 0, 10);
789 input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10); 793 input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10);
790 794
791 dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); 795 cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL);
792 if (!dev->ep4_in_urb) { 796 if (!cdev->ep4_in_urb) {
793 ret = -ENOMEM; 797 ret = -ENOMEM;
794 goto exit_free_idev; 798 goto exit_free_idev;
795 } 799 }
796 800
797 usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, 801 usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev,
798 usb_rcvbulkpipe(usb_dev, 0x4), 802 usb_rcvbulkpipe(usb_dev, 0x4),
799 dev->ep4_in_buf, EP4_BUFSIZE, 803 cdev->ep4_in_buf, EP4_BUFSIZE,
800 snd_usb_caiaq_ep4_reply_dispatch, dev); 804 snd_usb_caiaq_ep4_reply_dispatch, cdev);
801 805
802 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); 806 snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
803 break; 807 break;
804 808
805 default: 809 default:
@@ -809,12 +813,12 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
809 813
810 input->open = snd_usb_caiaq_input_open; 814 input->open = snd_usb_caiaq_input_open;
811 input->close = snd_usb_caiaq_input_close; 815 input->close = snd_usb_caiaq_input_close;
812 input->keycode = dev->keycode; 816 input->keycode = cdev->keycode;
813 input->keycodesize = sizeof(unsigned short); 817 input->keycodesize = sizeof(unsigned short);
814 for (i = 0; i < input->keycodemax; i++) 818 for (i = 0; i < input->keycodemax; i++)
815 __set_bit(dev->keycode[i], input->keybit); 819 __set_bit(cdev->keycode[i], input->keybit);
816 820
817 dev->input_dev = input; 821 cdev->input_dev = input;
818 822
819 ret = input_register_device(input); 823 ret = input_register_device(input);
820 if (ret < 0) 824 if (ret < 0)
@@ -824,19 +828,19 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
824 828
825exit_free_idev: 829exit_free_idev:
826 input_free_device(input); 830 input_free_device(input);
827 dev->input_dev = NULL; 831 cdev->input_dev = NULL;
828 return ret; 832 return ret;
829} 833}
830 834
831void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev) 835void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev)
832{ 836{
833 if (!dev || !dev->input_dev) 837 if (!cdev || !cdev->input_dev)
834 return; 838 return;
835 839
836 usb_kill_urb(dev->ep4_in_urb); 840 usb_kill_urb(cdev->ep4_in_urb);
837 usb_free_urb(dev->ep4_in_urb); 841 usb_free_urb(cdev->ep4_in_urb);
838 dev->ep4_in_urb = NULL; 842 cdev->ep4_in_urb = NULL;
839 843
840 input_unregister_device(dev->input_dev); 844 input_unregister_device(cdev->input_dev);
841 dev->input_dev = NULL; 845 cdev->input_dev = NULL;
842} 846}