Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Brownell and committed by
Greg Kroah-Hartman
28ffd79c 9029b174

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