diff options
Diffstat (limited to 'drivers/usb/atm/cxacru.c')
-rw-r--r-- | drivers/usb/atm/cxacru.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 1bc884051e0..a51eeedc18d 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c | |||
@@ -456,7 +456,6 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done, | |||
456 | int* actual_length) | 456 | int* actual_length) |
457 | { | 457 | { |
458 | struct timer_list timer; | 458 | struct timer_list timer; |
459 | int status; | ||
460 | 459 | ||
461 | init_timer(&timer); | 460 | init_timer(&timer); |
462 | timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT); | 461 | timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT); |
@@ -464,12 +463,11 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done, | |||
464 | timer.function = cxacru_timeout_kill; | 463 | timer.function = cxacru_timeout_kill; |
465 | add_timer(&timer); | 464 | add_timer(&timer); |
466 | wait_for_completion(done); | 465 | wait_for_completion(done); |
467 | status = urb->status; | ||
468 | del_timer_sync(&timer); | 466 | del_timer_sync(&timer); |
469 | 467 | ||
470 | if (actual_length) | 468 | if (actual_length) |
471 | *actual_length = urb->actual_length; | 469 | *actual_length = urb->actual_length; |
472 | return status; | 470 | return urb->status; /* must read status after completion */ |
473 | } | 471 | } |
474 | 472 | ||
475 | static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | 473 | static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, |
@@ -484,7 +482,9 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | |||
484 | int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE; | 482 | int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE; |
485 | 483 | ||
486 | if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) { | 484 | if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) { |
487 | dbg("too big transfer requested"); | 485 | if (printk_ratelimit()) |
486 | usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n", | ||
487 | wbuflen, rbuflen); | ||
488 | ret = -ENOMEM; | 488 | ret = -ENOMEM; |
489 | goto fail; | 489 | goto fail; |
490 | } | 490 | } |
@@ -495,8 +495,9 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | |||
495 | init_completion(&instance->rcv_done); | 495 | init_completion(&instance->rcv_done); |
496 | ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL); | 496 | ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL); |
497 | if (ret < 0) { | 497 | if (ret < 0) { |
498 | dbg("submitting read urb for cm %#x failed", cm); | 498 | if (printk_ratelimit()) |
499 | ret = ret; | 499 | usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n", |
500 | cm, ret); | ||
500 | goto fail; | 501 | goto fail; |
501 | } | 502 | } |
502 | 503 | ||
@@ -512,27 +513,29 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | |||
512 | init_completion(&instance->snd_done); | 513 | init_completion(&instance->snd_done); |
513 | ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL); | 514 | ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL); |
514 | if (ret < 0) { | 515 | if (ret < 0) { |
515 | dbg("submitting write urb for cm %#x failed", cm); | 516 | if (printk_ratelimit()) |
516 | ret = ret; | 517 | usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n", |
518 | cm, ret); | ||
517 | goto fail; | 519 | goto fail; |
518 | } | 520 | } |
519 | 521 | ||
520 | ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL); | 522 | ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL); |
521 | if (ret < 0) { | 523 | if (ret < 0) { |
522 | dbg("sending cm %#x failed", cm); | 524 | if (printk_ratelimit()) |
523 | ret = ret; | 525 | usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret); |
524 | goto fail; | 526 | goto fail; |
525 | } | 527 | } |
526 | 528 | ||
527 | ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen); | 529 | ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen); |
528 | if (ret < 0) { | 530 | if (ret < 0) { |
529 | dbg("receiving cm %#x failed", cm); | 531 | if (printk_ratelimit()) |
530 | ret = ret; | 532 | usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret); |
531 | goto fail; | 533 | goto fail; |
532 | } | 534 | } |
533 | if (actlen % CMD_PACKET_SIZE || !actlen) { | 535 | if (actlen % CMD_PACKET_SIZE || !actlen) { |
534 | dbg("response is not a positive multiple of %d: %#x", | 536 | if (printk_ratelimit()) |
535 | CMD_PACKET_SIZE, actlen); | 537 | usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n", |
538 | cm, actlen); | ||
536 | ret = -EIO; | 539 | ret = -EIO; |
537 | goto fail; | 540 | goto fail; |
538 | } | 541 | } |
@@ -540,12 +543,16 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | |||
540 | /* check the return status and copy the data to the output buffer, if needed */ | 543 | /* check the return status and copy the data to the output buffer, if needed */ |
541 | for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) { | 544 | for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) { |
542 | if (rbuf[offb] != cm) { | 545 | if (rbuf[offb] != cm) { |
543 | dbg("wrong cm %#x in response", rbuf[offb]); | 546 | if (printk_ratelimit()) |
547 | usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n", | ||
548 | rbuf[offb], cm); | ||
544 | ret = -EIO; | 549 | ret = -EIO; |
545 | goto fail; | 550 | goto fail; |
546 | } | 551 | } |
547 | if (rbuf[offb + 1] != CM_STATUS_SUCCESS) { | 552 | if (rbuf[offb + 1] != CM_STATUS_SUCCESS) { |
548 | dbg("response failed: %#x", rbuf[offb + 1]); | 553 | if (printk_ratelimit()) |
554 | usb_err(instance->usbatm, "response to cm %#x failed: %#x\n", | ||
555 | cm, rbuf[offb + 1]); | ||
549 | ret = -EIO; | 556 | ret = -EIO; |
550 | goto fail; | 557 | goto fail; |
551 | } | 558 | } |
@@ -584,14 +591,18 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ | |||
584 | for (offb = 0; offb < len; ) { | 591 | for (offb = 0; offb < len; ) { |
585 | int l = le32_to_cpu(buf[offb++]); | 592 | int l = le32_to_cpu(buf[offb++]); |
586 | if (l > stride || l > (len - offb) / 2) { | 593 | if (l > stride || l > (len - offb) / 2) { |
587 | dbg("wrong data length %#x in response", l); | 594 | if (printk_ratelimit()) |
595 | usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n", | ||
596 | cm, l); | ||
588 | ret = -EIO; | 597 | ret = -EIO; |
589 | goto cleanup; | 598 | goto cleanup; |
590 | } | 599 | } |
591 | while (l--) { | 600 | while (l--) { |
592 | offd = le32_to_cpu(buf[offb++]); | 601 | offd = le32_to_cpu(buf[offb++]); |
593 | if (offd >= size) { | 602 | if (offd >= size) { |
594 | dbg("wrong index %#x in response", offd); | 603 | if (printk_ratelimit()) |
604 | usb_err(instance->usbatm, "wrong index #%x in response to cm #%x\n", | ||
605 | offd, cm); | ||
595 | ret = -EIO; | 606 | ret = -EIO; |
596 | goto cleanup; | 607 | goto cleanup; |
597 | } | 608 | } |