aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2006-01-17 05:15:13 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-31 20:23:39 -0500
commit0ec3c7e856319b600311750d784262caa8ed94b9 (patch)
tree86d0b3aa9105a8b92bbfc514c5964c9abe7da0e7 /drivers/usb/atm
parent7ce08c93e388922e25a96a7d9895784182e4c72c (diff)
[PATCH] USBATM: trivial modifications
Formatting, changes to variable names, comments, log level changes, printk rate limiting. Signed-off-by: Duncan Sands <baldrick@free.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/atm')
-rw-r--r--drivers/usb/atm/cxacru.c69
-rw-r--r--drivers/usb/atm/speedtch.c53
-rw-r--r--drivers/usb/atm/usbatm.c101
-rw-r--r--drivers/usb/atm/usbatm.h25
-rw-r--r--drivers/usb/atm/xusbatm.c23
5 files changed, 153 insertions, 118 deletions
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index af0a41e7870e..139be1207d22 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -352,7 +352,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
352 struct atm_dev *atm_dev) 352 struct atm_dev *atm_dev)
353{ 353{
354 struct cxacru_data *instance = usbatm_instance->driver_data; 354 struct cxacru_data *instance = usbatm_instance->driver_data;
355 struct device *dev = &usbatm_instance->usb_intf->dev;
356 /* 355 /*
357 struct atm_dev *atm_dev = usbatm_instance->atm_dev; 356 struct atm_dev *atm_dev = usbatm_instance->atm_dev;
358 */ 357 */
@@ -364,14 +363,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
364 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0, 363 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0,
365 atm_dev->esi, sizeof(atm_dev->esi)); 364 atm_dev->esi, sizeof(atm_dev->esi));
366 if (ret < 0) { 365 if (ret < 0) {
367 dev_err(dev, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret); 366 atm_err(usbatm_instance, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret);
368 return ret; 367 return ret;
369 } 368 }
370 369
371 /* start ADSL */ 370 /* start ADSL */
372 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); 371 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
373 if (ret < 0) { 372 if (ret < 0) {
374 dev_err(dev, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret); 373 atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
375 return ret; 374 return ret;
376 } 375 }
377 376
@@ -383,13 +382,13 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
383static void cxacru_poll_status(struct cxacru_data *instance) 382static void cxacru_poll_status(struct cxacru_data *instance)
384{ 383{
385 u32 buf[CXINF_MAX] = {}; 384 u32 buf[CXINF_MAX] = {};
386 struct device *dev = &instance->usbatm->usb_intf->dev; 385 struct usbatm_data *usbatm = instance->usbatm;
387 struct atm_dev *atm_dev = instance->usbatm->atm_dev; 386 struct atm_dev *atm_dev = usbatm->atm_dev;
388 int ret; 387 int ret;
389 388
390 ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX); 389 ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX);
391 if (ret < 0) { 390 if (ret < 0) {
392 dev_warn(dev, "poll status: error %d\n", ret); 391 atm_warn(usbatm, "poll status: error %d\n", ret);
393 goto reschedule; 392 goto reschedule;
394 } 393 }
395 394
@@ -400,50 +399,50 @@ static void cxacru_poll_status(struct cxacru_data *instance)
400 switch (instance->line_status) { 399 switch (instance->line_status) {
401 case 0: 400 case 0:
402 atm_dev->signal = ATM_PHY_SIG_LOST; 401 atm_dev->signal = ATM_PHY_SIG_LOST;
403 dev_info(dev, "ADSL line: down\n"); 402 atm_info(usbatm, "ADSL line: down\n");
404 break; 403 break;
405 404
406 case 1: 405 case 1:
407 atm_dev->signal = ATM_PHY_SIG_LOST; 406 atm_dev->signal = ATM_PHY_SIG_LOST;
408 dev_info(dev, "ADSL line: attemtping to activate\n"); 407 atm_info(usbatm, "ADSL line: attempting to activate\n");
409 break; 408 break;
410 409
411 case 2: 410 case 2:
412 atm_dev->signal = ATM_PHY_SIG_LOST; 411 atm_dev->signal = ATM_PHY_SIG_LOST;
413 dev_info(dev, "ADSL line: training\n"); 412 atm_info(usbatm, "ADSL line: training\n");
414 break; 413 break;
415 414
416 case 3: 415 case 3:
417 atm_dev->signal = ATM_PHY_SIG_LOST; 416 atm_dev->signal = ATM_PHY_SIG_LOST;
418 dev_info(dev, "ADSL line: channel analysis\n"); 417 atm_info(usbatm, "ADSL line: channel analysis\n");
419 break; 418 break;
420 419
421 case 4: 420 case 4:
422 atm_dev->signal = ATM_PHY_SIG_LOST; 421 atm_dev->signal = ATM_PHY_SIG_LOST;
423 dev_info(dev, "ADSL line: exchange\n"); 422 atm_info(usbatm, "ADSL line: exchange\n");
424 break; 423 break;
425 424
426 case 5: 425 case 5:
427 atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424; 426 atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
428 atm_dev->signal = ATM_PHY_SIG_FOUND; 427 atm_dev->signal = ATM_PHY_SIG_FOUND;
429 428
430 dev_info(dev, "ADSL line: up (%d kb/s down | %d kb/s up)\n", 429 atm_info(usbatm, "ADSL line: up (%d kb/s down | %d kb/s up)\n",
431 buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]); 430 buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
432 break; 431 break;
433 432
434 case 6: 433 case 6:
435 atm_dev->signal = ATM_PHY_SIG_LOST; 434 atm_dev->signal = ATM_PHY_SIG_LOST;
436 dev_info(dev, "ADSL line: waiting\n"); 435 atm_info(usbatm, "ADSL line: waiting\n");
437 break; 436 break;
438 437
439 case 7: 438 case 7:
440 atm_dev->signal = ATM_PHY_SIG_LOST; 439 atm_dev->signal = ATM_PHY_SIG_LOST;
441 dev_info(dev, "ADSL line: initializing\n"); 440 atm_info(usbatm, "ADSL line: initializing\n");
442 break; 441 break;
443 442
444 default: 443 default:
445 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 444 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
446 dev_info(dev, "Unknown line state %02x\n", instance->line_status); 445 atm_info(usbatm, "Unknown line state %02x\n", instance->line_status);
447 break; 446 break;
448 } 447 }
449reschedule: 448reschedule:
@@ -504,8 +503,8 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
504{ 503{
505 int ret; 504 int ret;
506 int off; 505 int off;
507 struct usb_device *usb_dev = instance->usbatm->usb_dev; 506 struct usbatm_data *usbatm = instance->usbatm;
508 struct device *dev = &instance->usbatm->usb_intf->dev; 507 struct usb_device *usb_dev = usbatm->usb_dev;
509 u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct }; 508 u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
510 u32 val; 509 u32 val;
511 510
@@ -515,7 +514,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
515 val = cpu_to_le32(instance->modem_type->pll_f_clk); 514 val = cpu_to_le32(instance->modem_type->pll_f_clk);
516 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4); 515 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
517 if (ret) { 516 if (ret) {
518 dev_err(dev, "FirmwarePllFClkValue failed: %d\n", ret); 517 usb_err(usbatm, "FirmwarePllFClkValue failed: %d\n", ret);
519 return; 518 return;
520 } 519 }
521 520
@@ -523,7 +522,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
523 val = cpu_to_le32(instance->modem_type->pll_b_clk); 522 val = cpu_to_le32(instance->modem_type->pll_b_clk);
524 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4); 523 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
525 if (ret) { 524 if (ret) {
526 dev_err(dev, "FirmwarePllBClkValue failed: %d\n", ret); 525 usb_err(usbatm, "FirmwarePllBClkValue failed: %d\n", ret);
527 return; 526 return;
528 } 527 }
529 528
@@ -531,14 +530,14 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
531 val = cpu_to_le32(SDRAM_ENA); 530 val = cpu_to_le32(SDRAM_ENA);
532 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4); 531 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
533 if (ret) { 532 if (ret) {
534 dev_err(dev, "Enable SDRAM failed: %d\n", ret); 533 usb_err(usbatm, "Enable SDRAM failed: %d\n", ret);
535 return; 534 return;
536 } 535 }
537 536
538 /* Firmware */ 537 /* Firmware */
539 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size); 538 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
540 if (ret) { 539 if (ret) {
541 dev_err(dev, "Firmware upload failed: %d\n", ret); 540 usb_err(usbatm, "Firmware upload failed: %d\n", ret);
542 return; 541 return;
543 } 542 }
544 543
@@ -546,7 +545,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
546 if (instance->modem_type->boot_rom_patch) { 545 if (instance->modem_type->boot_rom_patch) {
547 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size); 546 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
548 if (ret) { 547 if (ret) {
549 dev_err(dev, "Boot ROM patching failed: %d\n", ret); 548 usb_err(usbatm, "Boot ROM patching failed: %d\n", ret);
550 return; 549 return;
551 } 550 }
552 } 551 }
@@ -554,7 +553,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
554 /* Signature */ 553 /* Signature */
555 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4); 554 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
556 if (ret) { 555 if (ret) {
557 dev_err(dev, "Signature storing failed: %d\n", ret); 556 usb_err(usbatm, "Signature storing failed: %d\n", ret);
558 return; 557 return;
559 } 558 }
560 559
@@ -566,7 +565,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
566 ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0); 565 ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0);
567 } 566 }
568 if (ret) { 567 if (ret) {
569 dev_err(dev, "Passing control to firmware failed: %d\n", ret); 568 usb_err(usbatm, "Passing control to firmware failed: %d\n", ret);
570 return; 569 return;
571 } 570 }
572 571
@@ -580,7 +579,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
580 579
581 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0); 580 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
582 if (ret < 0) { 581 if (ret < 0) {
583 dev_err(dev, "modem failed to initialize: %d\n", ret); 582 usb_err(usbatm, "modem failed to initialize: %d\n", ret);
584 return; 583 return;
585 } 584 }
586 585
@@ -597,7 +596,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
597 ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET, 596 ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET,
598 (u8 *) buf, len, NULL, 0); 597 (u8 *) buf, len, NULL, 0);
599 if (ret < 0) { 598 if (ret < 0) {
600 dev_err(dev, "load config data failed: %d\n", ret); 599 usb_err(usbatm, "load config data failed: %d\n", ret);
601 return; 600 return;
602 } 601 }
603 } 602 }
@@ -608,18 +607,19 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
608static int cxacru_find_firmware(struct cxacru_data *instance, 607static int cxacru_find_firmware(struct cxacru_data *instance,
609 char* phase, const struct firmware **fw_p) 608 char* phase, const struct firmware **fw_p)
610{ 609{
611 struct device *dev = &instance->usbatm->usb_intf->dev; 610 struct usbatm_data *usbatm = instance->usbatm;
611 struct device *dev = &usbatm->usb_intf->dev;
612 char buf[16]; 612 char buf[16];
613 613
614 sprintf(buf, "cxacru-%s.bin", phase); 614 sprintf(buf, "cxacru-%s.bin", phase);
615 dbg("cxacru_find_firmware: looking for %s", buf); 615 dbg("cxacru_find_firmware: looking for %s", buf);
616 616
617 if (request_firmware(fw_p, buf, dev)) { 617 if (request_firmware(fw_p, buf, dev)) {
618 dev_dbg(dev, "no stage %s firmware found\n", phase); 618 usb_dbg(usbatm, "no stage %s firmware found\n", phase);
619 return -ENOENT; 619 return -ENOENT;
620 } 620 }
621 621
622 dev_info(dev, "found firmware %s\n", buf); 622 usb_info(usbatm, "found firmware %s\n", buf);
623 623
624 return 0; 624 return 0;
625} 625}
@@ -627,20 +627,19 @@ static int cxacru_find_firmware(struct cxacru_data *instance,
627static int cxacru_heavy_init(struct usbatm_data *usbatm_instance, 627static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
628 struct usb_interface *usb_intf) 628 struct usb_interface *usb_intf)
629{ 629{
630 struct device *dev = &usbatm_instance->usb_intf->dev;
631 const struct firmware *fw, *bp, *cf; 630 const struct firmware *fw, *bp, *cf;
632 struct cxacru_data *instance = usbatm_instance->driver_data; 631 struct cxacru_data *instance = usbatm_instance->driver_data;
633 632
634 int ret = cxacru_find_firmware(instance, "fw", &fw); 633 int ret = cxacru_find_firmware(instance, "fw", &fw);
635 if (ret) { 634 if (ret) {
636 dev_warn(dev, "firmware (cxacru-fw.bin) unavailable (hotplug misconfiguration?)\n"); 635 usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
637 return ret; 636 return ret;
638 } 637 }
639 638
640 if (instance->modem_type->boot_rom_patch) { 639 if (instance->modem_type->boot_rom_patch) {
641 ret = cxacru_find_firmware(instance, "bp", &bp); 640 ret = cxacru_find_firmware(instance, "bp", &bp);
642 if (ret) { 641 if (ret) {
643 dev_warn(dev, "boot ROM patch (cxacru-bp.bin) unavailable (hotplug misconfiguration?)\n"); 642 usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
644 release_firmware(fw); 643 release_firmware(fw);
645 return ret; 644 return ret;
646 } 645 }
@@ -787,12 +786,12 @@ static const struct usb_device_id cxacru_usb_ids[] = {
787 { /* V = Conexant P = ADSL modem (Hasbani project) */ 786 { /* V = Conexant P = ADSL modem (Hasbani project) */
788 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 787 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
789 }, 788 },
790 { /* V = Conexant P = ADSL modem (Well PTI-800 */
791 USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
792 },
793 { /* V = Conexant P = ADSL modem */ 789 { /* V = Conexant P = ADSL modem */
794 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 790 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
795 }, 791 },
792 { /* V = Conexant P = ADSL modem (Well PTI-800) */
793 USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
794 },
796 { /* V = Conexant P = ADSL modem */ 795 { /* V = Conexant P = ADSL modem */
797 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00 796 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
798 }, 797 },
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index c1b47d74e206..211d467311e2 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -205,7 +205,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
205 buffer, 0x200, &actual_length, 2000); 205 buffer, 0x200, &actual_length, 2000);
206 206
207 if (ret < 0 && ret != -ETIMEDOUT) 207 if (ret < 0 && ret != -ETIMEDOUT)
208 usb_dbg(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret); 208 usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret);
209 else 209 else
210 usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret); 210 usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret);
211 } 211 }
@@ -219,7 +219,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
219 buffer, thislen, &actual_length, DATA_TIMEOUT); 219 buffer, thislen, &actual_length, DATA_TIMEOUT);
220 220
221 if (ret < 0) { 221 if (ret < 0) {
222 usb_dbg(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret); 222 usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret);
223 goto out_free; 223 goto out_free;
224 } 224 }
225 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size); 225 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size);
@@ -232,7 +232,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
232 buffer, 0x200, &actual_length, DATA_TIMEOUT); 232 buffer, 0x200, &actual_length, DATA_TIMEOUT);
233 233
234 if (ret < 0) { 234 if (ret < 0) {
235 usb_dbg(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret); 235 usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret);
236 goto out_free; 236 goto out_free;
237 } 237 }
238 usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length); 238 usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length);
@@ -246,7 +246,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
246 buffer, thislen, &actual_length, DATA_TIMEOUT); 246 buffer, thislen, &actual_length, DATA_TIMEOUT);
247 247
248 if (ret < 0) { 248 if (ret < 0) {
249 usb_dbg(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret); 249 usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret);
250 goto out_free; 250 goto out_free;
251 } 251 }
252 } 252 }
@@ -259,7 +259,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
259 buffer, 0x200, &actual_length, DATA_TIMEOUT); 259 buffer, 0x200, &actual_length, DATA_TIMEOUT);
260 260
261 if (ret < 0) { 261 if (ret < 0) {
262 usb_dbg(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret); 262 usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret);
263 goto out_free; 263 goto out_free;
264 } 264 }
265 265
@@ -285,8 +285,8 @@ out:
285 return ret; 285 return ret;
286} 286}
287 287
288static int speedtch_find_firmware(struct usb_interface *intf, int phase, 288static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interface *intf,
289 const struct firmware **fw_p) 289 int phase, const struct firmware **fw_p)
290{ 290{
291 struct device *dev = &intf->dev; 291 struct device *dev = &intf->dev;
292 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice); 292 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice);
@@ -295,24 +295,24 @@ static int speedtch_find_firmware(struct usb_interface *intf, int phase,
295 char buf[24]; 295 char buf[24];
296 296
297 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision); 297 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
298 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 298 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
299 299
300 if (request_firmware(fw_p, buf, dev)) { 300 if (request_firmware(fw_p, buf, dev)) {
301 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision); 301 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
302 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 302 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
303 303
304 if (request_firmware(fw_p, buf, dev)) { 304 if (request_firmware(fw_p, buf, dev)) {
305 sprintf(buf, "speedtch-%d.bin", phase); 305 sprintf(buf, "speedtch-%d.bin", phase);
306 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 306 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
307 307
308 if (request_firmware(fw_p, buf, dev)) { 308 if (request_firmware(fw_p, buf, dev)) {
309 dev_warn(dev, "no stage %d firmware found!\n", phase); 309 usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase);
310 return -ENOENT; 310 return -ENOENT;
311 } 311 }
312 } 312 }
313 } 313 }
314 314
315 dev_info(dev, "found stage %d firmware %s\n", phase, buf); 315 usb_info(usbatm, "found stage %d firmware %s\n", phase, buf);
316 316
317 return 0; 317 return 0;
318} 318}
@@ -323,15 +323,16 @@ static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface
323 struct speedtch_instance_data *instance = usbatm->driver_data; 323 struct speedtch_instance_data *instance = usbatm->driver_data;
324 int ret; 324 int ret;
325 325
326 if ((ret = speedtch_find_firmware(intf, 1, &fw1)) < 0) 326 if ((ret = speedtch_find_firmware(usbatm, intf, 1, &fw1)) < 0)
327 return ret; 327 return ret;
328 328
329 if ((ret = speedtch_find_firmware(intf, 2, &fw2)) < 0) { 329 if ((ret = speedtch_find_firmware(usbatm, intf, 2, &fw2)) < 0) {
330 release_firmware(fw1); 330 release_firmware(fw1);
331 return ret; 331 return ret;
332 } 332 }
333 333
334 ret = speedtch_upload_firmware(instance, fw1, fw2); 334 if ((ret = speedtch_upload_firmware(instance, fw1, fw2)) < 0)
335 usb_err(usbatm, "%s: firmware upload failed (%d)!\n", __func__, ret);
335 336
336 release_firmware(fw2); 337 release_firmware(fw2);
337 release_firmware(fw1); 338 release_firmware(fw1);
@@ -428,7 +429,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
428 int down_speed, up_speed, ret; 429 int down_speed, up_speed, ret;
429 unsigned char status; 430 unsigned char status;
430 431
432#ifdef VERBOSE_DEBUG
431 atm_dbg(usbatm, "%s entered\n", __func__); 433 atm_dbg(usbatm, "%s entered\n", __func__);
434#endif
432 435
433 ret = speedtch_read_status(instance); 436 ret = speedtch_read_status(instance);
434 if (ret < 0) { 437 if (ret < 0) {
@@ -441,9 +444,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
441 444
442 status = buf[OFFSET_7]; 445 status = buf[OFFSET_7];
443 446
444 atm_dbg(usbatm, "%s: line state %02x\n", __func__, status);
445
446 if ((status != instance->last_status) || !status) { 447 if ((status != instance->last_status) || !status) {
448 atm_dbg(usbatm, "%s: line state 0x%02x\n", __func__, status);
449
447 switch (status) { 450 switch (status) {
448 case 0: 451 case 0:
449 atm_dev->signal = ATM_PHY_SIG_LOST; 452 atm_dev->signal = ATM_PHY_SIG_LOST;
@@ -484,7 +487,7 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
484 487
485 default: 488 default:
486 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 489 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
487 atm_info(usbatm, "Unknown line state %02x\n", status); 490 atm_info(usbatm, "unknown line state %02x\n", status);
488 break; 491 break;
489 } 492 }
490 493
@@ -690,8 +693,10 @@ static int speedtch_bind(struct usbatm_data *usbatm,
690 693
691 usb_dbg(usbatm, "%s entered\n", __func__); 694 usb_dbg(usbatm, "%s entered\n", __func__);
692 695
696 /* sanity checks */
697
693 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { 698 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) {
694 usb_dbg(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); 699 usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass);
695 return -ENODEV; 700 return -ENODEV;
696 } 701 }
697 702
@@ -704,7 +709,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
704 ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm); 709 ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm);
705 710
706 if (ret < 0) { 711 if (ret < 0) {
707 usb_dbg(usbatm, "%s: failed to claim interface %d (%d)\n", __func__, i, ret); 712 usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, i, ret);
708 speedtch_release_interfaces(usb_dev, i); 713 speedtch_release_interfaces(usb_dev, i);
709 return ret; 714 return ret;
710 } 715 }
@@ -714,7 +719,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
714 instance = kmalloc(sizeof(*instance), GFP_KERNEL); 719 instance = kmalloc(sizeof(*instance), GFP_KERNEL);
715 720
716 if (!instance) { 721 if (!instance) {
717 usb_dbg(usbatm, "%s: no memory for instance data!\n", __func__); 722 usb_err(usbatm, "%s: no memory for instance data!\n", __func__);
718 ret = -ENOMEM; 723 ret = -ENOMEM;
719 goto fail_release; 724 goto fail_release;
720 } 725 }
@@ -754,8 +759,10 @@ static int speedtch_bind(struct usbatm_data *usbatm,
754 usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already"); 759 usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already");
755 760
756 if (*need_heavy_init) 761 if (*need_heavy_init)
757 if ((ret = usb_reset_device(usb_dev)) < 0) 762 if ((ret = usb_reset_device(usb_dev)) < 0) {
763 usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
758 goto fail_free; 764 goto fail_free;
765 }
759 766
760 usbatm->driver_data = instance; 767 usbatm->driver_data = instance;
761 768
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 7af1883d4bf9..779f86ecdd76 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -166,10 +166,10 @@ struct usbatm_control {
166 166
167/* ATM */ 167/* ATM */
168 168
169static void usbatm_atm_dev_close(struct atm_dev *dev); 169static void usbatm_atm_dev_close(struct atm_dev *atm_dev);
170static int usbatm_atm_open(struct atm_vcc *vcc); 170static int usbatm_atm_open(struct atm_vcc *vcc);
171static void usbatm_atm_close(struct atm_vcc *vcc); 171static void usbatm_atm_close(struct atm_vcc *vcc);
172static int usbatm_atm_ioctl(struct atm_dev *dev, unsigned int cmd, void __user * arg); 172static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user * arg);
173static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb); 173static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb);
174static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page); 174static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page);
175 175
@@ -234,8 +234,9 @@ static int usbatm_submit_urb(struct urb *urb)
234 234
235 ret = usb_submit_urb(urb, GFP_ATOMIC); 235 ret = usb_submit_urb(urb, GFP_ATOMIC);
236 if (ret) { 236 if (ret) {
237 atm_dbg(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n", 237 if (printk_ratelimit())
238 __func__, urb, ret); 238 atm_warn(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n",
239 __func__, urb, ret);
239 240
240 /* consider all errors transient and return the buffer back to the queue */ 241 /* consider all errors transient and return the buffer back to the queue */
241 urb->status = -EAGAIN; 242 urb->status = -EAGAIN;
@@ -269,10 +270,13 @@ static void usbatm_complete(struct urb *urb, struct pt_regs *regs)
269 270
270 spin_unlock_irqrestore(&channel->lock, flags); 271 spin_unlock_irqrestore(&channel->lock, flags);
271 272
272 if (unlikely(urb->status)) 273 if (unlikely(urb->status)) {
274 if (printk_ratelimit())
275 atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
276 __func__, urb, urb->status);
273 /* throttle processing in case of an error */ 277 /* throttle processing in case of an error */
274 mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS)); 278 mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS));
275 else 279 } else
276 tasklet_schedule(&channel->tasklet); 280 tasklet_schedule(&channel->tasklet);
277} 281}
278 282
@@ -284,11 +288,11 @@ static void usbatm_complete(struct urb *urb, struct pt_regs *regs)
284static inline struct usbatm_vcc_data *usbatm_find_vcc(struct usbatm_data *instance, 288static inline struct usbatm_vcc_data *usbatm_find_vcc(struct usbatm_data *instance,
285 short vpi, int vci) 289 short vpi, int vci)
286{ 290{
287 struct usbatm_vcc_data *vcc; 291 struct usbatm_vcc_data *vcc_data;
288 292
289 list_for_each_entry(vcc, &instance->vcc_list, list) 293 list_for_each_entry(vcc_data, &instance->vcc_list, list)
290 if ((vcc->vci == vci) && (vcc->vpi == vpi)) 294 if ((vcc_data->vci == vci) && (vcc_data->vpi == vpi))
291 return vcc; 295 return vcc_data;
292 return NULL; 296 return NULL;
293} 297}
294 298
@@ -317,7 +321,7 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
317 cached_vcc = usbatm_find_vcc(instance, vpi, vci); 321 cached_vcc = usbatm_find_vcc(instance, vpi, vci);
318 322
319 if (!cached_vcc) 323 if (!cached_vcc)
320 atm_dbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci); 324 atm_rldbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci);
321 } 325 }
322 326
323 if (!cached_vcc) 327 if (!cached_vcc)
@@ -327,7 +331,9 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
327 331
328 /* OAM F5 end-to-end */ 332 /* OAM F5 end-to-end */
329 if (pti == ATM_PTI_E2EF5) { 333 if (pti == ATM_PTI_E2EF5) {
330 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n", __func__, vpi, vci); 334 if (printk_ratelimit())
335 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
336 __func__, vpi, vci);
331 atomic_inc(&vcc->stats->rx_err); 337 atomic_inc(&vcc->stats->rx_err);
332 continue; 338 continue;
333 } 339 }
@@ -335,7 +341,7 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
335 sarb = cached_vcc->sarb; 341 sarb = cached_vcc->sarb;
336 342
337 if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) { 343 if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
338 atm_dbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n", 344 atm_rldbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n",
339 __func__, sarb->len, vcc); 345 __func__, sarb->len, vcc);
340 /* discard cells already received */ 346 /* discard cells already received */
341 skb_trim(sarb, 0); 347 skb_trim(sarb, 0);
@@ -354,7 +360,7 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
354 360
355 /* guard against overflow */ 361 /* guard against overflow */
356 if (length > ATM_MAX_AAL5_PDU) { 362 if (length > ATM_MAX_AAL5_PDU) {
357 atm_dbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n", 363 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
358 __func__, length, vcc); 364 __func__, length, vcc);
359 atomic_inc(&vcc->stats->rx_err); 365 atomic_inc(&vcc->stats->rx_err);
360 goto out; 366 goto out;
@@ -363,14 +369,14 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
363 pdu_length = usbatm_pdu_length(length); 369 pdu_length = usbatm_pdu_length(length);
364 370
365 if (sarb->len < pdu_length) { 371 if (sarb->len < pdu_length) {
366 atm_dbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n", 372 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
367 __func__, pdu_length, sarb->len, vcc); 373 __func__, pdu_length, sarb->len, vcc);
368 atomic_inc(&vcc->stats->rx_err); 374 atomic_inc(&vcc->stats->rx_err);
369 goto out; 375 goto out;
370 } 376 }
371 377
372 if (crc32_be(~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) { 378 if (crc32_be(~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
373 atm_dbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n", 379 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
374 __func__, vcc); 380 __func__, vcc);
375 atomic_inc(&vcc->stats->rx_err); 381 atomic_inc(&vcc->stats->rx_err);
376 goto out; 382 goto out;
@@ -379,7 +385,9 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
379 vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc); 385 vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc);
380 386
381 if (!(skb = dev_alloc_skb(length))) { 387 if (!(skb = dev_alloc_skb(length))) {
382 atm_dbg(instance, "%s: no memory for skb (length: %u)!\n", __func__, length); 388 if (printk_ratelimit())
389 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
390 __func__, length);
383 atomic_inc(&vcc->stats->rx_drop); 391 atomic_inc(&vcc->stats->rx_drop);
384 goto out; 392 goto out;
385 } 393 }
@@ -387,7 +395,8 @@ static void usbatm_extract_cells(struct usbatm_data *instance,
387 vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize); 395 vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize);
388 396
389 if (!atm_charge(vcc, skb->truesize)) { 397 if (!atm_charge(vcc, skb->truesize)) {
390 atm_dbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n", __func__, skb->truesize); 398 atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n",
399 __func__, skb->truesize);
391 dev_kfree_skb(skb); 400 dev_kfree_skb(skb);
392 goto out; /* atm_charge increments rx_drop */ 401 goto out; /* atm_charge increments rx_drop */
393 } 402 }
@@ -600,13 +609,13 @@ static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
600 } 609 }
601 610
602 if (vcc->qos.aal != ATM_AAL5) { 611 if (vcc->qos.aal != ATM_AAL5) {
603 atm_dbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal); 612 atm_rldbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
604 err = -EINVAL; 613 err = -EINVAL;
605 goto fail; 614 goto fail;
606 } 615 }
607 616
608 if (skb->len > ATM_MAX_AAL5_PDU) { 617 if (skb->len > ATM_MAX_AAL5_PDU) {
609 atm_dbg(instance, "%s: packet too long (%d vs %d)!\n", 618 atm_rldbg(instance, "%s: packet too long (%d vs %d)!\n",
610 __func__, skb->len, ATM_MAX_AAL5_PDU); 619 __func__, skb->len, ATM_MAX_AAL5_PDU);
611 err = -EINVAL; 620 err = -EINVAL;
612 goto fail; 621 goto fail;
@@ -665,16 +674,16 @@ static void usbatm_put_instance(struct usbatm_data *instance)
665** ATM ** 674** ATM **
666**********/ 675**********/
667 676
668static void usbatm_atm_dev_close(struct atm_dev *dev) 677static void usbatm_atm_dev_close(struct atm_dev *atm_dev)
669{ 678{
670 struct usbatm_data *instance = dev->dev_data; 679 struct usbatm_data *instance = atm_dev->dev_data;
671 680
672 dbg("%s", __func__); 681 dbg("%s", __func__);
673 682
674 if (!instance) 683 if (!instance)
675 return; 684 return;
676 685
677 dev->dev_data = NULL; 686 atm_dev->dev_data = NULL; /* catch bugs */
678 usbatm_put_instance(instance); /* taken in usbatm_atm_init */ 687 usbatm_put_instance(instance); /* taken in usbatm_atm_init */
679} 688}
680 689
@@ -735,13 +744,18 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
735 atm_dbg(instance, "%s: vpi %hd, vci %d\n", __func__, vpi, vci); 744 atm_dbg(instance, "%s: vpi %hd, vci %d\n", __func__, vpi, vci);
736 745
737 /* only support AAL5 */ 746 /* only support AAL5 */
738 if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) 747 if ((vcc->qos.aal != ATM_AAL5)) {
739 || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) { 748 atm_warn(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
740 atm_dbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal); 749 return -EINVAL;
750 }
751
752 /* sanity checks */
753 if ((vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
754 atm_dbg(instance, "%s: max_sdu %d out of range!\n", __func__, vcc->qos.rxtp.max_sdu);
741 return -EINVAL; 755 return -EINVAL;
742 } 756 }
743 757
744 down(&instance->serialize); /* vs self, usbatm_atm_close */ 758 down(&instance->serialize); /* vs self, usbatm_atm_close, usbatm_usb_disconnect */
745 759
746 if (usbatm_find_vcc(instance, vpi, vci)) { 760 if (usbatm_find_vcc(instance, vpi, vci)) {
747 atm_dbg(instance, "%s: %hd/%d already in use!\n", __func__, vpi, vci); 761 atm_dbg(instance, "%s: %hd/%d already in use!\n", __func__, vpi, vci);
@@ -750,7 +764,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
750 } 764 }
751 765
752 if (!(new = kmalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL))) { 766 if (!(new = kmalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL))) {
753 atm_dbg(instance, "%s: no memory for vcc_data!\n", __func__); 767 atm_err(instance, "%s: no memory for vcc_data!\n", __func__);
754 ret = -ENOMEM; 768 ret = -ENOMEM;
755 goto fail; 769 goto fail;
756 } 770 }
@@ -762,7 +776,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
762 776
763 new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL); 777 new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL);
764 if (!new->sarb) { 778 if (!new->sarb) {
765 atm_dbg(instance, "%s: no memory for SAR buffer!\n", __func__); 779 atm_err(instance, "%s: no memory for SAR buffer!\n", __func__);
766 ret = -ENOMEM; 780 ret = -ENOMEM;
767 goto fail; 781 goto fail;
768 } 782 }
@@ -806,7 +820,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
806 820
807 usbatm_cancel_send(instance, vcc); 821 usbatm_cancel_send(instance, vcc);
808 822
809 down(&instance->serialize); /* vs self, usbatm_atm_open */ 823 down(&instance->serialize); /* vs self, usbatm_atm_open, usbatm_usb_disconnect */
810 824
811 tasklet_disable(&instance->rx_channel.tasklet); 825 tasklet_disable(&instance->rx_channel.tasklet);
812 list_del(&vcc_data->list); 826 list_del(&vcc_data->list);
@@ -829,7 +843,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
829 atm_dbg(instance, "%s successful\n", __func__); 843 atm_dbg(instance, "%s successful\n", __func__);
830} 844}
831 845
832static int usbatm_atm_ioctl(struct atm_dev *dev, unsigned int cmd, 846static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd,
833 void __user * arg) 847 void __user * arg)
834{ 848{
835 switch (cmd) { 849 switch (cmd) {
@@ -845,10 +859,13 @@ static int usbatm_atm_init(struct usbatm_data *instance)
845 struct atm_dev *atm_dev; 859 struct atm_dev *atm_dev;
846 int ret, i; 860 int ret, i;
847 861
848 /* ATM init */ 862 /* ATM init. The ATM initialization scheme suffers from an intrinsic race
863 * condition: callbacks we register can be executed at once, before we have
864 * initialized the struct atm_dev. To protect against this, all callbacks
865 * abort if atm_dev->dev_data is NULL. */
849 atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL); 866 atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL);
850 if (!atm_dev) { 867 if (!atm_dev) {
851 usb_dbg(instance, "%s: failed to register ATM device!\n", __func__); 868 usb_err(instance, "%s: failed to register ATM device!\n", __func__);
852 return -1; 869 return -1;
853 } 870 }
854 871
@@ -862,12 +879,13 @@ static int usbatm_atm_init(struct usbatm_data *instance)
862 atm_dev->link_rate = 128 * 1000 / 424; 879 atm_dev->link_rate = 128 * 1000 / 424;
863 880
864 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) { 881 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) {
865 atm_dbg(instance, "%s: atm_start failed: %d!\n", __func__, ret); 882 atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret);
866 goto fail; 883 goto fail;
867 } 884 }
868 885
869 /* ready for ATM callbacks */
870 usbatm_get_instance(instance); /* dropped in usbatm_atm_dev_close */ 886 usbatm_get_instance(instance); /* dropped in usbatm_atm_dev_close */
887
888 /* ready for ATM callbacks */
871 mb(); 889 mb();
872 atm_dev->dev_data = instance; 890 atm_dev->dev_data = instance;
873 891
@@ -915,7 +933,7 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
915 int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_KERNEL); 933 int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_KERNEL);
916 934
917 if (ret < 0) { 935 if (ret < 0) {
918 usb_dbg(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); 936 usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret);
919 return ret; 937 return ret;
920 } 938 }
921 939
@@ -953,7 +971,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
953 int i, length; 971 int i, length;
954 int need_heavy; 972 int need_heavy;
955 973
956 dev_dbg(dev, "%s: trying driver %s with vendor=0x%x, product=0x%x, ifnum %d\n", 974 dev_dbg(dev, "%s: trying driver %s with vendor=%04x, product=%04x, ifnum %2d\n",
957 __func__, driver->driver_name, 975 __func__, driver->driver_name,
958 le16_to_cpu(usb_dev->descriptor.idVendor), 976 le16_to_cpu(usb_dev->descriptor.idVendor),
959 le16_to_cpu(usb_dev->descriptor.idProduct), 977 le16_to_cpu(usb_dev->descriptor.idProduct),
@@ -962,7 +980,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
962 /* instance init */ 980 /* instance init */
963 instance = kzalloc(sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL); 981 instance = kzalloc(sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL);
964 if (!instance) { 982 if (!instance) {
965 dev_dbg(dev, "%s: no memory for instance data!\n", __func__); 983 dev_err(dev, "%s: no memory for instance data!\n", __func__);
966 return -ENOMEM; 984 return -ENOMEM;
967 } 985 }
968 986
@@ -998,7 +1016,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
998 bind: 1016 bind:
999 need_heavy = 1; 1017 need_heavy = 1;
1000 if (driver->bind && (error = driver->bind(instance, intf, id, &need_heavy)) < 0) { 1018 if (driver->bind && (error = driver->bind(instance, intf, id, &need_heavy)) < 0) {
1001 dev_dbg(dev, "%s: bind failed: %d!\n", __func__, error); 1019 dev_err(dev, "%s: bind failed: %d!\n", __func__, error);
1002 goto fail_free; 1020 goto fail_free;
1003 } 1021 }
1004 1022
@@ -1044,7 +1062,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1044 1062
1045 urb = usb_alloc_urb(iso_packets, GFP_KERNEL); 1063 urb = usb_alloc_urb(iso_packets, GFP_KERNEL);
1046 if (!urb) { 1064 if (!urb) {
1047 dev_dbg(dev, "%s: no memory for urb %d!\n", __func__, i); 1065 dev_err(dev, "%s: no memory for urb %d!\n", __func__, i);
1048 goto fail_unbind; 1066 goto fail_unbind;
1049 } 1067 }
1050 1068
@@ -1052,9 +1070,10 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1052 1070
1053 buffer = kmalloc(channel->buf_size, GFP_KERNEL); 1071 buffer = kmalloc(channel->buf_size, GFP_KERNEL);
1054 if (!buffer) { 1072 if (!buffer) {
1055 dev_dbg(dev, "%s: no memory for buffer %d!\n", __func__, i); 1073 dev_err(dev, "%s: no memory for buffer %d!\n", __func__, i);
1056 goto fail_unbind; 1074 goto fail_unbind;
1057 } 1075 }
1076 /* zero the tx padding to avoid leaking information */
1058 memset(buffer, 0, channel->buf_size); 1077 memset(buffer, 0, channel->buf_size);
1059 1078
1060 usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint, 1079 usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint,
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index 1adacd60d713..ebb79da4cb15 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -24,22 +24,21 @@
24#ifndef _USBATM_H_ 24#ifndef _USBATM_H_
25#define _USBATM_H_ 25#define _USBATM_H_
26 26
27#include <linux/config.h>
28
29/*
30#define VERBOSE_DEBUG
31*/
32
33#include <asm/semaphore.h> 27#include <asm/semaphore.h>
34#include <linux/atm.h> 28#include <linux/atm.h>
35#include <linux/atmdev.h> 29#include <linux/atmdev.h>
36#include <linux/completion.h> 30#include <linux/completion.h>
37#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/kernel.h>
38#include <linux/kref.h> 33#include <linux/kref.h>
39#include <linux/list.h> 34#include <linux/list.h>
40#include <linux/stringify.h> 35#include <linux/stringify.h>
41#include <linux/usb.h> 36#include <linux/usb.h>
42 37
38/*
39#define VERBOSE_DEBUG
40*/
41
43#ifdef DEBUG 42#ifdef DEBUG
44#define UDSL_ASSERT(x) BUG_ON(!(x)) 43#define UDSL_ASSERT(x) BUG_ON(!(x))
45#else 44#else
@@ -52,8 +51,13 @@
52 dev_info(&(instance)->usb_intf->dev , format , ## arg) 51 dev_info(&(instance)->usb_intf->dev , format , ## arg)
53#define usb_warn(instance, format, arg...) \ 52#define usb_warn(instance, format, arg...) \
54 dev_warn(&(instance)->usb_intf->dev , format , ## arg) 53 dev_warn(&(instance)->usb_intf->dev , format , ## arg)
54#ifdef DEBUG
55#define usb_dbg(instance, format, arg...) \
56 dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
57#else
55#define usb_dbg(instance, format, arg...) \ 58#define usb_dbg(instance, format, arg...) \
56 dev_dbg(&(instance)->usb_intf->dev , format , ## arg) 59 do {} while (0)
60#endif
57 61
58/* FIXME: move to dev_* once ATM is driver model aware */ 62/* FIXME: move to dev_* once ATM is driver model aware */
59#define atm_printk(level, instance, format, arg...) \ 63#define atm_printk(level, instance, format, arg...) \
@@ -69,9 +73,14 @@
69#ifdef DEBUG 73#ifdef DEBUG
70#define atm_dbg(instance, format, arg...) \ 74#define atm_dbg(instance, format, arg...) \
71 atm_printk(KERN_DEBUG, instance , format , ## arg) 75 atm_printk(KERN_DEBUG, instance , format , ## arg)
76#define atm_rldbg(instance, format, arg...) \
77 if (printk_ratelimit()) \
78 atm_printk(KERN_DEBUG, instance , format , ## arg)
72#else 79#else
73#define atm_dbg(instance, format, arg...) \ 80#define atm_dbg(instance, format, arg...) \
74 do {} while (0) 81 do {} while (0)
82#define atm_rldbg(instance, format, arg...) \
83 do {} while (0)
75#endif 84#endif
76 85
77 86
@@ -171,7 +180,7 @@ struct usbatm_data {
171 struct usbatm_channel tx_channel; 180 struct usbatm_channel tx_channel;
172 181
173 struct sk_buff_head sndqueue; 182 struct sk_buff_head sndqueue;
174 struct sk_buff *current_skb; /* being emptied */ 183 struct sk_buff *current_skb; /* being emptied */
175 184
176 struct urb *urbs[0]; 185 struct urb *urbs[0];
177}; 186};
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c
index 5c76e3aaaa5e..8f55642f376f 100644
--- a/drivers/usb/atm/xusbatm.c
+++ b/drivers/usb/atm/xusbatm.c
@@ -61,7 +61,7 @@ static int usb_intf_has_ep(const struct usb_interface *intf, u8 ep)
61 return 0; 61 return 0;
62} 62}
63 63
64static int xusbatm_bind(struct usbatm_data *usbatm_instance, 64static int xusbatm_bind(struct usbatm_data *usbatm,
65 struct usb_interface *intf, const struct usb_device_id *id, 65 struct usb_interface *intf, const struct usb_device_id *id,
66 int *need_heavy_init) 66 int *need_heavy_init)
67{ 67{
@@ -72,14 +72,14 @@ static int xusbatm_bind(struct usbatm_data *usbatm_instance,
72 u8 searched_ep = rx_ep_present ? tx_endpoint[drv_ix] : rx_endpoint[drv_ix]; 72 u8 searched_ep = rx_ep_present ? tx_endpoint[drv_ix] : rx_endpoint[drv_ix];
73 int i, ret; 73 int i, ret;
74 74
75 usb_dbg(usbatm_instance, "%s: binding driver %d: vendor %#x product %#x" 75 usb_dbg(usbatm, "%s: binding driver %d: vendor %04x product %04x"
76 " rx: ep %#x padd %d tx: ep %#x padd %d\n", 76 " rx: ep %02x padd %d tx: ep %02x padd %d\n",
77 __func__, drv_ix, vendor[drv_ix], product[drv_ix], 77 __func__, drv_ix, vendor[drv_ix], product[drv_ix],
78 rx_endpoint[drv_ix], rx_padding[drv_ix], 78 rx_endpoint[drv_ix], rx_padding[drv_ix],
79 tx_endpoint[drv_ix], tx_padding[drv_ix]); 79 tx_endpoint[drv_ix], tx_padding[drv_ix]);
80 80
81 if (!rx_ep_present && !tx_ep_present) { 81 if (!rx_ep_present && !tx_ep_present) {
82 usb_dbg(usbatm_instance, "%s: intf #%d has neither rx (%#x) nor tx (%#x) endpoint\n", 82 usb_dbg(usbatm, "%s: intf #%d has neither rx (%#x) nor tx (%#x) endpoint\n",
83 __func__, intf->altsetting->desc.bInterfaceNumber, 83 __func__, intf->altsetting->desc.bInterfaceNumber,
84 rx_endpoint[drv_ix], tx_endpoint[drv_ix]); 84 rx_endpoint[drv_ix], tx_endpoint[drv_ix]);
85 return -ENODEV; 85 return -ENODEV;
@@ -93,25 +93,26 @@ static int xusbatm_bind(struct usbatm_data *usbatm_instance,
93 93
94 if (cur_if != intf && usb_intf_has_ep(cur_if, searched_ep)) { 94 if (cur_if != intf && usb_intf_has_ep(cur_if, searched_ep)) {
95 ret = usb_driver_claim_interface(&xusbatm_usb_driver, 95 ret = usb_driver_claim_interface(&xusbatm_usb_driver,
96 cur_if, usbatm_instance); 96 cur_if, usbatm);
97 if (!ret) 97 if (!ret)
98 usb_err(usbatm_instance, "%s: failed to claim interface #%d (%d)\n", 98 usb_err(usbatm, "%s: failed to claim interface #%d (%d)\n",
99 __func__, cur_if->altsetting->desc.bInterfaceNumber, ret); 99 __func__, cur_if->altsetting->desc.bInterfaceNumber, ret);
100 return ret; 100 return ret;
101 } 101 }
102 } 102 }
103 103
104 usb_err(usbatm_instance, "%s: no interface has endpoint %#x\n", 104 usb_err(usbatm, "%s: no interface has endpoint %#x\n",
105 __func__, searched_ep); 105 __func__, searched_ep);
106 return -ENODEV; 106 return -ENODEV;
107} 107}
108 108
109static void xusbatm_unbind(struct usbatm_data *usbatm_instance, 109static void xusbatm_unbind(struct usbatm_data *usbatm,
110 struct usb_interface *intf) 110 struct usb_interface *intf)
111{ 111{
112 struct usb_device *usb_dev = interface_to_usbdev(intf); 112 struct usb_device *usb_dev = interface_to_usbdev(intf);
113 int i; 113 int i;
114 usb_dbg(usbatm_instance, "%s entered\n", __func__); 114
115 usb_dbg(usbatm, "%s entered\n", __func__);
115 116
116 for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { 117 for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) {
117 struct usb_interface *cur_if = usb_dev->actconfig->interface[i]; 118 struct usb_interface *cur_if = usb_dev->actconfig->interface[i];
@@ -120,10 +121,10 @@ static void xusbatm_unbind(struct usbatm_data *usbatm_instance,
120 } 121 }
121} 122}
122 123
123static int xusbatm_atm_start(struct usbatm_data *usbatm_instance, 124static int xusbatm_atm_start(struct usbatm_data *usbatm,
124 struct atm_dev *atm_dev) 125 struct atm_dev *atm_dev)
125{ 126{
126 atm_dbg(usbatm_instance, "%s entered\n", __func__); 127 atm_dbg(usbatm, "%s entered\n", __func__);
127 128
128 /* use random MAC as we've no way to get it from the device */ 129 /* use random MAC as we've no way to get it from the device */
129 random_ether_addr(atm_dev->esi); 130 random_ether_addr(atm_dev->esi);