aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/usbtest.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2008-04-25 21:51:10 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-05-02 13:25:52 -0400
commit28ffd79c31a7bed6f610511a4d104d1255cd1d95 (patch)
tree1ff8f9a225ebaf7bf83cc3a04e38e25645b97a0d /drivers/usb/misc/usbtest.c
parent9029b174ba22918d0a0aa3b71859854bd50c39cc (diff)
USB: usbtest displays diagnostics again
Minor cleanup to the "usbtest" driver, mostly to resolve a regression: all the important diagnostics were at KERN_DEBUG, so that when the "#define DEBUG" was removed from the top of that file it stopped providing diagnostics. Fix by using KERN_ERROR. Also: - Stop using the legacy dbg() calls - Simplify the internal debug macros - Correct some test descriptions: * Test #10 subcase 7 should *always* stall * Test #10 subcase 8 *may* stall - Diagnostic about control queue test failures is more informative - Fix some whitespace "bugs" And add a warning about the rude interaction between usbfs ioctl() and khubd during device disconnect ... don't unplug a device under test, that will wedge. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc/usbtest.c')
-rw-r--r--drivers/usb/misc/usbtest.c276
1 files changed, 133 insertions, 143 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index a51983854ca0..742be3c35947 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -79,30 +79,10 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test)
79/* set up all urbs so they can be used with either bulk or interrupt */ 79/* set up all urbs so they can be used with either bulk or interrupt */
80#define INTERRUPT_RATE 1 /* msec/transfer */ 80#define INTERRUPT_RATE 1 /* msec/transfer */
81 81
82#define xprintk(tdev,level,fmt,args...) \ 82#define ERROR(tdev, fmt, args...) \
83 dev_printk(level , &(tdev)->intf->dev , fmt , ## args) 83 dev_err(&(tdev)->intf->dev , fmt , ## args)
84 84#define WARN(tdev, fmt, args...) \
85#ifdef DEBUG 85 dev_warn(&(tdev)->intf->dev , fmt , ## args)
86#define DBG(dev,fmt,args...) \
87 xprintk(dev , KERN_DEBUG , fmt , ## args)
88#else
89#define DBG(dev,fmt,args...) \
90 do { } while (0)
91#endif /* DEBUG */
92
93#ifdef VERBOSE
94#define VDBG DBG
95#else
96#define VDBG(dev,fmt,args...) \
97 do { } while (0)
98#endif /* VERBOSE */
99
100#define ERROR(dev,fmt,args...) \
101 xprintk(dev , KERN_ERR , fmt , ## args)
102#define WARN(dev,fmt,args...) \
103 xprintk(dev , KERN_WARNING , fmt , ## args)
104#define INFO(dev,fmt,args...) \
105 xprintk(dev , KERN_INFO , fmt , ## args)
106 86
107/*-------------------------------------------------------------------------*/ 87/*-------------------------------------------------------------------------*/
108 88
@@ -236,7 +216,7 @@ static struct urb *simple_alloc_urb (
236 216
237static unsigned pattern = 0; 217static unsigned pattern = 0;
238module_param (pattern, uint, S_IRUGO); 218module_param (pattern, uint, S_IRUGO);
239// MODULE_PARM_DESC (pattern, "i/o pattern (0 == zeroes)"); 219MODULE_PARM_DESC(pattern, "i/o pattern (0 == zeroes)");
240 220
241static inline void simple_fill_buf (struct urb *urb) 221static inline void simple_fill_buf (struct urb *urb)
242{ 222{
@@ -257,7 +237,7 @@ static inline void simple_fill_buf (struct urb *urb)
257 } 237 }
258} 238}
259 239
260static inline int simple_check_buf (struct urb *urb) 240static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb)
261{ 241{
262 unsigned i; 242 unsigned i;
263 u8 expected; 243 u8 expected;
@@ -285,7 +265,7 @@ static inline int simple_check_buf (struct urb *urb)
285 } 265 }
286 if (*buf == expected) 266 if (*buf == expected)
287 continue; 267 continue;
288 dbg ("buf[%d] = %d (not %d)", i, *buf, expected); 268 ERROR(tdev, "buf[%d] = %d (not %d)\n", i, *buf, expected);
289 return -EINVAL; 269 return -EINVAL;
290 } 270 }
291 return 0; 271 return 0;
@@ -299,6 +279,7 @@ static void simple_free_urb (struct urb *urb)
299} 279}
300 280
301static int simple_io ( 281static int simple_io (
282 struct usbtest_dev *tdev,
302 struct urb *urb, 283 struct urb *urb,
303 int iterations, 284 int iterations,
304 int vary, 285 int vary,
@@ -324,7 +305,7 @@ static int simple_io (
324 retval = urb->status; 305 retval = urb->status;
325 urb->dev = udev; 306 urb->dev = udev;
326 if (retval == 0 && usb_pipein (urb->pipe)) 307 if (retval == 0 && usb_pipein (urb->pipe))
327 retval = simple_check_buf (urb); 308 retval = simple_check_buf(tdev, urb);
328 309
329 if (vary) { 310 if (vary) {
330 int len = urb->transfer_buffer_length; 311 int len = urb->transfer_buffer_length;
@@ -341,7 +322,7 @@ static int simple_io (
341 urb->transfer_buffer_length = max; 322 urb->transfer_buffer_length = max;
342 323
343 if (expected != retval) 324 if (expected != retval)
344 dev_dbg (&udev->dev, 325 dev_err(&udev->dev,
345 "%s failed, iterations left %d, status %d (not %d)\n", 326 "%s failed, iterations left %d, status %d (not %d)\n",
346 label, iterations, retval, expected); 327 label, iterations, retval, expected);
347 return retval; 328 return retval;
@@ -357,7 +338,7 @@ static int simple_io (
357static void free_sglist (struct scatterlist *sg, int nents) 338static void free_sglist (struct scatterlist *sg, int nents)
358{ 339{
359 unsigned i; 340 unsigned i;
360 341
361 if (!sg) 342 if (!sg)
362 return; 343 return;
363 for (i = 0; i < nents; i++) { 344 for (i = 0; i < nents; i++) {
@@ -415,7 +396,7 @@ alloc_sglist (int nents, int max, int vary)
415} 396}
416 397
417static int perform_sglist ( 398static int perform_sglist (
418 struct usb_device *udev, 399 struct usbtest_dev *tdev,
419 unsigned iterations, 400 unsigned iterations,
420 int pipe, 401 int pipe,
421 struct usb_sg_request *req, 402 struct usb_sg_request *req,
@@ -423,6 +404,7 @@ static int perform_sglist (
423 int nents 404 int nents
424) 405)
425{ 406{
407 struct usb_device *udev = testdev_to_usbdev(tdev);
426 int retval = 0; 408 int retval = 0;
427 409
428 while (retval == 0 && iterations-- > 0) { 410 while (retval == 0 && iterations-- > 0) {
@@ -431,7 +413,7 @@ static int perform_sglist (
431 ? (INTERRUPT_RATE << 3) 413 ? (INTERRUPT_RATE << 3)
432 : INTERRUPT_RATE, 414 : INTERRUPT_RATE,
433 sg, nents, 0, GFP_KERNEL); 415 sg, nents, 0, GFP_KERNEL);
434 416
435 if (retval) 417 if (retval)
436 break; 418 break;
437 usb_sg_wait (req); 419 usb_sg_wait (req);
@@ -446,7 +428,8 @@ static int perform_sglist (
446 // failure if retval is as we expected ... 428 // failure if retval is as we expected ...
447 429
448 if (retval) 430 if (retval)
449 dbg ("perform_sglist failed, iterations left %d, status %d", 431 ERROR(tdev, "perform_sglist failed, "
432 "iterations left %d, status %d\n",
450 iterations, retval); 433 iterations, retval);
451 return retval; 434 return retval;
452} 435}
@@ -505,28 +488,28 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
505 alternate); 488 alternate);
506} 489}
507 490
508static int is_good_config (char *buf, int len) 491static int is_good_config(struct usbtest_dev *tdev, int len)
509{ 492{
510 struct usb_config_descriptor *config; 493 struct usb_config_descriptor *config;
511 494
512 if (len < sizeof *config) 495 if (len < sizeof *config)
513 return 0; 496 return 0;
514 config = (struct usb_config_descriptor *) buf; 497 config = (struct usb_config_descriptor *) tdev->buf;
515 498
516 switch (config->bDescriptorType) { 499 switch (config->bDescriptorType) {
517 case USB_DT_CONFIG: 500 case USB_DT_CONFIG:
518 case USB_DT_OTHER_SPEED_CONFIG: 501 case USB_DT_OTHER_SPEED_CONFIG:
519 if (config->bLength != 9) { 502 if (config->bLength != 9) {
520 dbg ("bogus config descriptor length"); 503 ERROR(tdev, "bogus config descriptor length\n");
521 return 0; 504 return 0;
522 } 505 }
523 /* this bit 'must be 1' but often isn't */ 506 /* this bit 'must be 1' but often isn't */
524 if (!realworld && !(config->bmAttributes & 0x80)) { 507 if (!realworld && !(config->bmAttributes & 0x80)) {
525 dbg ("high bit of config attributes not set"); 508 ERROR(tdev, "high bit of config attributes not set\n");
526 return 0; 509 return 0;
527 } 510 }
528 if (config->bmAttributes & 0x1f) { /* reserved == 0 */ 511 if (config->bmAttributes & 0x1f) { /* reserved == 0 */
529 dbg ("reserved config bits set"); 512 ERROR(tdev, "reserved config bits set\n");
530 return 0; 513 return 0;
531 } 514 }
532 break; 515 break;
@@ -538,7 +521,7 @@ static int is_good_config (char *buf, int len)
538 return 1; 521 return 1;
539 if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ 522 if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */
540 return 1; 523 return 1;
541 dbg ("bogus config descriptor read size"); 524 ERROR(tdev, "bogus config descriptor read size\n");
542 return 0; 525 return 0;
543} 526}
544 527
@@ -571,7 +554,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
571 /* 9.2.3 constrains the range here */ 554 /* 9.2.3 constrains the range here */
572 alt = iface->altsetting [i].desc.bAlternateSetting; 555 alt = iface->altsetting [i].desc.bAlternateSetting;
573 if (alt < 0 || alt >= iface->num_altsetting) { 556 if (alt < 0 || alt >= iface->num_altsetting) {
574 dev_dbg (&iface->dev, 557 dev_err(&iface->dev,
575 "invalid alt [%d].bAltSetting = %d\n", 558 "invalid alt [%d].bAltSetting = %d\n",
576 i, alt); 559 i, alt);
577 } 560 }
@@ -583,7 +566,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
583 /* [9.4.10] set_interface */ 566 /* [9.4.10] set_interface */
584 retval = set_altsetting (dev, alt); 567 retval = set_altsetting (dev, alt);
585 if (retval) { 568 if (retval) {
586 dev_dbg (&iface->dev, "can't set_interface = %d, %d\n", 569 dev_err(&iface->dev, "can't set_interface = %d, %d\n",
587 alt, retval); 570 alt, retval);
588 return retval; 571 return retval;
589 } 572 }
@@ -591,7 +574,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
591 /* [9.4.4] get_interface always works */ 574 /* [9.4.4] get_interface always works */
592 retval = get_altsetting (dev); 575 retval = get_altsetting (dev);
593 if (retval != alt) { 576 if (retval != alt) {
594 dev_dbg (&iface->dev, "get alt should be %d, was %d\n", 577 dev_err(&iface->dev, "get alt should be %d, was %d\n",
595 alt, retval); 578 alt, retval);
596 return (retval < 0) ? retval : -EDOM; 579 return (retval < 0) ? retval : -EDOM;
597 } 580 }
@@ -611,7 +594,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
611 USB_DIR_IN | USB_RECIP_DEVICE, 594 USB_DIR_IN | USB_RECIP_DEVICE,
612 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); 595 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT);
613 if (retval != 1 || dev->buf [0] != expected) { 596 if (retval != 1 || dev->buf [0] != expected) {
614 dev_dbg (&iface->dev, "get config --> %d %d (1 %d)\n", 597 dev_err(&iface->dev, "get config --> %d %d (1 %d)\n",
615 retval, dev->buf[0], expected); 598 retval, dev->buf[0], expected);
616 return (retval < 0) ? retval : -EDOM; 599 return (retval < 0) ? retval : -EDOM;
617 } 600 }
@@ -621,7 +604,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
621 retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, 604 retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0,
622 dev->buf, sizeof udev->descriptor); 605 dev->buf, sizeof udev->descriptor);
623 if (retval != sizeof udev->descriptor) { 606 if (retval != sizeof udev->descriptor) {
624 dev_dbg (&iface->dev, "dev descriptor --> %d\n", retval); 607 dev_err(&iface->dev, "dev descriptor --> %d\n", retval);
625 return (retval < 0) ? retval : -EDOM; 608 return (retval < 0) ? retval : -EDOM;
626 } 609 }
627 610
@@ -629,8 +612,8 @@ static int ch9_postconfig (struct usbtest_dev *dev)
629 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { 612 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) {
630 retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, 613 retval = usb_get_descriptor (udev, USB_DT_CONFIG, i,
631 dev->buf, TBUF_SIZE); 614 dev->buf, TBUF_SIZE);
632 if (!is_good_config (dev->buf, retval)) { 615 if (!is_good_config(dev, retval)) {
633 dev_dbg (&iface->dev, 616 dev_err(&iface->dev,
634 "config [%d] descriptor --> %d\n", 617 "config [%d] descriptor --> %d\n",
635 i, retval); 618 i, retval);
636 return (retval < 0) ? retval : -EDOM; 619 return (retval < 0) ? retval : -EDOM;
@@ -650,14 +633,14 @@ static int ch9_postconfig (struct usbtest_dev *dev)
650 sizeof (struct usb_qualifier_descriptor)); 633 sizeof (struct usb_qualifier_descriptor));
651 if (retval == -EPIPE) { 634 if (retval == -EPIPE) {
652 if (udev->speed == USB_SPEED_HIGH) { 635 if (udev->speed == USB_SPEED_HIGH) {
653 dev_dbg (&iface->dev, 636 dev_err(&iface->dev,
654 "hs dev qualifier --> %d\n", 637 "hs dev qualifier --> %d\n",
655 retval); 638 retval);
656 return (retval < 0) ? retval : -EDOM; 639 return (retval < 0) ? retval : -EDOM;
657 } 640 }
658 /* usb2.0 but not high-speed capable; fine */ 641 /* usb2.0 but not high-speed capable; fine */
659 } else if (retval != sizeof (struct usb_qualifier_descriptor)) { 642 } else if (retval != sizeof (struct usb_qualifier_descriptor)) {
660 dev_dbg (&iface->dev, "dev qualifier --> %d\n", retval); 643 dev_err(&iface->dev, "dev qualifier --> %d\n", retval);
661 return (retval < 0) ? retval : -EDOM; 644 return (retval < 0) ? retval : -EDOM;
662 } else 645 } else
663 d = (struct usb_qualifier_descriptor *) dev->buf; 646 d = (struct usb_qualifier_descriptor *) dev->buf;
@@ -669,8 +652,8 @@ static int ch9_postconfig (struct usbtest_dev *dev)
669 retval = usb_get_descriptor (udev, 652 retval = usb_get_descriptor (udev,
670 USB_DT_OTHER_SPEED_CONFIG, i, 653 USB_DT_OTHER_SPEED_CONFIG, i,
671 dev->buf, TBUF_SIZE); 654 dev->buf, TBUF_SIZE);
672 if (!is_good_config (dev->buf, retval)) { 655 if (!is_good_config(dev, retval)) {
673 dev_dbg (&iface->dev, 656 dev_err(&iface->dev,
674 "other speed config --> %d\n", 657 "other speed config --> %d\n",
675 retval); 658 retval);
676 return (retval < 0) ? retval : -EDOM; 659 return (retval < 0) ? retval : -EDOM;
@@ -683,7 +666,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
683 /* [9.4.5] get_status always works */ 666 /* [9.4.5] get_status always works */
684 retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); 667 retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf);
685 if (retval != 2) { 668 if (retval != 2) {
686 dev_dbg (&iface->dev, "get dev status --> %d\n", retval); 669 dev_err(&iface->dev, "get dev status --> %d\n", retval);
687 return (retval < 0) ? retval : -EDOM; 670 return (retval < 0) ? retval : -EDOM;
688 } 671 }
689 672
@@ -693,11 +676,11 @@ static int ch9_postconfig (struct usbtest_dev *dev)
693 retval = usb_get_status (udev, USB_RECIP_INTERFACE, 676 retval = usb_get_status (udev, USB_RECIP_INTERFACE,
694 iface->altsetting [0].desc.bInterfaceNumber, dev->buf); 677 iface->altsetting [0].desc.bInterfaceNumber, dev->buf);
695 if (retval != 2) { 678 if (retval != 2) {
696 dev_dbg (&iface->dev, "get interface status --> %d\n", retval); 679 dev_err(&iface->dev, "get interface status --> %d\n", retval);
697 return (retval < 0) ? retval : -EDOM; 680 return (retval < 0) ? retval : -EDOM;
698 } 681 }
699 // FIXME get status for each endpoint in the interface 682 // FIXME get status for each endpoint in the interface
700 683
701 return 0; 684 return 0;
702} 685}
703 686
@@ -752,8 +735,9 @@ static void ctrl_complete (struct urb *urb)
752 */ 735 */
753 if (subcase->number > 0) { 736 if (subcase->number > 0) {
754 if ((subcase->number - ctx->last) != 1) { 737 if ((subcase->number - ctx->last) != 1) {
755 dbg ("subcase %d completed out of order, last %d", 738 ERROR(ctx->dev,
756 subcase->number, ctx->last); 739 "subcase %d completed out of order, last %d\n",
740 subcase->number, ctx->last);
757 status = -EDOM; 741 status = -EDOM;
758 ctx->last = subcase->number; 742 ctx->last = subcase->number;
759 goto error; 743 goto error;
@@ -777,7 +761,7 @@ static void ctrl_complete (struct urb *urb)
777 else if (subcase->number == 12 && status == -EPIPE) 761 else if (subcase->number == 12 && status == -EPIPE)
778 status = 0; 762 status = 0;
779 else 763 else
780 dbg ("subtest %d error, status %d", 764 ERROR(ctx->dev, "subtest %d error, status %d\n",
781 subcase->number, status); 765 subcase->number, status);
782 } 766 }
783 767
@@ -788,9 +772,12 @@ error:
788 int i; 772 int i;
789 773
790 ctx->status = status; 774 ctx->status = status;
791 info ("control queue %02x.%02x, err %d, %d left", 775 ERROR(ctx->dev, "control queue %02x.%02x, err %d, "
776 "%d left, subcase %d, len %d/%d\n",
792 reqp->bRequestType, reqp->bRequest, 777 reqp->bRequestType, reqp->bRequest,
793 status, ctx->count); 778 status, ctx->count, subcase->number,
779 urb->actual_length,
780 urb->transfer_buffer_length);
794 781
795 /* FIXME this "unlink everything" exit route should 782 /* FIXME this "unlink everything" exit route should
796 * be a separate test case. 783 * be a separate test case.
@@ -799,7 +786,8 @@ error:
799 /* unlink whatever's still pending */ 786 /* unlink whatever's still pending */
800 for (i = 1; i < ctx->param->sglen; i++) { 787 for (i = 1; i < ctx->param->sglen; i++) {
801 struct urb *u = ctx->urb [ 788 struct urb *u = ctx->urb [
802 (i + subcase->number) % ctx->param->sglen]; 789 (i + subcase->number)
790 % ctx->param->sglen];
803 791
804 if (u == urb || !u->dev) 792 if (u == urb || !u->dev)
805 continue; 793 continue;
@@ -812,7 +800,8 @@ error:
812 case -EIDRM: 800 case -EIDRM:
813 continue; 801 continue;
814 default: 802 default:
815 dbg ("urb unlink --> %d", status); 803 ERROR(ctx->dev, "urb unlink --> %d\n",
804 status);
816 } 805 }
817 } 806 }
818 status = ctx->status; 807 status = ctx->status;
@@ -822,14 +811,15 @@ error:
822 /* resubmit if we need to, else mark this as done */ 811 /* resubmit if we need to, else mark this as done */
823 if ((status == 0) && (ctx->pending < ctx->count)) { 812 if ((status == 0) && (ctx->pending < ctx->count)) {
824 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { 813 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
825 dbg ("can't resubmit ctrl %02x.%02x, err %d", 814 ERROR(ctx->dev,
815 "can't resubmit ctrl %02x.%02x, err %d\n",
826 reqp->bRequestType, reqp->bRequest, status); 816 reqp->bRequestType, reqp->bRequest, status);
827 urb->dev = NULL; 817 urb->dev = NULL;
828 } else 818 } else
829 ctx->pending++; 819 ctx->pending++;
830 } else 820 } else
831 urb->dev = NULL; 821 urb->dev = NULL;
832 822
833 /* signal completion when nothing's queued */ 823 /* signal completion when nothing's queued */
834 if (ctx->pending == 0) 824 if (ctx->pending == 0)
835 complete (&ctx->complete); 825 complete (&ctx->complete);
@@ -918,11 +908,11 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
918 req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); 908 req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8);
919 // interface == 0 909 // interface == 0
920 len = sizeof (struct usb_interface_descriptor); 910 len = sizeof (struct usb_interface_descriptor);
921 expected = EPIPE; 911 expected = -EPIPE;
922 break; 912 break;
923 // NOTE: two consecutive stalls in the queue here. 913 // NOTE: two consecutive stalls in the queue here.
924 // that tests fault recovery a bit more aggressively. 914 // that tests fault recovery a bit more aggressively.
925 case 8: // clear endpoint halt (USUALLY STALLS) 915 case 8: // clear endpoint halt (MAY STALL)
926 req.bRequest = USB_REQ_CLEAR_FEATURE; 916 req.bRequest = USB_REQ_CLEAR_FEATURE;
927 req.bRequestType = USB_RECIP_ENDPOINT; 917 req.bRequestType = USB_RECIP_ENDPOINT;
928 // wValue 0 == ep halt 918 // wValue 0 == ep halt
@@ -965,7 +955,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
965 break; 955 break;
966 case 14: // short read; try to fill the last packet 956 case 14: // short read; try to fill the last packet
967 req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); 957 req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0);
968 // device descriptor size == 18 bytes 958 /* device descriptor size == 18 bytes */
969 len = udev->descriptor.bMaxPacketSize0; 959 len = udev->descriptor.bMaxPacketSize0;
970 switch (len) { 960 switch (len) {
971 case 8: len = 24; break; 961 case 8: len = 24; break;
@@ -974,7 +964,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
974 expected = -EREMOTEIO; 964 expected = -EREMOTEIO;
975 break; 965 break;
976 default: 966 default:
977 err ("bogus number of ctrl queue testcases!"); 967 ERROR(dev, "bogus number of ctrl queue testcases!\n");
978 context.status = -EINVAL; 968 context.status = -EINVAL;
979 goto cleanup; 969 goto cleanup;
980 } 970 }
@@ -1003,7 +993,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
1003 for (i = 0; i < param->sglen; i++) { 993 for (i = 0; i < param->sglen; i++) {
1004 context.status = usb_submit_urb (urb [i], GFP_ATOMIC); 994 context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
1005 if (context.status != 0) { 995 if (context.status != 0) {
1006 dbg ("can't submit urb[%d], status %d", 996 ERROR(dev, "can't submit urb[%d], status %d\n",
1007 i, context.status); 997 i, context.status);
1008 context.count = context.pending; 998 context.count = context.pending;
1009 break; 999 break;
@@ -1070,7 +1060,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1070 * due to errors, or is just NAKing requests. 1060 * due to errors, or is just NAKing requests.
1071 */ 1061 */
1072 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { 1062 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
1073 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval); 1063 dev_err(&dev->intf->dev, "submit fail %d\n", retval);
1074 return retval; 1064 return retval;
1075 } 1065 }
1076 1066
@@ -1087,13 +1077,13 @@ retry:
1087 * "normal" drivers would prevent resubmission, but 1077 * "normal" drivers would prevent resubmission, but
1088 * since we're testing unlink paths, we can't. 1078 * since we're testing unlink paths, we can't.
1089 */ 1079 */
1090 dev_dbg (&dev->intf->dev, "unlink retry\n"); 1080 ERROR(dev, "unlink retry\n");
1091 goto retry; 1081 goto retry;
1092 } 1082 }
1093 } else 1083 } else
1094 usb_kill_urb (urb); 1084 usb_kill_urb (urb);
1095 if (!(retval == 0 || retval == -EINPROGRESS)) { 1085 if (!(retval == 0 || retval == -EINPROGRESS)) {
1096 dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval); 1086 dev_err(&dev->intf->dev, "unlink fail %d\n", retval);
1097 return retval; 1087 return retval;
1098 } 1088 }
1099 1089
@@ -1121,7 +1111,7 @@ static int unlink_simple (struct usbtest_dev *dev, int pipe, int len)
1121 1111
1122/*-------------------------------------------------------------------------*/ 1112/*-------------------------------------------------------------------------*/
1123 1113
1124static int verify_not_halted (int ep, struct urb *urb) 1114static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1125{ 1115{
1126 int retval; 1116 int retval;
1127 u16 status; 1117 u16 status;
@@ -1129,20 +1119,21 @@ static int verify_not_halted (int ep, struct urb *urb)
1129 /* shouldn't look or act halted */ 1119 /* shouldn't look or act halted */
1130 retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); 1120 retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1131 if (retval < 0) { 1121 if (retval < 0) {
1132 dbg ("ep %02x couldn't get no-halt status, %d", ep, retval); 1122 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n",
1123 ep, retval);
1133 return retval; 1124 return retval;
1134 } 1125 }
1135 if (status != 0) { 1126 if (status != 0) {
1136 dbg ("ep %02x bogus status: %04x != 0", ep, status); 1127 ERROR(tdev, "ep %02x bogus status: %04x != 0\n", ep, status);
1137 return -EINVAL; 1128 return -EINVAL;
1138 } 1129 }
1139 retval = simple_io (urb, 1, 0, 0, __func__); 1130 retval = simple_io(tdev, urb, 1, 0, 0, __func__);
1140 if (retval != 0) 1131 if (retval != 0)
1141 return -EINVAL; 1132 return -EINVAL;
1142 return 0; 1133 return 0;
1143} 1134}
1144 1135
1145static int verify_halted (int ep, struct urb *urb) 1136static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1146{ 1137{
1147 int retval; 1138 int retval;
1148 u16 status; 1139 u16 status;
@@ -1150,29 +1141,30 @@ static int verify_halted (int ep, struct urb *urb)
1150 /* should look and act halted */ 1141 /* should look and act halted */
1151 retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); 1142 retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1152 if (retval < 0) { 1143 if (retval < 0) {
1153 dbg ("ep %02x couldn't get halt status, %d", ep, retval); 1144 ERROR(tdev, "ep %02x couldn't get halt status, %d\n",
1145 ep, retval);
1154 return retval; 1146 return retval;
1155 } 1147 }
1156 le16_to_cpus(&status); 1148 le16_to_cpus(&status);
1157 if (status != 1) { 1149 if (status != 1) {
1158 dbg ("ep %02x bogus status: %04x != 1", ep, status); 1150 ERROR(tdev, "ep %02x bogus status: %04x != 1\n", ep, status);
1159 return -EINVAL; 1151 return -EINVAL;
1160 } 1152 }
1161 retval = simple_io (urb, 1, 0, -EPIPE, __func__); 1153 retval = simple_io(tdev, urb, 1, 0, -EPIPE, __func__);
1162 if (retval != -EPIPE) 1154 if (retval != -EPIPE)
1163 return -EINVAL; 1155 return -EINVAL;
1164 retval = simple_io (urb, 1, 0, -EPIPE, "verify_still_halted"); 1156 retval = simple_io(tdev, urb, 1, 0, -EPIPE, "verify_still_halted");
1165 if (retval != -EPIPE) 1157 if (retval != -EPIPE)
1166 return -EINVAL; 1158 return -EINVAL;
1167 return 0; 1159 return 0;
1168} 1160}
1169 1161
1170static int test_halt (int ep, struct urb *urb) 1162static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
1171{ 1163{
1172 int retval; 1164 int retval;
1173 1165
1174 /* shouldn't look or act halted now */ 1166 /* shouldn't look or act halted now */
1175 retval = verify_not_halted (ep, urb); 1167 retval = verify_not_halted(tdev, ep, urb);
1176 if (retval < 0) 1168 if (retval < 0)
1177 return retval; 1169 return retval;
1178 1170
@@ -1182,20 +1174,20 @@ static int test_halt (int ep, struct urb *urb)
1182 USB_ENDPOINT_HALT, ep, 1174 USB_ENDPOINT_HALT, ep,
1183 NULL, 0, USB_CTRL_SET_TIMEOUT); 1175 NULL, 0, USB_CTRL_SET_TIMEOUT);
1184 if (retval < 0) { 1176 if (retval < 0) {
1185 dbg ("ep %02x couldn't set halt, %d", ep, retval); 1177 ERROR(tdev, "ep %02x couldn't set halt, %d\n", ep, retval);
1186 return retval; 1178 return retval;
1187 } 1179 }
1188 retval = verify_halted (ep, urb); 1180 retval = verify_halted(tdev, ep, urb);
1189 if (retval < 0) 1181 if (retval < 0)
1190 return retval; 1182 return retval;
1191 1183
1192 /* clear halt (tests API + protocol), verify it worked */ 1184 /* clear halt (tests API + protocol), verify it worked */
1193 retval = usb_clear_halt (urb->dev, urb->pipe); 1185 retval = usb_clear_halt (urb->dev, urb->pipe);
1194 if (retval < 0) { 1186 if (retval < 0) {
1195 dbg ("ep %02x couldn't clear halt, %d", ep, retval); 1187 ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval);
1196 return retval; 1188 return retval;
1197 } 1189 }
1198 retval = verify_not_halted (ep, urb); 1190 retval = verify_not_halted(tdev, ep, urb);
1199 if (retval < 0) 1191 if (retval < 0)
1200 return retval; 1192 return retval;
1201 1193
@@ -1217,7 +1209,7 @@ static int halt_simple (struct usbtest_dev *dev)
1217 if (dev->in_pipe) { 1209 if (dev->in_pipe) {
1218 ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN; 1210 ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN;
1219 urb->pipe = dev->in_pipe; 1211 urb->pipe = dev->in_pipe;
1220 retval = test_halt (ep, urb); 1212 retval = test_halt(dev, ep, urb);
1221 if (retval < 0) 1213 if (retval < 0)
1222 goto done; 1214 goto done;
1223 } 1215 }
@@ -1225,7 +1217,7 @@ static int halt_simple (struct usbtest_dev *dev)
1225 if (dev->out_pipe) { 1217 if (dev->out_pipe) {
1226 ep = usb_pipeendpoint (dev->out_pipe); 1218 ep = usb_pipeendpoint (dev->out_pipe);
1227 urb->pipe = dev->out_pipe; 1219 urb->pipe = dev->out_pipe;
1228 retval = test_halt (ep, urb); 1220 retval = test_halt(dev, ep, urb);
1229 } 1221 }
1230done: 1222done:
1231 simple_free_urb (urb); 1223 simple_free_urb (urb);
@@ -1275,7 +1267,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1275 if (retval != len) { 1267 if (retval != len) {
1276 what = "write"; 1268 what = "write";
1277 if (retval >= 0) { 1269 if (retval >= 0) {
1278 INFO(dev, "ctrl_out, wlen %d (expected %d)\n", 1270 ERROR(dev, "ctrl_out, wlen %d (expected %d)\n",
1279 retval, len); 1271 retval, len);
1280 retval = -EBADMSG; 1272 retval = -EBADMSG;
1281 } 1273 }
@@ -1289,7 +1281,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1289 if (retval != len) { 1281 if (retval != len) {
1290 what = "read"; 1282 what = "read";
1291 if (retval >= 0) { 1283 if (retval >= 0) {
1292 INFO(dev, "ctrl_out, rlen %d (expected %d)\n", 1284 ERROR(dev, "ctrl_out, rlen %d (expected %d)\n",
1293 retval, len); 1285 retval, len);
1294 retval = -EBADMSG; 1286 retval = -EBADMSG;
1295 } 1287 }
@@ -1299,7 +1291,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1299 /* fail if we can't verify */ 1291 /* fail if we can't verify */
1300 for (j = 0; j < len; j++) { 1292 for (j = 0; j < len; j++) {
1301 if (buf [j] != (u8) (i + j)) { 1293 if (buf [j] != (u8) (i + j)) {
1302 INFO (dev, "ctrl_out, byte %d is %d not %d\n", 1294 ERROR(dev, "ctrl_out, byte %d is %d not %d\n",
1303 j, buf [j], (u8) i + j); 1295 j, buf [j], (u8) i + j);
1304 retval = -EBADMSG; 1296 retval = -EBADMSG;
1305 break; 1297 break;
@@ -1321,7 +1313,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1321 } 1313 }
1322 1314
1323 if (retval < 0) 1315 if (retval < 0)
1324 INFO (dev, "ctrl_out %s failed, code %d, count %d\n", 1316 ERROR (dev, "ctrl_out %s failed, code %d, count %d\n",
1325 what, retval, i); 1317 what, retval, i);
1326 1318
1327 kfree (buf); 1319 kfree (buf);
@@ -1366,7 +1358,7 @@ static void iso_callback (struct urb *urb)
1366 case 0: 1358 case 0:
1367 goto done; 1359 goto done;
1368 default: 1360 default:
1369 dev_dbg (&ctx->dev->intf->dev, 1361 dev_err(&ctx->dev->intf->dev,
1370 "iso resubmit err %d\n", 1362 "iso resubmit err %d\n",
1371 status); 1363 status);
1372 /* FALLTHROUGH */ 1364 /* FALLTHROUGH */
@@ -1381,7 +1373,7 @@ static void iso_callback (struct urb *urb)
1381 ctx->pending--; 1373 ctx->pending--;
1382 if (ctx->pending == 0) { 1374 if (ctx->pending == 0) {
1383 if (ctx->errors) 1375 if (ctx->errors)
1384 dev_dbg (&ctx->dev->intf->dev, 1376 dev_err(&ctx->dev->intf->dev,
1385 "iso test, %lu errors out of %lu\n", 1377 "iso test, %lu errors out of %lu\n",
1386 ctx->errors, ctx->packet_count); 1378 ctx->errors, ctx->packet_count);
1387 complete (&ctx->done); 1379 complete (&ctx->done);
@@ -1458,7 +1450,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1458 1450
1459 memset (urbs, 0, sizeof urbs); 1451 memset (urbs, 0, sizeof urbs);
1460 udev = testdev_to_usbdev (dev); 1452 udev = testdev_to_usbdev (dev);
1461 dev_dbg (&dev->intf->dev, 1453 dev_info(&dev->intf->dev,
1462 "... iso period %d %sframes, wMaxPacket %04x\n", 1454 "... iso period %d %sframes, wMaxPacket %04x\n",
1463 1 << (desc->bInterval - 1), 1455 1 << (desc->bInterval - 1),
1464 (udev->speed == USB_SPEED_HIGH) ? "micro" : "", 1456 (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
@@ -1475,7 +1467,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1475 urbs [i]->context = &context; 1467 urbs [i]->context = &context;
1476 } 1468 }
1477 packets *= param->iterations; 1469 packets *= param->iterations;
1478 dev_dbg (&dev->intf->dev, 1470 dev_info(&dev->intf->dev,
1479 "... total %lu msec (%lu packets)\n", 1471 "... total %lu msec (%lu packets)\n",
1480 (packets * (1 << (desc->bInterval - 1))) 1472 (packets * (1 << (desc->bInterval - 1)))
1481 / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), 1473 / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
@@ -1537,6 +1529,13 @@ fail:
1537 * except indirectly by consuming USB bandwidth and CPU resources for test 1529 * except indirectly by consuming USB bandwidth and CPU resources for test
1538 * threads and request completion. But the only way to know that for sure 1530 * threads and request completion. But the only way to know that for sure
1539 * is to test when HC queues are in use by many devices. 1531 * is to test when HC queues are in use by many devices.
1532 *
1533 * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
1534 * it locks out usbcore in certain code paths. Notably, if you disconnect
1535 * the device-under-test, khubd will wait block forever waiting for the
1536 * ioctl to complete ... so that usb_disconnect() can abort the pending
1537 * urbs and then call usbtest_disconnect(). To abort a test, you're best
1538 * off just killing the userspace task and waiting for it to exit.
1540 */ 1539 */
1541 1540
1542static int 1541static int
@@ -1575,7 +1574,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1575 * altsettings; force a default so most tests don't need to check. 1574 * altsettings; force a default so most tests don't need to check.
1576 */ 1575 */
1577 if (dev->info->alt >= 0) { 1576 if (dev->info->alt >= 0) {
1578 int res; 1577 int res;
1579 1578
1580 if (intf->altsetting->desc.bInterfaceNumber) { 1579 if (intf->altsetting->desc.bInterfaceNumber) {
1581 mutex_unlock(&dev->lock); 1580 mutex_unlock(&dev->lock);
@@ -1604,7 +1603,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1604 switch (param->test_num) { 1603 switch (param->test_num) {
1605 1604
1606 case 0: 1605 case 0:
1607 dev_dbg (&intf->dev, "TEST 0: NOP\n"); 1606 dev_info(&intf->dev, "TEST 0: NOP\n");
1608 retval = 0; 1607 retval = 0;
1609 break; 1608 break;
1610 1609
@@ -1612,7 +1611,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1612 case 1: 1611 case 1:
1613 if (dev->out_pipe == 0) 1612 if (dev->out_pipe == 0)
1614 break; 1613 break;
1615 dev_dbg (&intf->dev, 1614 dev_info(&intf->dev,
1616 "TEST 1: write %d bytes %u times\n", 1615 "TEST 1: write %d bytes %u times\n",
1617 param->length, param->iterations); 1616 param->length, param->iterations);
1618 urb = simple_alloc_urb (udev, dev->out_pipe, param->length); 1617 urb = simple_alloc_urb (udev, dev->out_pipe, param->length);
@@ -1621,13 +1620,13 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1621 break; 1620 break;
1622 } 1621 }
1623 // FIRMWARE: bulk sink (maybe accepts short writes) 1622 // FIRMWARE: bulk sink (maybe accepts short writes)
1624 retval = simple_io (urb, param->iterations, 0, 0, "test1"); 1623 retval = simple_io(dev, urb, param->iterations, 0, 0, "test1");
1625 simple_free_urb (urb); 1624 simple_free_urb (urb);
1626 break; 1625 break;
1627 case 2: 1626 case 2:
1628 if (dev->in_pipe == 0) 1627 if (dev->in_pipe == 0)
1629 break; 1628 break;
1630 dev_dbg (&intf->dev, 1629 dev_info(&intf->dev,
1631 "TEST 2: read %d bytes %u times\n", 1630 "TEST 2: read %d bytes %u times\n",
1632 param->length, param->iterations); 1631 param->length, param->iterations);
1633 urb = simple_alloc_urb (udev, dev->in_pipe, param->length); 1632 urb = simple_alloc_urb (udev, dev->in_pipe, param->length);
@@ -1636,13 +1635,13 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1636 break; 1635 break;
1637 } 1636 }
1638 // FIRMWARE: bulk source (maybe generates short writes) 1637 // FIRMWARE: bulk source (maybe generates short writes)
1639 retval = simple_io (urb, param->iterations, 0, 0, "test2"); 1638 retval = simple_io(dev, urb, param->iterations, 0, 0, "test2");
1640 simple_free_urb (urb); 1639 simple_free_urb (urb);
1641 break; 1640 break;
1642 case 3: 1641 case 3:
1643 if (dev->out_pipe == 0 || param->vary == 0) 1642 if (dev->out_pipe == 0 || param->vary == 0)
1644 break; 1643 break;
1645 dev_dbg (&intf->dev, 1644 dev_info(&intf->dev,
1646 "TEST 3: write/%d 0..%d bytes %u times\n", 1645 "TEST 3: write/%d 0..%d bytes %u times\n",
1647 param->vary, param->length, param->iterations); 1646 param->vary, param->length, param->iterations);
1648 urb = simple_alloc_urb (udev, dev->out_pipe, param->length); 1647 urb = simple_alloc_urb (udev, dev->out_pipe, param->length);
@@ -1651,14 +1650,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1651 break; 1650 break;
1652 } 1651 }
1653 // FIRMWARE: bulk sink (maybe accepts short writes) 1652 // FIRMWARE: bulk sink (maybe accepts short writes)
1654 retval = simple_io (urb, param->iterations, param->vary, 1653 retval = simple_io(dev, urb, param->iterations, param->vary,
1655 0, "test3"); 1654 0, "test3");
1656 simple_free_urb (urb); 1655 simple_free_urb (urb);
1657 break; 1656 break;
1658 case 4: 1657 case 4:
1659 if (dev->in_pipe == 0 || param->vary == 0) 1658 if (dev->in_pipe == 0 || param->vary == 0)
1660 break; 1659 break;
1661 dev_dbg (&intf->dev, 1660 dev_info(&intf->dev,
1662 "TEST 4: read/%d 0..%d bytes %u times\n", 1661 "TEST 4: read/%d 0..%d bytes %u times\n",
1663 param->vary, param->length, param->iterations); 1662 param->vary, param->length, param->iterations);
1664 urb = simple_alloc_urb (udev, dev->in_pipe, param->length); 1663 urb = simple_alloc_urb (udev, dev->in_pipe, param->length);
@@ -1667,7 +1666,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1667 break; 1666 break;
1668 } 1667 }
1669 // FIRMWARE: bulk source (maybe generates short writes) 1668 // FIRMWARE: bulk source (maybe generates short writes)
1670 retval = simple_io (urb, param->iterations, param->vary, 1669 retval = simple_io(dev, urb, param->iterations, param->vary,
1671 0, "test4"); 1670 0, "test4");
1672 simple_free_urb (urb); 1671 simple_free_urb (urb);
1673 break; 1672 break;
@@ -1676,7 +1675,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1676 case 5: 1675 case 5:
1677 if (dev->out_pipe == 0 || param->sglen == 0) 1676 if (dev->out_pipe == 0 || param->sglen == 0)
1678 break; 1677 break;
1679 dev_dbg (&intf->dev, 1678 dev_info(&intf->dev,
1680 "TEST 5: write %d sglists %d entries of %d bytes\n", 1679 "TEST 5: write %d sglists %d entries of %d bytes\n",
1681 param->iterations, 1680 param->iterations,
1682 param->sglen, param->length); 1681 param->sglen, param->length);
@@ -1686,7 +1685,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1686 break; 1685 break;
1687 } 1686 }
1688 // FIRMWARE: bulk sink (maybe accepts short writes) 1687 // FIRMWARE: bulk sink (maybe accepts short writes)
1689 retval = perform_sglist (udev, param->iterations, dev->out_pipe, 1688 retval = perform_sglist(dev, param->iterations, dev->out_pipe,
1690 &req, sg, param->sglen); 1689 &req, sg, param->sglen);
1691 free_sglist (sg, param->sglen); 1690 free_sglist (sg, param->sglen);
1692 break; 1691 break;
@@ -1694,7 +1693,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1694 case 6: 1693 case 6:
1695 if (dev->in_pipe == 0 || param->sglen == 0) 1694 if (dev->in_pipe == 0 || param->sglen == 0)
1696 break; 1695 break;
1697 dev_dbg (&intf->dev, 1696 dev_info(&intf->dev,
1698 "TEST 6: read %d sglists %d entries of %d bytes\n", 1697 "TEST 6: read %d sglists %d entries of %d bytes\n",
1699 param->iterations, 1698 param->iterations,
1700 param->sglen, param->length); 1699 param->sglen, param->length);
@@ -1704,14 +1703,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1704 break; 1703 break;
1705 } 1704 }
1706 // FIRMWARE: bulk source (maybe generates short writes) 1705 // FIRMWARE: bulk source (maybe generates short writes)
1707 retval = perform_sglist (udev, param->iterations, dev->in_pipe, 1706 retval = perform_sglist(dev, param->iterations, dev->in_pipe,
1708 &req, sg, param->sglen); 1707 &req, sg, param->sglen);
1709 free_sglist (sg, param->sglen); 1708 free_sglist (sg, param->sglen);
1710 break; 1709 break;
1711 case 7: 1710 case 7:
1712 if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) 1711 if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0)
1713 break; 1712 break;
1714 dev_dbg (&intf->dev, 1713 dev_info(&intf->dev,
1715 "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", 1714 "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n",
1716 param->vary, param->iterations, 1715 param->vary, param->iterations,
1717 param->sglen, param->length); 1716 param->sglen, param->length);
@@ -1721,14 +1720,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1721 break; 1720 break;
1722 } 1721 }
1723 // FIRMWARE: bulk sink (maybe accepts short writes) 1722 // FIRMWARE: bulk sink (maybe accepts short writes)
1724 retval = perform_sglist (udev, param->iterations, dev->out_pipe, 1723 retval = perform_sglist(dev, param->iterations, dev->out_pipe,
1725 &req, sg, param->sglen); 1724 &req, sg, param->sglen);
1726 free_sglist (sg, param->sglen); 1725 free_sglist (sg, param->sglen);
1727 break; 1726 break;
1728 case 8: 1727 case 8:
1729 if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) 1728 if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0)
1730 break; 1729 break;
1731 dev_dbg (&intf->dev, 1730 dev_info(&intf->dev,
1732 "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", 1731 "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n",
1733 param->vary, param->iterations, 1732 param->vary, param->iterations,
1734 param->sglen, param->length); 1733 param->sglen, param->length);
@@ -1738,7 +1737,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1738 break; 1737 break;
1739 } 1738 }
1740 // FIRMWARE: bulk source (maybe generates short writes) 1739 // FIRMWARE: bulk source (maybe generates short writes)
1741 retval = perform_sglist (udev, param->iterations, dev->in_pipe, 1740 retval = perform_sglist(dev, param->iterations, dev->in_pipe,
1742 &req, sg, param->sglen); 1741 &req, sg, param->sglen);
1743 free_sglist (sg, param->sglen); 1742 free_sglist (sg, param->sglen);
1744 break; 1743 break;
@@ -1746,13 +1745,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1746 /* non-queued sanity tests for control (chapter 9 subset) */ 1745 /* non-queued sanity tests for control (chapter 9 subset) */
1747 case 9: 1746 case 9:
1748 retval = 0; 1747 retval = 0;
1749 dev_dbg (&intf->dev, 1748 dev_info(&intf->dev,
1750 "TEST 9: ch9 (subset) control tests, %d times\n", 1749 "TEST 9: ch9 (subset) control tests, %d times\n",
1751 param->iterations); 1750 param->iterations);
1752 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1751 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1753 retval = ch9_postconfig (dev); 1752 retval = ch9_postconfig (dev);
1754 if (retval) 1753 if (retval)
1755 dbg ("ch9 subset failed, iterations left %d", i); 1754 dev_err(&intf->dev, "ch9 subset failed, "
1755 "iterations left %d\n", i);
1756 break; 1756 break;
1757 1757
1758 /* queued control messaging */ 1758 /* queued control messaging */
@@ -1760,7 +1760,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1760 if (param->sglen == 0) 1760 if (param->sglen == 0)
1761 break; 1761 break;
1762 retval = 0; 1762 retval = 0;
1763 dev_dbg (&intf->dev, 1763 dev_info(&intf->dev,
1764 "TEST 10: queue %d control calls, %d times\n", 1764 "TEST 10: queue %d control calls, %d times\n",
1765 param->sglen, 1765 param->sglen,
1766 param->iterations); 1766 param->iterations);
@@ -1772,26 +1772,26 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1772 if (dev->in_pipe == 0 || !param->length) 1772 if (dev->in_pipe == 0 || !param->length)
1773 break; 1773 break;
1774 retval = 0; 1774 retval = 0;
1775 dev_dbg (&intf->dev, "TEST 11: unlink %d reads of %d\n", 1775 dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n",
1776 param->iterations, param->length); 1776 param->iterations, param->length);
1777 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1777 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1778 retval = unlink_simple (dev, dev->in_pipe, 1778 retval = unlink_simple (dev, dev->in_pipe,
1779 param->length); 1779 param->length);
1780 if (retval) 1780 if (retval)
1781 dev_dbg (&intf->dev, "unlink reads failed %d, " 1781 dev_err(&intf->dev, "unlink reads failed %d, "
1782 "iterations left %d\n", retval, i); 1782 "iterations left %d\n", retval, i);
1783 break; 1783 break;
1784 case 12: 1784 case 12:
1785 if (dev->out_pipe == 0 || !param->length) 1785 if (dev->out_pipe == 0 || !param->length)
1786 break; 1786 break;
1787 retval = 0; 1787 retval = 0;
1788 dev_dbg (&intf->dev, "TEST 12: unlink %d writes of %d\n", 1788 dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n",
1789 param->iterations, param->length); 1789 param->iterations, param->length);
1790 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1790 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1791 retval = unlink_simple (dev, dev->out_pipe, 1791 retval = unlink_simple (dev, dev->out_pipe,
1792 param->length); 1792 param->length);
1793 if (retval) 1793 if (retval)
1794 dev_dbg (&intf->dev, "unlink writes failed %d, " 1794 dev_err(&intf->dev, "unlink writes failed %d, "
1795 "iterations left %d\n", retval, i); 1795 "iterations left %d\n", retval, i);
1796 break; 1796 break;
1797 1797
@@ -1800,24 +1800,24 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1800 if (dev->out_pipe == 0 && dev->in_pipe == 0) 1800 if (dev->out_pipe == 0 && dev->in_pipe == 0)
1801 break; 1801 break;
1802 retval = 0; 1802 retval = 0;
1803 dev_dbg (&intf->dev, "TEST 13: set/clear %d halts\n", 1803 dev_info(&intf->dev, "TEST 13: set/clear %d halts\n",
1804 param->iterations); 1804 param->iterations);
1805 for (i = param->iterations; retval == 0 && i--; /* NOP */) 1805 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1806 retval = halt_simple (dev); 1806 retval = halt_simple (dev);
1807 1807
1808 if (retval) 1808 if (retval)
1809 DBG (dev, "halts failed, iterations left %d\n", i); 1809 ERROR(dev, "halts failed, iterations left %d\n", i);
1810 break; 1810 break;
1811 1811
1812 /* control write tests */ 1812 /* control write tests */
1813 case 14: 1813 case 14:
1814 if (!dev->info->ctrl_out) 1814 if (!dev->info->ctrl_out)
1815 break; 1815 break;
1816 dev_dbg (&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n", 1816 dev_info(&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n",
1817 param->iterations, 1817 param->iterations,
1818 realworld ? 1 : 0, param->length, 1818 realworld ? 1 : 0, param->length,
1819 param->vary); 1819 param->vary);
1820 retval = ctrl_out (dev, param->iterations, 1820 retval = ctrl_out(dev, param->iterations,
1821 param->length, param->vary); 1821 param->length, param->vary);
1822 break; 1822 break;
1823 1823
@@ -1825,7 +1825,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1825 case 15: 1825 case 15:
1826 if (dev->out_iso_pipe == 0 || param->sglen == 0) 1826 if (dev->out_iso_pipe == 0 || param->sglen == 0)
1827 break; 1827 break;
1828 dev_dbg (&intf->dev, 1828 dev_info(&intf->dev,
1829 "TEST 15: write %d iso, %d entries of %d bytes\n", 1829 "TEST 15: write %d iso, %d entries of %d bytes\n",
1830 param->iterations, 1830 param->iterations,
1831 param->sglen, param->length); 1831 param->sglen, param->length);
@@ -1838,7 +1838,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1838 case 16: 1838 case 16:
1839 if (dev->in_iso_pipe == 0 || param->sglen == 0) 1839 if (dev->in_iso_pipe == 0 || param->sglen == 0)
1840 break; 1840 break;
1841 dev_dbg (&intf->dev, 1841 dev_info(&intf->dev,
1842 "TEST 16: read %d iso, %d entries of %d bytes\n", 1842 "TEST 16: read %d iso, %d entries of %d bytes\n",
1843 param->iterations, 1843 param->iterations,
1844 param->sglen, param->length); 1844 param->sglen, param->length);
@@ -1898,7 +1898,8 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1898 return -ENODEV; 1898 return -ENODEV;
1899 if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) 1899 if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product)
1900 return -ENODEV; 1900 return -ENODEV;
1901 dbg ("matched module params, vend=0x%04x prod=0x%04x", 1901 dev_info(&intf->dev, "matched module params, "
1902 "vend=0x%04x prod=0x%04x\n",
1902 le16_to_cpu(udev->descriptor.idVendor), 1903 le16_to_cpu(udev->descriptor.idVendor),
1903 le16_to_cpu(udev->descriptor.idProduct)); 1904 le16_to_cpu(udev->descriptor.idProduct));
1904 } 1905 }
@@ -1940,7 +1941,8 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1940 1941
1941 status = get_endpoints (dev, intf); 1942 status = get_endpoints (dev, intf);
1942 if (status < 0) { 1943 if (status < 0) {
1943 dbg ("couldn't get endpoints, %d\n", status); 1944 WARN(dev, "couldn't get endpoints, %d\n",
1945 status);
1944 return status; 1946 return status;
1945 } 1947 }
1946 /* may find bulk or ISO pipes */ 1948 /* may find bulk or ISO pipes */
@@ -2082,21 +2084,9 @@ static struct usbtest_info generic_info = {
2082}; 2084};
2083#endif 2085#endif
2084 2086
2085// FIXME remove this
2086static struct usbtest_info hact_info = {
2087 .name = "FX2/hact",
2088 //.ep_in = 6,
2089 .ep_out = 2,
2090 .alt = -1,
2091};
2092
2093 2087
2094static struct usb_device_id id_table [] = { 2088static struct usb_device_id id_table [] = {
2095 2089
2096 { USB_DEVICE (0x0547, 0x1002),
2097 .driver_info = (unsigned long) &hact_info,
2098 },
2099
2100 /*-------------------------------------------------------------*/ 2090 /*-------------------------------------------------------------*/
2101 2091
2102 /* EZ-USB devices which download firmware to replace (or in our 2092 /* EZ-USB devices which download firmware to replace (or in our
@@ -2185,7 +2175,7 @@ static int __init usbtest_init (void)
2185{ 2175{
2186#ifdef GENERIC 2176#ifdef GENERIC
2187 if (vendor) 2177 if (vendor)
2188 dbg ("params: vend=0x%04x prod=0x%04x", vendor, product); 2178 pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product);
2189#endif 2179#endif
2190 return usb_register (&usbtest_driver); 2180 return usb_register (&usbtest_driver);
2191} 2181}