Merge with Linux 2.5.73.
[linux-2.6/linux-mips.git] / drivers / usb / misc / usbtest.c
blob4d7f9a9158ea324344cc7ad1627360d54cda8231
1 #include <linux/config.h>
2 #include <linux/kernel.h>
3 #include <linux/errno.h>
4 #include <linux/init.h>
5 #include <linux/slab.h>
6 #include <linux/mm.h>
7 #include <linux/module.h>
8 #include <asm/scatterlist.h>
10 #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
11 # define DEBUG
12 #endif
13 #include <linux/usb.h>
16 /*-------------------------------------------------------------------------*/
18 // FIXME make these public somewhere; usbdevfs.h?
20 struct usbtest_param {
21 // inputs
22 unsigned test_num; /* 0..(TEST_CASES-1) */
23 int iterations;
24 int length;
25 int vary;
26 int sglen;
28 // outputs
29 struct timeval duration;
31 #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param)
33 /*-------------------------------------------------------------------------*/
35 #define GENERIC /* let probe() bind using module params */
37 /* Some devices that can be used for testing will have "real" drivers.
38 * Entries for those need to be enabled here by hand, after disabling
39 * that "real" driver.
41 //#define IBOT2 /* grab iBOT2 webcams */
42 //#define KEYSPAN_19Qi /* grab un-renumerated serial adapter */
44 /*-------------------------------------------------------------------------*/
46 struct usbtest_info {
47 const char *name;
48 u8 ep_in; /* bulk/intr source */
49 u8 ep_out; /* bulk/intr sink */
50 int alt;
53 /* this is accessed only through usbfs ioctl calls.
54 * one ioctl to issue a test ... one lock per device.
55 * tests create other threads if they need them.
56 * urbs and buffers are allocated dynamically,
57 * and data generated deterministically.
59 struct usbtest_dev {
60 struct usb_interface *intf;
61 struct usbtest_info *info;
62 char id [32];
63 int in_pipe;
64 int out_pipe;
65 struct semaphore sem;
67 #define TBUF_SIZE 256
68 u8 *buf;
71 static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test)
73 return interface_to_usbdev (test->intf);
76 /* set up all urbs so they can be used with either bulk or interrupt */
77 #define INTERRUPT_RATE 1 /* msec/transfer */
79 /*-------------------------------------------------------------------------*/
81 /* Support for testing basic non-queued I/O streams.
83 * These just package urbs as requests that can be easily canceled.
84 * Each urb's data buffer is dynamically allocated; callers can fill
85 * them with non-zero test data (or test for it) when appropriate.
88 static void simple_callback (struct urb *urb, struct pt_regs *regs)
90 complete ((struct completion *) urb->context);
93 static struct urb *simple_alloc_urb (
94 struct usb_device *udev,
95 int pipe,
96 long bytes
99 struct urb *urb;
101 if (bytes < 0)
102 return 0;
103 urb = usb_alloc_urb (0, SLAB_KERNEL);
104 if (!urb)
105 return urb;
106 usb_fill_bulk_urb (urb, udev, pipe, 0, bytes, simple_callback, 0);
107 urb->interval = (udev->speed == USB_SPEED_HIGH)
108 ? (INTERRUPT_RATE << 3)
109 : INTERRUPT_RATE;
110 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
111 if (usb_pipein (pipe))
112 urb->transfer_flags |= URB_SHORT_NOT_OK;
113 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL,
114 &urb->transfer_dma);
115 if (!urb->transfer_buffer) {
116 usb_free_urb (urb);
117 urb = 0;
118 } else
119 memset (urb->transfer_buffer, 0, bytes);
120 return urb;
123 static void simple_free_urb (struct urb *urb)
125 usb_buffer_free (urb->dev, urb->transfer_buffer_length,
126 urb->transfer_buffer, urb->transfer_dma);
127 usb_free_urb (urb);
130 static int simple_io (
131 struct urb *urb,
132 int iterations,
133 int vary
136 struct usb_device *udev = urb->dev;
137 int max = urb->transfer_buffer_length;
138 struct completion completion;
139 int retval = 0;
141 urb->context = &completion;
142 while (retval == 0 && iterations-- > 0) {
143 init_completion (&completion);
144 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0)
145 break;
147 /* NOTE: no timeouts; can't be broken out of by interrupt */
148 wait_for_completion (&completion);
149 retval = urb->status;
150 urb->dev = udev;
152 if (vary) {
153 int len = urb->transfer_buffer_length;
155 len += vary;
156 len %= max;
157 if (len == 0)
158 len = (vary < max) ? vary : max;
159 urb->transfer_buffer_length = len;
162 /* FIXME if endpoint halted, clear halt (and log) */
164 urb->transfer_buffer_length = max;
166 // FIXME for unlink or fault handling tests, don't report
167 // failure if retval is as we expected ...
168 if (retval)
169 dbg ("simple_io failed, iterations left %d, status %d",
170 iterations, retval);
171 return retval;
174 /*-------------------------------------------------------------------------*/
176 /* We use scatterlist primitives to test queued I/O.
177 * Yes, this also tests the scatterlist primitives.
180 static void free_sglist (struct scatterlist *sg, int nents)
182 unsigned i;
184 if (!sg)
185 return;
186 for (i = 0; i < nents; i++) {
187 if (!sg [i].page)
188 continue;
189 kfree (page_address (sg [i].page) + sg [i].offset);
191 kfree (sg);
194 static struct scatterlist *
195 alloc_sglist (int nents, int max, int vary)
197 struct scatterlist *sg;
198 unsigned i;
199 unsigned size = max;
201 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL);
202 if (!sg)
203 return 0;
204 memset (sg, 0, nents * sizeof *sg);
206 for (i = 0; i < nents; i++) {
207 char *buf;
209 buf = kmalloc (size, SLAB_KERNEL);
210 if (!buf) {
211 free_sglist (sg, i);
212 return 0;
214 memset (buf, 0, size);
216 /* kmalloc pages are always physically contiguous! */
217 sg [i].page = virt_to_page (buf);
218 sg [i].offset = ((unsigned) buf) & ~PAGE_MASK;
219 sg [i].length = size;
221 if (vary) {
222 size += vary;
223 size %= max;
224 if (size == 0)
225 size = (vary < max) ? vary : max;
229 return sg;
232 static int perform_sglist (
233 struct usb_device *udev,
234 unsigned iterations,
235 int pipe,
236 struct usb_sg_request *req,
237 struct scatterlist *sg,
238 int nents
241 int retval = 0;
243 while (retval == 0 && iterations-- > 0) {
244 retval = usb_sg_init (req, udev, pipe,
245 (udev->speed == USB_SPEED_HIGH)
246 ? (INTERRUPT_RATE << 3)
247 : INTERRUPT_RATE,
248 sg, nents, 0, SLAB_KERNEL);
250 if (retval)
251 break;
252 usb_sg_wait (req);
253 retval = req->status;
255 /* FIXME if endpoint halted, clear halt (and log) */
258 // FIXME for unlink or fault handling tests, don't report
259 // failure if retval is as we expected ...
261 if (retval)
262 dbg ("perform_sglist failed, iterations left %d, status %d",
263 iterations, retval);
264 return retval;
268 /*-------------------------------------------------------------------------*/
270 /* unqueued control message testing
272 * there's a nice set of device functional requirements in chapter 9 of the
273 * usb 2.0 spec, which we can apply to ANY device, even ones that don't use
274 * special test firmware.
276 * we know the device is configured (or suspended) by the time it's visible
277 * through usbfs. we can't change that, so we won't test enumeration (which
278 * worked 'well enough' to get here, this time), power management (ditto),
279 * or remote wakeup (which needs human interaction).
282 static int realworld = 1;
283 MODULE_PARM (realworld, "i");
284 MODULE_PARM_DESC (realworld, "clear to demand stricter ch9 compliance");
286 static int get_altsetting (struct usbtest_dev *dev)
288 struct usb_interface *iface = dev->intf;
289 struct usb_device *udev = interface_to_usbdev (iface);
290 int retval;
292 retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
293 USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE,
294 0, iface->altsetting [0].desc.bInterfaceNumber,
295 dev->buf, 1, HZ * USB_CTRL_GET_TIMEOUT);
296 switch (retval) {
297 case 1:
298 return dev->buf [0];
299 case 0:
300 retval = -ERANGE;
301 // FALLTHROUGH
302 default:
303 return retval;
307 /* this is usb_set_interface(), with no 'only one altsetting' case */
308 static int set_altsetting (struct usbtest_dev *dev, int alternate)
310 struct usb_interface *iface = dev->intf;
311 struct usb_device *udev;
312 struct usb_host_interface *iface_as;
313 int i, ret;
315 if (alternate < 0 || alternate >= iface->num_altsetting)
316 return -EINVAL;
318 udev = interface_to_usbdev (iface);
319 if ((ret = usb_control_msg (udev, usb_sndctrlpipe (udev, 0),
320 USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
321 alternate,
322 iface->altsetting->desc.bInterfaceNumber,
323 NULL, 0, HZ * USB_CTRL_SET_TIMEOUT)) < 0)
324 return ret;
326 // FIXME usbcore should be more like this:
327 // - remove that special casing in usbcore.
328 // - fix usbcore signature to take interface
330 /* prevent requests using previous endpoint settings */
331 iface_as = iface->altsetting + iface->act_altsetting;
332 for (i = 0; i < iface_as->desc.bNumEndpoints; i++) {
333 u8 ep = iface_as->endpoint [i].desc.bEndpointAddress;
334 int out = !(ep & USB_DIR_IN);
336 ep &= USB_ENDPOINT_NUMBER_MASK;
337 (out ? udev->epmaxpacketout : udev->epmaxpacketin ) [ep] = 0;
338 // FIXME want hcd hook here, "forget this endpoint"
340 iface->act_altsetting = alternate;
342 /* reset toggles and maxpacket for all endpoints affected */
343 iface_as = iface->altsetting + iface->act_altsetting;
344 for (i = 0; i < iface_as->desc.bNumEndpoints; i++) {
345 u8 ep = iface_as->endpoint [i].desc.bEndpointAddress;
346 int out = !(ep & USB_DIR_IN);
348 ep &= USB_ENDPOINT_NUMBER_MASK;
349 usb_settoggle (udev, ep, out, 0);
350 (out ? udev->epmaxpacketout : udev->epmaxpacketin ) [ep]
351 = iface_as->endpoint [i].desc.wMaxPacketSize;
354 return 0;
357 static int is_good_config (char *buf, int len)
359 struct usb_config_descriptor *config;
361 if (len < sizeof *config)
362 return 0;
363 config = (struct usb_config_descriptor *) buf;
365 switch (config->bDescriptorType) {
366 case USB_DT_CONFIG:
367 case USB_DT_OTHER_SPEED_CONFIG:
368 if (config->bLength != 9)
369 return 0;
370 /* this bit 'must be 1' but often isn't */
371 if (!realworld && !(config->bmAttributes & 0x80)) {
372 dbg ("high bit of config attributes not set");
373 return 0;
375 if (config->bmAttributes & 0x1f) /* reserved == 0 */
376 return 0;
377 break;
378 default:
379 return 0;
382 le32_to_cpus (&config->wTotalLength);
383 if (config->wTotalLength == len) /* read it all */
384 return 1;
385 return config->wTotalLength >= TBUF_SIZE; /* max partial read */
388 /* sanity test for standard requests working with usb_control_mesg() and some
389 * of the utility functions which use it.
391 * this doesn't test how endpoint halts behave or data toggles get set, since
392 * we won't do I/O to bulk/interrupt endpoints here (which is how to change
393 * halt or toggle). toggle testing is impractical without support from hcds.
395 * this avoids failing devices linux would normally work with, by not testing
396 * config/altsetting operations for devices that only support their defaults.
397 * such devices rarely support those needless operations.
399 * NOTE that since this is a sanity test, it's not examining boundary cases
400 * to see if usbcore, hcd, and device all behave right. such testing would
401 * involve varied read sizes and other operation sequences.
403 static int ch9_postconfig (struct usbtest_dev *dev)
405 struct usb_interface *iface = dev->intf;
406 struct usb_device *udev = interface_to_usbdev (iface);
407 int i, retval;
409 /* [9.2.3] if there's more than one altsetting, we need to be able to
410 * set and get each one. mostly trusts the descriptors from usbcore.
412 for (i = 0; i < iface->num_altsetting; i++) {
414 /* 9.2.3 constrains the range here, and Linux ensures
415 * they're ordered meaningfully in this array
417 if (iface->altsetting [i].desc.bAlternateSetting != i) {
418 dbg ("%s, illegal alt [%d].bAltSetting = %d",
419 dev->id, i,
420 iface->altsetting [i].desc
421 .bAlternateSetting);
422 return -EDOM;
425 /* [real world] get/set unimplemented if there's only one */
426 if (realworld && iface->num_altsetting == 1)
427 continue;
429 /* [9.4.10] set_interface */
430 retval = set_altsetting (dev, i);
431 if (retval) {
432 dbg ("%s can't set_interface = %d, %d",
433 dev->id, i, retval);
434 return retval;
437 /* [9.4.4] get_interface always works */
438 retval = get_altsetting (dev);
439 if (retval != i) {
440 dbg ("%s get alt should be %d, was %d",
441 dev->id, i, retval);
442 return (retval < 0) ? retval : -EDOM;
447 /* [real world] get_config unimplemented if there's only one */
448 if (!realworld || udev->descriptor.bNumConfigurations != 1) {
449 int expected = udev->actconfig->desc.bConfigurationValue;
451 /* [9.4.2] get_configuration always works
452 * ... although some cheap devices (like one TI Hub I've got)
453 * won't return config descriptors except before set_config.
455 retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
456 USB_REQ_GET_CONFIGURATION,
457 USB_DIR_IN | USB_RECIP_DEVICE,
458 0, 0, dev->buf, 1, HZ * USB_CTRL_GET_TIMEOUT);
459 if (retval != 1 || dev->buf [0] != expected) {
460 dbg ("%s get config --> %d (%d)", dev->id, retval,
461 expected);
462 return (retval < 0) ? retval : -EDOM;
466 /* there's always [9.4.3] a device descriptor [9.6.1] */
467 retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0,
468 dev->buf, sizeof udev->descriptor);
469 if (retval != sizeof udev->descriptor) {
470 dbg ("%s dev descriptor --> %d", dev->id, retval);
471 return (retval < 0) ? retval : -EDOM;
474 /* there's always [9.4.3] at least one config descriptor [9.6.3] */
475 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) {
476 retval = usb_get_descriptor (udev, USB_DT_CONFIG, i,
477 dev->buf, TBUF_SIZE);
478 if (!is_good_config (dev->buf, retval)) {
479 dbg ("%s config [%d] descriptor --> %d",
480 dev->id, i, retval);
481 return (retval < 0) ? retval : -EDOM;
484 // FIXME cross-checking udev->config[i] to make sure usbcore
485 // parsed it right (etc) would be good testing paranoia
488 /* and sometimes [9.2.6.6] speed dependent descriptors */
489 if (udev->descriptor.bcdUSB == 0x0200) { /* pre-swapped */
490 struct usb_qualifier_descriptor *d = 0;
492 /* device qualifier [9.6.2] */
493 retval = usb_get_descriptor (udev,
494 USB_DT_DEVICE_QUALIFIER, 0, dev->buf,
495 sizeof (struct usb_qualifier_descriptor));
496 if (retval == -EPIPE) {
497 if (udev->speed == USB_SPEED_HIGH) {
498 dbg ("%s hs dev qualifier --> %d",
499 dev->id, retval);
500 return (retval < 0) ? retval : -EDOM;
502 /* usb2.0 but not high-speed capable; fine */
503 } else if (retval != sizeof (struct usb_qualifier_descriptor)) {
504 dbg ("%s dev qualifier --> %d", dev->id, retval);
505 return (retval < 0) ? retval : -EDOM;
506 } else
507 d = (struct usb_qualifier_descriptor *) dev->buf;
509 /* might not have [9.6.2] any other-speed configs [9.6.4] */
510 if (d) {
511 unsigned max = d->bNumConfigurations;
512 for (i = 0; i < max; i++) {
513 retval = usb_get_descriptor (udev,
514 USB_DT_OTHER_SPEED_CONFIG, i,
515 dev->buf, TBUF_SIZE);
516 if (!is_good_config (dev->buf, retval)) {
517 dbg ("%s other speed config --> %d",
518 dev->id, retval);
519 return (retval < 0) ? retval : -EDOM;
524 // FIXME fetch strings from at least the device descriptor
526 /* [9.4.5] get_status always works */
527 retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf);
528 if (retval != 2) {
529 dbg ("%s get dev status --> %d", dev->id, retval);
530 return (retval < 0) ? retval : -EDOM;
533 // FIXME configuration.bmAttributes says if we could try to set/clear
534 // the device's remote wakeup feature ... if we can, test that here
536 retval = usb_get_status (udev, USB_RECIP_INTERFACE,
537 iface->altsetting [0].desc.bInterfaceNumber, dev->buf);
538 if (retval != 2) {
539 dbg ("%s get interface status --> %d", dev->id, retval);
540 return (retval < 0) ? retval : -EDOM;
542 // FIXME get status for each endpoint in the interface
544 return 0;
547 /*-------------------------------------------------------------------------*/
549 /* use ch9 requests to test whether:
550 * (a) queues work for control, keeping N subtests queued and
551 * active (auto-resubmit) for M loops through the queue.
552 * (b) protocol stalls (control-only) will autorecover.
553 * it's quite not like bulk/intr; no halt clearing.
554 * (c) short control reads are reported and handled.
555 * (d) queues are always processed in-order
558 struct ctrl_ctx {
559 spinlock_t lock;
560 struct usbtest_dev *dev;
561 struct completion complete;
562 unsigned count;
563 unsigned pending;
564 int status;
565 struct urb **urb;
566 struct usbtest_param *param;
567 int last;
570 #define NUM_SUBCASES 13 /* how many test subcases here? */
572 struct subcase {
573 struct usb_ctrlrequest setup;
574 int number;
575 int expected;
578 static void ctrl_complete (struct urb *urb, struct pt_regs *regs)
580 struct ctrl_ctx *ctx = urb->context;
581 struct usb_ctrlrequest *reqp;
582 struct subcase *subcase;
583 int status = urb->status;
585 reqp = (struct usb_ctrlrequest *)urb->setup_packet;
586 subcase = container_of (reqp, struct subcase, setup);
588 spin_lock (&ctx->lock);
589 ctx->count--;
590 ctx->pending--;
592 /* queue must transfer and complete in fifo order, unless
593 * usb_unlink_urb() is used to unlink something not at the
594 * physical queue head (not tested).
596 if (subcase->number > 0) {
597 if ((subcase->number - ctx->last) != 1) {
598 dbg ("subcase %d completed out of order, last %d",
599 subcase->number, ctx->last);
600 status = -EDOM;
601 goto error;
604 ctx->last = subcase->number;
606 /* succeed or fault in only one way? */
607 if (status == subcase->expected)
608 status = 0;
610 /* async unlink for cleanup? */
611 else if (status != -ECONNRESET) {
613 /* some faults are allowed, not required */
614 if (subcase->expected > 0 && (
615 ((urb->status == -subcase->expected /* happened */
616 || urb->status == 0)))) /* didn't */
617 status = 0;
618 /* sometimes more than one fault is allowed */
619 else if (subcase->number == 12 && status == -EPIPE)
620 status = 0;
621 else
622 dbg ("subtest %d error, status %d",
623 subcase->number, status);
626 /* unexpected status codes mean errors; ideally, in hardware */
627 if (status) {
628 error:
629 if (ctx->status == 0) {
630 int i;
632 ctx->status = status;
633 info ("control queue %02x.%02x, err %d, %d left",
634 reqp->bRequestType, reqp->bRequest,
635 status, ctx->count);
637 /* FIXME this "unlink everything" exit route should
638 * be a separate test case.
641 /* unlink whatever's still pending */
642 for (i = 0; i < ctx->param->sglen; i++) {
643 struct urb *u = ctx->urb [i];
645 if (u == urb || !u->dev)
646 continue;
647 status = usb_unlink_urb (u);
648 switch (status) {
649 case -EINPROGRESS:
650 case -EBUSY:
651 continue;
652 default:
653 dbg ("urb unlink --> %d", status);
656 status = ctx->status;
660 /* resubmit if we need to, else mark this as done */
661 if ((status == 0) && (ctx->pending < ctx->count)) {
662 if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) {
663 dbg ("can't resubmit ctrl %02x.%02x, err %d",
664 reqp->bRequestType, reqp->bRequest, status);
665 urb->dev = 0;
666 } else
667 ctx->pending++;
668 } else
669 urb->dev = 0;
671 /* signal completion when nothing's queued */
672 if (ctx->pending == 0)
673 complete (&ctx->complete);
674 spin_unlock (&ctx->lock);
677 static int
678 test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
680 struct usb_device *udev = testdev_to_usbdev (dev);
681 struct urb **urb;
682 struct ctrl_ctx context;
683 int i;
685 spin_lock_init (&context.lock);
686 context.dev = dev;
687 init_completion (&context.complete);
688 context.count = param->sglen * param->iterations;
689 context.pending = 0;
690 context.status = -ENOMEM;
691 context.param = param;
692 context.last = -1;
694 /* allocate and init the urbs we'll queue.
695 * as with bulk/intr sglists, sglen is the queue depth; it also
696 * controls which subtests run (more tests than sglen) or rerun.
698 urb = kmalloc (param->sglen * sizeof (struct urb *), SLAB_KERNEL);
699 if (!urb)
700 goto cleanup;
701 memset (urb, 0, param->sglen * sizeof (struct urb *));
702 for (i = 0; i < param->sglen; i++) {
703 int pipe = usb_rcvctrlpipe (udev, 0);
704 unsigned len;
705 struct urb *u;
706 struct usb_ctrlrequest req;
707 struct subcase *reqp;
708 int expected = 0;
710 /* requests here are mostly expected to succeed on any
711 * device, but some are chosen to trigger protocol stalls
712 * or short reads.
714 memset (&req, 0, sizeof req);
715 req.bRequest = USB_REQ_GET_DESCRIPTOR;
716 req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;
718 switch (i % NUM_SUBCASES) {
719 case 0: // get device descriptor
720 req.wValue = cpu_to_le16 (USB_DT_DEVICE << 8);
721 len = sizeof (struct usb_device_descriptor);
722 break;
723 case 1: // get first config descriptor (only)
724 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
725 len = sizeof (struct usb_config_descriptor);
726 break;
727 case 2: // get altsetting (OFTEN STALLS)
728 req.bRequest = USB_REQ_GET_INTERFACE;
729 req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;
730 // index = 0 means first interface
731 len = 1;
732 expected = EPIPE;
733 break;
734 case 3: // get interface status
735 req.bRequest = USB_REQ_GET_STATUS;
736 req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;
737 // interface 0
738 len = 2;
739 break;
740 case 4: // get device status
741 req.bRequest = USB_REQ_GET_STATUS;
742 req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;
743 len = 2;
744 break;
745 case 5: // get device qualifier (MAY STALL)
746 req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8);
747 len = sizeof (struct usb_qualifier_descriptor);
748 if (udev->speed != USB_SPEED_HIGH)
749 expected = EPIPE;
750 break;
751 case 6: // get first config descriptor, plus interface
752 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
753 len = sizeof (struct usb_config_descriptor);
754 len += sizeof (struct usb_interface_descriptor);
755 break;
756 case 7: // get interface descriptor (ALWAYS STALLS)
757 req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8);
758 // interface == 0
759 len = sizeof (struct usb_interface_descriptor);
760 expected = -EPIPE;
761 break;
762 // NOTE: two consecutive stalls in the queue here.
763 // that tests fault recovery a bit more aggressively.
764 case 8: // clear endpoint halt (USUALLY STALLS)
765 req.bRequest = USB_REQ_CLEAR_FEATURE;
766 req.bRequestType = USB_RECIP_ENDPOINT;
767 // wValue 0 == ep halt
768 // wIndex 0 == ep0 (shouldn't halt!)
769 len = 0;
770 pipe = usb_sndctrlpipe (udev, 0);
771 expected = EPIPE;
772 break;
773 case 9: // get endpoint status
774 req.bRequest = USB_REQ_GET_STATUS;
775 req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT;
776 // endpoint 0
777 len = 2;
778 break;
779 case 10: // trigger short read (EREMOTEIO)
780 req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
781 len = 1024;
782 expected = -EREMOTEIO;
783 break;
784 // NOTE: two consecutive _different_ faults in the queue.
785 case 11: // get endpoint descriptor (ALWAYS STALLS)
786 req.wValue = cpu_to_le16 (USB_DT_ENDPOINT << 8);
787 // endpoint == 0
788 len = sizeof (struct usb_interface_descriptor);
789 expected = -EPIPE;
790 break;
791 // NOTE: sometimes even a third fault in the queue!
792 case 12: // get string 0 descriptor (MAY STALL)
793 req.wValue = cpu_to_le16 (USB_DT_STRING << 8);
794 // string == 0, for language IDs
795 len = sizeof (struct usb_interface_descriptor);
796 expected = EREMOTEIO; // or EPIPE, if no strings
797 break;
798 default:
799 err ("bogus number of ctrl queue testcases!");
800 context.status = -EINVAL;
801 goto cleanup;
803 req.wLength = cpu_to_le16 (len);
804 urb [i] = u = simple_alloc_urb (udev, pipe, len);
805 if (!u)
806 goto cleanup;
808 reqp = usb_buffer_alloc (udev, sizeof *reqp, SLAB_KERNEL,
809 &u->setup_dma);
810 if (!reqp)
811 goto cleanup;
812 reqp->setup = req;
813 reqp->number = i % NUM_SUBCASES;
814 reqp->expected = expected;
815 u->setup_packet = (char *) &reqp->setup;
817 u->context = &context;
818 u->complete = ctrl_complete;
819 u->transfer_flags |= URB_ASYNC_UNLINK;
822 /* queue the urbs */
823 context.urb = urb;
824 spin_lock_irq (&context.lock);
825 for (i = 0; i < param->sglen; i++) {
826 context.status = usb_submit_urb (urb [i], SLAB_ATOMIC);
827 if (context.status != 0) {
828 dbg ("can't submit urb[%d], status %d",
829 i, context.status);
830 context.count = context.pending;
831 break;
833 context.pending++;
835 spin_unlock_irq (&context.lock);
837 /* FIXME set timer and time out; provide a disconnect hook */
839 /* wait for the last one to complete */
840 wait_for_completion (&context.complete);
842 cleanup:
843 for (i = 0; i < param->sglen; i++) {
844 if (!urb [i])
845 continue;
846 urb [i]->dev = udev;
847 if (urb [i]->setup_packet)
848 usb_buffer_free (udev, sizeof (struct usb_ctrlrequest),
849 urb [i]->setup_packet,
850 urb [i]->setup_dma);
851 simple_free_urb (urb [i]);
853 kfree (urb);
854 return context.status;
856 #undef NUM_SUBCASES
859 /*-------------------------------------------------------------------------*/
861 static void unlink1_callback (struct urb *urb, struct pt_regs *regs)
863 int status = urb->status;
865 // we "know" -EPIPE (stall) never happens
866 if (!status)
867 status = usb_submit_urb (urb, SLAB_ATOMIC);
868 if (status) {
869 if (status == -ECONNRESET || status == -ENOENT)
870 status = 0;
871 urb->status = status;
872 complete ((struct completion *) urb->context);
876 static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
878 struct urb *urb;
879 struct completion completion;
880 int retval = 0;
882 init_completion (&completion);
883 urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size);
884 if (!urb)
885 return -ENOMEM;
886 if (async)
887 urb->transfer_flags |= URB_ASYNC_UNLINK;
888 urb->context = &completion;
889 urb->complete = unlink1_callback;
891 /* keep the endpoint busy. there are lots of hc/hcd-internal
892 * states, and testing should get to all of them over time.
894 * FIXME want additional tests for when endpoint is STALLing
895 * due to errors, or is just NAKing requests.
897 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) {
898 dbg ("submit/unlink fail %d", retval);
899 return retval;
902 /* unlinking that should always work. variable delay tests more
903 * hcd states and code paths, even with little other system load.
905 wait_ms (jiffies % (2 * INTERRUPT_RATE));
906 retry:
907 retval = usb_unlink_urb (urb);
908 if (retval == -EBUSY) {
909 /* we can't unlink urbs while they're completing.
910 * "normal" drivers would prevent resubmission, but
911 * since we're testing unlink paths, we can't.
913 dbg ("unlink retry");
914 goto retry;
916 if (!(retval == 0 || retval == -EINPROGRESS)) {
917 dbg ("submit/unlink fail %d", retval);
918 return retval;
921 wait_for_completion (&completion);
922 retval = urb->status;
923 simple_free_urb (urb);
924 return retval;
927 static int unlink_simple (struct usbtest_dev *dev, int pipe, int len)
929 int retval = 0;
931 /* test sync and async paths */
932 retval = unlink1 (dev, pipe, len, 1);
933 if (!retval)
934 retval = unlink1 (dev, pipe, len, 0);
935 return retval;
938 /*-------------------------------------------------------------------------*/
940 /* We only have this one interface to user space, through usbfs.
941 * User mode code can scan usbfs to find N different devices (maybe on
942 * different busses) to use when testing, and allocate one thread per
943 * test. So discovery is simplified, and we have no device naming issues.
945 * Don't use these only as stress/load tests. Use them along with with
946 * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
947 * video capture, and so on. Run different tests at different times, in
948 * different sequences. Nothing here should interact with other devices,
949 * except indirectly by consuming USB bandwidth and CPU resources for test
950 * threads and request completion. But the only way to know that for sure
951 * is to test when HC queues are in use by many devices.
954 static int
955 usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
957 struct usbtest_dev *dev = usb_get_intfdata (intf);
958 struct usb_device *udev = testdev_to_usbdev (dev);
959 struct usbtest_param *param = buf;
960 int retval = -EOPNOTSUPP;
961 struct urb *urb;
962 struct scatterlist *sg;
963 struct usb_sg_request req;
964 struct timeval start;
965 unsigned i;
967 // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is.
969 if (code != USBTEST_REQUEST)
970 return -EOPNOTSUPP;
972 if (param->iterations <= 0 || param->length < 0
973 || param->sglen < 0 || param->vary < 0)
974 return -EINVAL;
976 if (down_interruptible (&dev->sem))
977 return -ERESTARTSYS;
979 /* some devices, like ez-usb default devices, need a non-default
980 * altsetting to have any active endpoints. some tests change
981 * altsettings; force a default so most tests don't need to check.
983 if (dev->info->alt >= 0) {
984 int res;
986 if (intf->altsetting->desc.bInterfaceNumber) {
987 up (&dev->sem);
988 return -ENODEV;
990 res = set_altsetting (dev, dev->info->alt);
991 if (res) {
992 err ("%s: set altsetting to %d failed, %d",
993 dev->id, dev->info->alt, res);
994 up (&dev->sem);
995 return res;
1000 * Just a bunch of test cases that every HCD is expected to handle.
1002 * Some may need specific firmware, though it'd be good to have
1003 * one firmware image to handle all the test cases.
1005 * FIXME add more tests! cancel requests, verify the data, control
1006 * queueing, concurrent read+write threads, and so on.
1008 do_gettimeofday (&start);
1009 switch (param->test_num) {
1011 case 0:
1012 dbg ("%s TEST 0: NOP", dev->id);
1013 retval = 0;
1014 break;
1016 /* Simple non-queued bulk I/O tests */
1017 case 1:
1018 if (dev->out_pipe == 0)
1019 break;
1020 dbg ("%s TEST 1: write %d bytes %u times", dev->id,
1021 param->length, param->iterations);
1022 urb = simple_alloc_urb (udev, dev->out_pipe, param->length);
1023 if (!urb) {
1024 retval = -ENOMEM;
1025 break;
1027 // FIRMWARE: bulk sink (maybe accepts short writes)
1028 retval = simple_io (urb, param->iterations, 0);
1029 simple_free_urb (urb);
1030 break;
1031 case 2:
1032 if (dev->in_pipe == 0)
1033 break;
1034 dbg ("%s TEST 2: read %d bytes %u times", dev->id,
1035 param->length, param->iterations);
1036 urb = simple_alloc_urb (udev, dev->in_pipe, param->length);
1037 if (!urb) {
1038 retval = -ENOMEM;
1039 break;
1041 // FIRMWARE: bulk source (maybe generates short writes)
1042 retval = simple_io (urb, param->iterations, 0);
1043 simple_free_urb (urb);
1044 break;
1045 case 3:
1046 if (dev->out_pipe == 0 || param->vary == 0)
1047 break;
1048 dbg ("%s TEST 3: write/%d 0..%d bytes %u times", dev->id,
1049 param->vary, param->length, param->iterations);
1050 urb = simple_alloc_urb (udev, dev->out_pipe, param->length);
1051 if (!urb) {
1052 retval = -ENOMEM;
1053 break;
1055 // FIRMWARE: bulk sink (maybe accepts short writes)
1056 retval = simple_io (urb, param->iterations, param->vary);
1057 simple_free_urb (urb);
1058 break;
1059 case 4:
1060 if (dev->in_pipe == 0 || param->vary == 0)
1061 break;
1062 dbg ("%s TEST 4: read/%d 0..%d bytes %u times", dev->id,
1063 param->vary, param->length, param->iterations);
1064 urb = simple_alloc_urb (udev, dev->in_pipe, param->length);
1065 if (!urb) {
1066 retval = -ENOMEM;
1067 break;
1069 // FIRMWARE: bulk source (maybe generates short writes)
1070 retval = simple_io (urb, param->iterations, param->vary);
1071 simple_free_urb (urb);
1072 break;
1074 /* Queued bulk I/O tests */
1075 case 5:
1076 if (dev->out_pipe == 0 || param->sglen == 0)
1077 break;
1078 dbg ("%s TEST 5: write %d sglists, %d entries of %d bytes",
1079 dev->id, param->iterations,
1080 param->sglen, param->length);
1081 sg = alloc_sglist (param->sglen, param->length, 0);
1082 if (!sg) {
1083 retval = -ENOMEM;
1084 break;
1086 // FIRMWARE: bulk sink (maybe accepts short writes)
1087 retval = perform_sglist (udev, param->iterations, dev->out_pipe,
1088 &req, sg, param->sglen);
1089 free_sglist (sg, param->sglen);
1090 break;
1092 case 6:
1093 if (dev->in_pipe == 0 || param->sglen == 0)
1094 break;
1095 dbg ("%s TEST 6: read %d sglists, %d entries of %d bytes",
1096 dev->id, param->iterations,
1097 param->sglen, param->length);
1098 sg = alloc_sglist (param->sglen, param->length, 0);
1099 if (!sg) {
1100 retval = -ENOMEM;
1101 break;
1103 // FIRMWARE: bulk source (maybe generates short writes)
1104 retval = perform_sglist (udev, param->iterations, dev->in_pipe,
1105 &req, sg, param->sglen);
1106 free_sglist (sg, param->sglen);
1107 break;
1108 case 7:
1109 if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0)
1110 break;
1111 dbg ("%s TEST 7: write/%d %d sglists, %d entries 0..%d bytes",
1112 dev->id, param->vary, param->iterations,
1113 param->sglen, param->length);
1114 sg = alloc_sglist (param->sglen, param->length, param->vary);
1115 if (!sg) {
1116 retval = -ENOMEM;
1117 break;
1119 // FIRMWARE: bulk sink (maybe accepts short writes)
1120 retval = perform_sglist (udev, param->iterations, dev->out_pipe,
1121 &req, sg, param->sglen);
1122 free_sglist (sg, param->sglen);
1123 break;
1124 case 8:
1125 if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0)
1126 break;
1127 dbg ("%s TEST 8: read/%d %d sglists, %d entries 0..%d bytes",
1128 dev->id, param->vary, param->iterations,
1129 param->sglen, param->length);
1130 sg = alloc_sglist (param->sglen, param->length, param->vary);
1131 if (!sg) {
1132 retval = -ENOMEM;
1133 break;
1135 // FIRMWARE: bulk source (maybe generates short writes)
1136 retval = perform_sglist (udev, param->iterations, dev->in_pipe,
1137 &req, sg, param->sglen);
1138 free_sglist (sg, param->sglen);
1139 break;
1141 /* non-queued sanity tests for control (chapter 9 subset) */
1142 case 9:
1143 retval = 0;
1144 dbg ("%s TEST 9: ch9 (subset) control tests, %d times",
1145 dev->id, param->iterations);
1146 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1147 retval = ch9_postconfig (dev);
1148 if (retval)
1149 dbg ("ch9 subset failed, iterations left %d", i);
1150 break;
1152 /* queued control messaging */
1153 case 10:
1154 if (param->sglen == 0)
1155 break;
1156 retval = 0;
1157 dbg ("%s TEST 10: queue %d control calls, %d times",
1158 dev->id, param->sglen,
1159 param->iterations);
1160 retval = test_ctrl_queue (dev, param);
1161 break;
1163 /* simple non-queued unlinks (ring with one urb) */
1164 case 11:
1165 if (dev->in_pipe == 0 || !param->length)
1166 break;
1167 retval = 0;
1168 dbg ("%s TEST 11: unlink %d reads of %d",
1169 dev->id, param->iterations, param->length);
1170 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1171 retval = unlink_simple (dev, dev->in_pipe, param->length);
1172 if (retval)
1173 dbg ("unlink reads failed, iterations left %d", i);
1174 break;
1175 case 12:
1176 if (dev->out_pipe == 0 || !param->length)
1177 break;
1178 retval = 0;
1179 dbg ("%s TEST 12: unlink %d writes of %d",
1180 dev->id, param->iterations, param->length);
1181 for (i = param->iterations; retval == 0 && i--; /* NOP */)
1182 retval = unlink_simple (dev, dev->out_pipe, param->length);
1183 if (retval)
1184 dbg ("unlink writes failed, iterations left %d", i);
1185 break;
1187 // FIXME unlink from queue (ring with N urbs)
1189 // FIXME scatterlist cancel (needs helper thread)
1192 do_gettimeofday (&param->duration);
1193 param->duration.tv_sec -= start.tv_sec;
1194 param->duration.tv_usec -= start.tv_usec;
1195 if (param->duration.tv_usec < 0) {
1196 param->duration.tv_usec += 1000 * 1000;
1197 param->duration.tv_sec -= 1;
1199 up (&dev->sem);
1200 return retval;
1203 /*-------------------------------------------------------------------------*/
1205 static int force_interrupt = 0;
1206 MODULE_PARM (force_interrupt, "i");
1207 MODULE_PARM_DESC (force_interrupt, "0 = test bulk (default), else interrupt");
1209 #ifdef GENERIC
1210 static int vendor;
1211 MODULE_PARM (vendor, "h");
1212 MODULE_PARM_DESC (vendor, "vendor code (from usb-if)");
1214 static int product;
1215 MODULE_PARM (product, "h");
1216 MODULE_PARM_DESC (product, "product code (from vendor)");
1217 #endif
1219 static int
1220 usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1222 struct usb_device *udev;
1223 struct usbtest_dev *dev;
1224 struct usbtest_info *info;
1225 char *rtest, *wtest;
1227 udev = interface_to_usbdev (intf);
1229 #ifdef GENERIC
1230 /* specify devices by module parameters? */
1231 if (id->match_flags == 0) {
1232 /* vendor match required, product match optional */
1233 if (!vendor || udev->descriptor.idVendor != (u16)vendor)
1234 return -ENODEV;
1235 if (product && udev->descriptor.idProduct != (u16)product)
1236 return -ENODEV;
1237 dbg ("matched module params, vend=0x%04x prod=0x%04x",
1238 udev->descriptor.idVendor,
1239 udev->descriptor.idProduct);
1241 #endif
1243 dev = kmalloc (sizeof *dev, SLAB_KERNEL);
1244 if (!dev)
1245 return -ENOMEM;
1246 memset (dev, 0, sizeof *dev);
1247 info = (struct usbtest_info *) id->driver_info;
1248 dev->info = info;
1249 init_MUTEX (&dev->sem);
1251 /* use the same kind of id the hid driver shows */
1252 snprintf (dev->id, sizeof dev->id, "%s-%s:%d",
1253 udev->bus->bus_name, udev->devpath,
1254 intf->altsetting [0].desc.bInterfaceNumber);
1255 dev->intf = intf;
1257 /* cacheline-aligned scratch for i/o */
1258 if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == 0) {
1259 kfree (dev);
1260 return -ENOMEM;
1263 /* NOTE this doesn't yet test the handful of difference that are
1264 * visible with high speed interrupts: bigger maxpacket (1K) and
1265 * "high bandwidth" modes (up to 3 packets/uframe).
1267 rtest = wtest = "";
1268 if (force_interrupt || udev->speed == USB_SPEED_LOW) {
1269 if (info->ep_in) {
1270 dev->in_pipe = usb_rcvintpipe (udev, info->ep_in);
1271 rtest = " intr-in";
1273 if (info->ep_out) {
1274 dev->out_pipe = usb_sndintpipe (udev, info->ep_out);
1275 wtest = " intr-out";
1277 } else {
1278 if (info->ep_in) {
1279 dev->in_pipe = usb_rcvbulkpipe (udev, info->ep_in);
1280 rtest = " bulk-in";
1282 if (info->ep_out) {
1283 dev->out_pipe = usb_sndbulkpipe (udev, info->ep_out);
1284 wtest = " bulk-out";
1288 usb_set_intfdata (intf, dev);
1289 info ("%s at %s ... %s speed {control%s%s} tests",
1290 info->name, dev->id,
1291 ({ char *tmp;
1292 switch (udev->speed) {
1293 case USB_SPEED_LOW: tmp = "low"; break;
1294 case USB_SPEED_FULL: tmp = "full"; break;
1295 case USB_SPEED_HIGH: tmp = "high"; break;
1296 default: tmp = "unknown"; break;
1297 }; tmp; }), rtest, wtest);
1298 return 0;
1301 static void usbtest_disconnect (struct usb_interface *intf)
1303 struct usbtest_dev *dev = usb_get_intfdata (intf);
1305 down (&dev->sem);
1307 usb_set_intfdata (intf, NULL);
1308 info ("unbound %s", dev->id);
1311 /* Basic testing only needs a device that can source or sink bulk traffic.
1312 * Any device can test control transfers (default with GENERIC binding).
1314 * Several entries work with the default EP0 implementation that's built
1315 * into EZ-USB chips. There's a default vendor ID which can be overridden
1316 * by (very) small config EEPROMS, but otherwise all these devices act
1317 * identically until firmware is loaded: only EP0 works. It turns out
1318 * to be easy to make other endpoints work, without modifying that EP0
1319 * behavior. For now, we expect that kind of firmware.
1322 /* an21xx or fx versions of ez-usb */
1323 static struct usbtest_info ez1_info = {
1324 .name = "EZ-USB device",
1325 .ep_in = 2,
1326 .ep_out = 2,
1327 .alt = 1,
1330 /* fx2 version of ez-usb */
1331 static struct usbtest_info ez2_info = {
1332 .name = "FX2 device",
1333 .ep_in = 6,
1334 .ep_out = 2,
1335 .alt = 1,
1338 /* ezusb family device with dedicated usb test firmware,
1339 * or a peripheral running Linux and 'zero.c' test firmware.
1341 * FIXME usbtest should read the descriptors, since compatible
1342 * test firmware might run on hardware (pxa250 for one) that
1343 * can't configure an ep2in-bulk.
1345 static struct usbtest_info fw_info = {
1346 .name = "usb test device",
1347 .ep_in = 2,
1348 .ep_out = 2,
1349 .alt = 0,
1352 static struct usbtest_info um_info = {
1353 .name = "user mode test driver",
1354 .ep_in = 7,
1355 .ep_out = 3,
1356 .alt = -1,
1359 #ifdef IBOT2
1360 /* this is a nice source of high speed bulk data;
1361 * uses an FX2, with firmware provided in the device
1363 static struct usbtest_info ibot2_info = {
1364 .name = "iBOT2 webcam",
1365 .ep_in = 2,
1366 .alt = -1,
1368 #endif
1370 #ifdef GENERIC
1371 /* we can use any device to test control traffic */
1372 static struct usbtest_info generic_info = {
1373 .name = "Generic USB device",
1374 .alt = -1,
1376 #endif
1378 // FIXME remove this
1379 static struct usbtest_info hact_info = {
1380 .name = "FX2/hact",
1381 //.ep_in = 6,
1382 .ep_out = 2,
1383 .alt = -1,
1387 static struct usb_device_id id_table [] = {
1389 { USB_DEVICE (0x0547, 0x1002),
1390 .driver_info = (unsigned long) &hact_info,
1393 /*-------------------------------------------------------------*/
1395 /* EZ-USB devices which download firmware to replace (or in our
1396 * case augment) the default device implementation.
1399 /* generic EZ-USB FX controller */
1400 { USB_DEVICE (0x0547, 0x2235),
1401 .driver_info = (unsigned long) &ez1_info,
1404 /* CY3671 development board with EZ-USB FX */
1405 { USB_DEVICE (0x0547, 0x0080),
1406 .driver_info = (unsigned long) &ez1_info,
1409 /* generic EZ-USB FX2 controller (or development board) */
1410 { USB_DEVICE (0x04b4, 0x8613),
1411 .driver_info = (unsigned long) &ez2_info,
1414 /* re-enumerated usb test device firmware */
1415 { USB_DEVICE (0xfff0, 0xfff0),
1416 .driver_info = (unsigned long) &fw_info,
1419 /* "Gadget Zero" firmware runs under Linux */
1420 { USB_DEVICE (0x0525, 0xa4a0),
1421 .driver_info = (unsigned long) &fw_info,
1424 /* so does a user-mode variant */
1425 { USB_DEVICE (0x0525, 0xa4a4),
1426 .driver_info = (unsigned long) &um_info,
1429 #ifdef KEYSPAN_19Qi
1430 /* Keyspan 19qi uses an21xx (original EZ-USB) */
1431 // this does not coexist with the real Keyspan 19qi driver!
1432 { USB_DEVICE (0x06cd, 0x010b),
1433 .driver_info = (unsigned long) &ez1_info,
1435 #endif
1437 /*-------------------------------------------------------------*/
1439 #ifdef IBOT2
1440 /* iBOT2 makes a nice source of high speed bulk-in data */
1441 // this does not coexist with a real iBOT2 driver!
1442 { USB_DEVICE (0x0b62, 0x0059),
1443 .driver_info = (unsigned long) &ibot2_info,
1445 #endif
1447 /*-------------------------------------------------------------*/
1449 #ifdef GENERIC
1450 /* module params can specify devices to use for control tests */
1451 { .driver_info = (unsigned long) &generic_info, },
1452 #endif
1454 /*-------------------------------------------------------------*/
1458 MODULE_DEVICE_TABLE (usb, id_table);
1460 static struct usb_driver usbtest_driver = {
1461 .owner = THIS_MODULE,
1462 .name = "usbtest",
1463 .id_table = id_table,
1464 .probe = usbtest_probe,
1465 .ioctl = usbtest_ioctl,
1466 .disconnect = usbtest_disconnect,
1469 /*-------------------------------------------------------------------------*/
1471 static int __init usbtest_init (void)
1473 #ifdef GENERIC
1474 if (vendor)
1475 dbg ("params: vend=0x%04x prod=0x%04x", vendor, product);
1476 #endif
1477 return usb_register (&usbtest_driver);
1479 module_init (usbtest_init);
1481 static void __exit usbtest_exit (void)
1483 usb_deregister (&usbtest_driver);
1485 module_exit (usbtest_exit);
1487 MODULE_DESCRIPTION ("USB Core/HCD Testing Driver");
1488 MODULE_LICENSE ("GPL");