Lines Matching +full:sg +full:- +full:micro
1 // SPDX-License-Identifier: GPL-2.0
16 /*-------------------------------------------------------------------------*/
18 static int override_alt = -1;
23 /*-------------------------------------------------------------------------*/
30 __u32 test_num; /* 0..(TEST_CASES-1) */
47 __u32 test_num; /* 0..(TEST_CASES-1) */
63 /*-------------------------------------------------------------------------*/
72 //#define KEYSPAN_19Qi /* grab un-renumerated serial adapter */
74 /*-------------------------------------------------------------------------*/
112 return interface_to_usbdev(test->intf); in testdev_to_usbdev()
119 dev_err(&(tdev)->intf->dev , fmt , ## args)
121 dev_warn(&(tdev)->intf->dev , fmt , ## args)
126 /*-------------------------------------------------------------------------*/
152 for (tmp = 0; tmp < intf->num_altsetting; tmp++) { in get_endpoints()
158 alt = intf->altsetting + tmp; in get_endpoints()
161 override_alt != alt->desc.bAlternateSetting) in get_endpoints()
164 /* take the first altsetting with in-bulk + out-bulk; in get_endpoints()
167 for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { in get_endpoints()
171 e = alt->endpoint + ep; in get_endpoints()
172 edi = usb_endpoint_dir_in(&e->desc); in get_endpoints()
174 switch (usb_endpoint_type(&e->desc)) { in get_endpoints()
179 if (dev->info->intr) in get_endpoints()
183 if (dev->info->iso) in get_endpoints()
193 return -EINVAL; in get_endpoints()
197 dev->info->alt = alt->desc.bAlternateSetting; in get_endpoints()
198 if (alt->desc.bAlternateSetting != 0) { in get_endpoints()
200 alt->desc.bInterfaceNumber, in get_endpoints()
201 alt->desc.bAlternateSetting); in get_endpoints()
207 dev->in_pipe = usb_rcvbulkpipe(udev, in get_endpoints()
208 in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in get_endpoints()
210 dev->out_pipe = usb_sndbulkpipe(udev, in get_endpoints()
211 out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in get_endpoints()
214 dev->iso_in = &iso_in->desc; in get_endpoints()
215 dev->in_iso_pipe = usb_rcvisocpipe(udev, in get_endpoints()
216 iso_in->desc.bEndpointAddress in get_endpoints()
221 dev->iso_out = &iso_out->desc; in get_endpoints()
222 dev->out_iso_pipe = usb_sndisocpipe(udev, in get_endpoints()
223 iso_out->desc.bEndpointAddress in get_endpoints()
228 dev->int_in = &int_in->desc; in get_endpoints()
229 dev->in_int_pipe = usb_rcvintpipe(udev, in get_endpoints()
230 int_in->desc.bEndpointAddress in get_endpoints()
235 dev->int_out = &int_out->desc; in get_endpoints()
236 dev->out_int_pipe = usb_sndintpipe(udev, in get_endpoints()
237 int_out->desc.bEndpointAddress in get_endpoints()
243 /*-------------------------------------------------------------------------*/
245 /* Support for testing basic non-queued I/O streams.
249 * them with non-zero test data (or test for it) when appropriate.
254 complete(urb->context); in simple_callback()
279 urb->interval = (udev->speed == USB_SPEED_HIGH) in usbtest_alloc_urb()
282 urb->transfer_flags = transfer_flags; in usbtest_alloc_urb()
284 urb->transfer_flags |= URB_SHORT_NOT_OK; in usbtest_alloc_urb()
289 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) in usbtest_alloc_urb()
290 urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset, in usbtest_alloc_urb()
291 GFP_KERNEL, &urb->transfer_dma); in usbtest_alloc_urb()
293 urb->transfer_buffer = kmalloc(bytes + offset, GFP_KERNEL); in usbtest_alloc_urb()
295 if (!urb->transfer_buffer) { in usbtest_alloc_urb()
303 memset(urb->transfer_buffer, GUARD_BYTE, offset); in usbtest_alloc_urb()
304 urb->transfer_buffer += offset; in usbtest_alloc_urb()
305 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) in usbtest_alloc_urb()
306 urb->transfer_dma += offset; in usbtest_alloc_urb()
311 memset(urb->transfer_buffer, in usbtest_alloc_urb()
312 usb_pipein(urb->pipe) ? GUARD_BYTE : 0, in usbtest_alloc_urb()
347 return le16_to_cpup(&ep->desc.wMaxPacketSize); in get_maxpacket()
354 return USB_SS_MULT(ep->ss_ep_comp.bmAttributes) in ss_isoc_get_packet_num()
355 * (1 + ep->ss_ep_comp.bMaxBurst); in ss_isoc_get_packet_num()
361 u8 *buf = urb->transfer_buffer; in simple_fill_buf()
362 unsigned len = urb->transfer_buffer_length; in simple_fill_buf()
372 maxpacket = get_maxpacket(urb->dev, urb->pipe); in simple_fill_buf()
381 return (unsigned long)buf & (ARCH_KMALLOC_MINALIGN - 1); in buffer_offset()
386 u8 *buf = urb->transfer_buffer; in check_guard_bytes()
387 u8 *guard = buf - buffer_offset(buf); in check_guard_bytes()
394 return -EINVAL; in check_guard_bytes()
404 u8 *buf = urb->transfer_buffer; in simple_check_buf()
405 unsigned len = urb->actual_length; in simple_check_buf()
406 unsigned maxpacket = get_maxpacket(urb->dev, urb->pipe); in simple_check_buf()
414 /* all-zeroes has no synchronization issues */ in simple_check_buf()
418 /* mod63 stays in sync with short-terminated transfers, in simple_check_buf()
434 return -EINVAL; in simple_check_buf()
441 unsigned long offset = buffer_offset(urb->transfer_buffer); in simple_free_urb()
443 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) in simple_free_urb()
445 urb->dev, in simple_free_urb()
446 urb->transfer_buffer_length + offset, in simple_free_urb()
447 urb->transfer_buffer - offset, in simple_free_urb()
448 urb->transfer_dma - offset); in simple_free_urb()
450 kfree(urb->transfer_buffer - offset); in simple_free_urb()
463 struct usb_device *udev = urb->dev; in simple_io()
464 int max = urb->transfer_buffer_length; in simple_io()
469 urb->context = &completion; in simple_io()
470 while (retval == 0 && iterations-- > 0) { in simple_io()
472 if (usb_pipeout(urb->pipe)) { in simple_io()
474 urb->transfer_flags |= URB_ZERO_PACKET; in simple_io()
483 retval = (urb->status == -ENOENT ? in simple_io()
484 -ETIMEDOUT : urb->status); in simple_io()
486 retval = urb->status; in simple_io()
489 urb->dev = udev; in simple_io()
490 if (retval == 0 && usb_pipein(urb->pipe)) in simple_io()
494 int len = urb->transfer_buffer_length; in simple_io()
500 urb->transfer_buffer_length = len; in simple_io()
505 urb->transfer_buffer_length = max; in simple_io()
508 dev_err(&udev->dev, in simple_io()
515 /*-------------------------------------------------------------------------*/
521 static void free_sglist(struct scatterlist *sg, int nents) in free_sglist() argument
525 if (!sg) in free_sglist()
528 if (!sg_page(&sg[i])) in free_sglist()
530 kfree(sg_virt(&sg[i])); in free_sglist()
532 kfree(sg); in free_sglist()
538 struct scatterlist *sg; in alloc_sglist() local
543 get_maxpacket(interface_to_usbdev(dev->intf), pipe); in alloc_sglist()
548 sg = kmalloc_array(nents, sizeof(*sg), GFP_KERNEL); in alloc_sglist()
549 if (!sg) in alloc_sglist()
551 sg_init_table(sg, nents); in alloc_sglist()
559 free_sglist(sg, i); in alloc_sglist()
564 sg_set_buf(&sg[i], buf, size); in alloc_sglist()
585 return sg; in alloc_sglist()
597 usb_sg_cancel(timeout->req); in sg_timeout()
605 struct scatterlist *sg, in perform_sglist() argument
617 while (retval == 0 && iterations-- > 0) { in perform_sglist()
619 (udev->speed == USB_SPEED_HIGH) in perform_sglist()
622 sg, nents, 0, GFP_KERNEL); in perform_sglist()
630 retval = -ETIMEDOUT; in perform_sglist()
632 retval = req->status; in perform_sglist()
651 /*-------------------------------------------------------------------------*/
671 struct usb_interface *iface = dev->intf; in get_altsetting()
677 0, iface->altsetting[0].desc.bInterfaceNumber, in get_altsetting()
678 dev->buf, 1, USB_CTRL_GET_TIMEOUT); in get_altsetting()
681 return dev->buf[0]; in get_altsetting()
683 retval = -ERANGE; in get_altsetting()
692 struct usb_interface *iface = dev->intf; in set_altsetting()
696 return -EINVAL; in set_altsetting()
700 iface->altsetting[0].desc.bInterfaceNumber, in set_altsetting()
710 config = (struct usb_config_descriptor *) tdev->buf; in is_good_config()
712 switch (config->bDescriptorType) { in is_good_config()
715 if (config->bLength != 9) { in is_good_config()
720 if (!realworld && !(config->bmAttributes & 0x80)) { in is_good_config()
724 if (config->bmAttributes & 0x1f) { /* reserved == 0 */ in is_good_config()
733 if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ in is_good_config()
735 if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ in is_good_config()
748 if (ext->bLength != USB_DT_USB_EXT_CAP_SIZE) { in is_good_ext()
753 attr = le32_to_cpu(ext->bmAttributes); in is_good_ext()
769 if (ss->bLength != USB_DT_USB_SS_CAP_SIZE) { in is_good_ss_cap()
778 if (ss->bmAttributes & ~0x02) { /* reserved == 0 */ in is_good_ss_cap()
784 if (le16_to_cpu(ss->wSpeedSupported) & ~0x0f) { /* reserved == 0 */ in is_good_ss_cap()
798 if (con_id->bLength != USB_DT_USB_SS_CONTN_ID_SIZE) { in is_good_con_id()
803 if (con_id->bReserved) { /* reserved == 0 */ in is_good_con_id()
828 struct usb_interface *iface = dev->intf; in ch9_postconfig()
835 for (i = 0; i < iface->num_altsetting; i++) { in ch9_postconfig()
838 alt = iface->altsetting[i].desc.bAlternateSetting; in ch9_postconfig()
839 if (alt < 0 || alt >= iface->num_altsetting) { in ch9_postconfig()
840 dev_err(&iface->dev, in ch9_postconfig()
846 if (realworld && iface->num_altsetting == 1) in ch9_postconfig()
852 dev_err(&iface->dev, "can't set_interface = %d, %d\n", in ch9_postconfig()
860 dev_err(&iface->dev, "get alt should be %d, was %d\n", in ch9_postconfig()
862 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
868 if (!realworld || udev->descriptor.bNumConfigurations != 1) { in ch9_postconfig()
869 int expected = udev->actconfig->desc.bConfigurationValue; in ch9_postconfig()
878 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); in ch9_postconfig()
879 if (retval != 1 || dev->buf[0] != expected) { in ch9_postconfig()
880 dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", in ch9_postconfig()
881 retval, dev->buf[0], expected); in ch9_postconfig()
882 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
888 dev->buf, sizeof(udev->descriptor)); in ch9_postconfig()
889 if (retval != sizeof(udev->descriptor)) { in ch9_postconfig()
890 dev_err(&iface->dev, "dev descriptor --> %d\n", retval); in ch9_postconfig()
891 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
898 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0210) { in ch9_postconfig()
904 retval = usb_get_descriptor(udev, USB_DT_BOS, 0, dev->buf, in ch9_postconfig()
905 sizeof(*udev->bos->desc)); in ch9_postconfig()
906 if (retval != sizeof(*udev->bos->desc)) { in ch9_postconfig()
907 dev_err(&iface->dev, "bos descriptor --> %d\n", retval); in ch9_postconfig()
908 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
911 bos = (struct usb_bos_descriptor *)dev->buf; in ch9_postconfig()
912 total = le16_to_cpu(bos->wTotalLength); in ch9_postconfig()
913 num = bos->bNumDeviceCaps; in ch9_postconfig()
919 * get generic device-level capability descriptors [9.6.2] in ch9_postconfig()
922 retval = usb_get_descriptor(udev, USB_DT_BOS, 0, dev->buf, in ch9_postconfig()
925 dev_err(&iface->dev, "bos descriptor set --> %d\n", in ch9_postconfig()
927 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
930 length = sizeof(*udev->bos->desc); in ch9_postconfig()
931 buf = dev->buf; in ch9_postconfig()
935 dev->buf + total) in ch9_postconfig()
939 length = header->bLength; in ch9_postconfig()
941 if (header->bDescriptorType != in ch9_postconfig()
943 dev_warn(&udev->dev, "not device capability descriptor, skip\n"); in ch9_postconfig()
947 switch (header->bDevCapabilityType) { in ch9_postconfig()
950 dev->buf + total || in ch9_postconfig()
952 dev_err(&iface->dev, "bogus usb 2.0 extension descriptor\n"); in ch9_postconfig()
953 return -EDOM; in ch9_postconfig()
958 dev->buf + total || in ch9_postconfig()
960 dev_err(&iface->dev, "bogus superspeed device capability descriptor\n"); in ch9_postconfig()
961 return -EDOM; in ch9_postconfig()
966 dev->buf + total || in ch9_postconfig()
968 dev_err(&iface->dev, "bogus container id descriptor\n"); in ch9_postconfig()
969 return -EDOM; in ch9_postconfig()
979 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { in ch9_postconfig()
981 dev->buf, TBUF_SIZE); in ch9_postconfig()
983 dev_err(&iface->dev, in ch9_postconfig()
984 "config [%d] descriptor --> %d\n", in ch9_postconfig()
986 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
989 /* FIXME cross-checking udev->config[i] to make sure usbcore in ch9_postconfig()
995 if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { in ch9_postconfig()
1000 USB_DT_DEVICE_QUALIFIER, 0, dev->buf, in ch9_postconfig()
1002 if (retval == -EPIPE) { in ch9_postconfig()
1003 if (udev->speed == USB_SPEED_HIGH) { in ch9_postconfig()
1004 dev_err(&iface->dev, in ch9_postconfig()
1005 "hs dev qualifier --> %d\n", in ch9_postconfig()
1009 /* usb2.0 but not high-speed capable; fine */ in ch9_postconfig()
1011 dev_err(&iface->dev, "dev qualifier --> %d\n", retval); in ch9_postconfig()
1012 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
1014 d = (struct usb_qualifier_descriptor *) dev->buf; in ch9_postconfig()
1016 /* might not have [9.6.2] any other-speed configs [9.6.4] */ in ch9_postconfig()
1018 unsigned max = d->bNumConfigurations; in ch9_postconfig()
1022 dev->buf, TBUF_SIZE); in ch9_postconfig()
1024 dev_err(&iface->dev, in ch9_postconfig()
1025 "other speed config --> %d\n", in ch9_postconfig()
1027 return (retval < 0) ? retval : -EDOM; in ch9_postconfig()
1035 retval = usb_get_std_status(udev, USB_RECIP_DEVICE, 0, dev->buf); in ch9_postconfig()
1037 dev_err(&iface->dev, "get dev status --> %d\n", retval); in ch9_postconfig()
1046 iface->altsetting[0].desc.bInterfaceNumber, dev->buf); in ch9_postconfig()
1048 dev_err(&iface->dev, "get interface status --> %d\n", retval); in ch9_postconfig()
1056 /*-------------------------------------------------------------------------*/
1060 * active (auto-resubmit) for M loops through the queue.
1061 * (b) protocol stalls (control-only) will autorecover.
1064 * (d) queues are always processed in-order
1089 struct ctrl_ctx *ctx = urb->context; in ctrl_complete()
1092 int status = urb->status; in ctrl_complete()
1095 reqp = (struct usb_ctrlrequest *)urb->setup_packet; in ctrl_complete()
1098 spin_lock_irqsave(&ctx->lock, flags); in ctrl_complete()
1099 ctx->count--; in ctrl_complete()
1100 ctx->pending--; in ctrl_complete()
1106 if (subcase->number > 0) { in ctrl_complete()
1107 if ((subcase->number - ctx->last) != 1) { in ctrl_complete()
1108 ERROR(ctx->dev, in ctrl_complete()
1110 subcase->number, ctx->last); in ctrl_complete()
1111 status = -EDOM; in ctrl_complete()
1112 ctx->last = subcase->number; in ctrl_complete()
1116 ctx->last = subcase->number; in ctrl_complete()
1119 if (status == subcase->expected) in ctrl_complete()
1123 else if (status != -ECONNRESET) { in ctrl_complete()
1126 if (subcase->expected > 0 && ( in ctrl_complete()
1127 ((status == -subcase->expected /* happened */ in ctrl_complete()
1131 else if (subcase->number == 12 && status == -EPIPE) in ctrl_complete()
1134 ERROR(ctx->dev, "subtest %d error, status %d\n", in ctrl_complete()
1135 subcase->number, status); in ctrl_complete()
1141 if (ctx->status == 0) { in ctrl_complete()
1144 ctx->status = status; in ctrl_complete()
1145 ERROR(ctx->dev, "control queue %02x.%02x, err %d, " in ctrl_complete()
1147 reqp->bRequestType, reqp->bRequest, in ctrl_complete()
1148 status, ctx->count, subcase->number, in ctrl_complete()
1149 urb->actual_length, in ctrl_complete()
1150 urb->transfer_buffer_length); in ctrl_complete()
1157 for (i = 1; i < ctx->param->sglen; i++) { in ctrl_complete()
1158 struct urb *u = ctx->urb[ in ctrl_complete()
1159 (i + subcase->number) in ctrl_complete()
1160 % ctx->param->sglen]; in ctrl_complete()
1162 if (u == urb || !u->dev) in ctrl_complete()
1164 spin_unlock(&ctx->lock); in ctrl_complete()
1166 spin_lock(&ctx->lock); in ctrl_complete()
1168 case -EINPROGRESS: in ctrl_complete()
1169 case -EBUSY: in ctrl_complete()
1170 case -EIDRM: in ctrl_complete()
1173 ERROR(ctx->dev, "urb unlink --> %d\n", in ctrl_complete()
1177 status = ctx->status; in ctrl_complete()
1182 if ((status == 0) && (ctx->pending < ctx->count)) { in ctrl_complete()
1185 ERROR(ctx->dev, in ctrl_complete()
1187 reqp->bRequestType, reqp->bRequest, status); in ctrl_complete()
1188 urb->dev = NULL; in ctrl_complete()
1190 ctx->pending++; in ctrl_complete()
1192 urb->dev = NULL; in ctrl_complete()
1195 if (ctx->pending == 0) in ctrl_complete()
1196 complete(&ctx->complete); in ctrl_complete()
1197 spin_unlock_irqrestore(&ctx->lock, flags); in ctrl_complete()
1208 if (param->sglen == 0 || param->iterations > UINT_MAX / param->sglen) in test_ctrl_queue()
1209 return -EOPNOTSUPP; in test_ctrl_queue()
1214 context.count = param->sglen * param->iterations; in test_ctrl_queue()
1216 context.status = -ENOMEM; in test_ctrl_queue()
1218 context.last = -1; in test_ctrl_queue()
1224 urb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL); in test_ctrl_queue()
1226 return -ENOMEM; in test_ctrl_queue()
1227 for (i = 0; i < param->sglen; i++) { in test_ctrl_queue()
1235 * -: tested code must return this (negative) error code in test_ctrl_queue()
1278 if (udev->speed != USB_SPEED_HIGH) in test_ctrl_queue()
1290 expected = -EPIPE; in test_ctrl_queue()
1312 expected = -EREMOTEIO; in test_ctrl_queue()
1332 if (udev->speed == USB_SPEED_SUPER) in test_ctrl_queue()
1333 len = 1024 - 512; in test_ctrl_queue()
1335 len = 1024 - udev->descriptor.bMaxPacketSize0; in test_ctrl_queue()
1336 expected = -EREMOTEIO; in test_ctrl_queue()
1341 len = udev->descriptor.bMaxPacketSize0; in test_ctrl_queue()
1342 if (udev->speed == USB_SPEED_SUPER) in test_ctrl_queue()
1352 expected = -EREMOTEIO; in test_ctrl_queue()
1356 if (udev->bos) in test_ctrl_queue()
1357 len = le16_to_cpu(udev->bos->desc->wTotalLength); in test_ctrl_queue()
1360 if (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0201) in test_ctrl_queue()
1361 expected = -EPIPE; in test_ctrl_queue()
1365 context.status = -EINVAL; in test_ctrl_queue()
1376 reqp->setup = req; in test_ctrl_queue()
1377 reqp->number = i % NUM_SUBCASES; in test_ctrl_queue()
1378 reqp->expected = expected; in test_ctrl_queue()
1379 u->setup_packet = (char *) &reqp->setup; in test_ctrl_queue()
1381 u->context = &context; in test_ctrl_queue()
1382 u->complete = ctrl_complete; in test_ctrl_queue()
1388 for (i = 0; i < param->sglen; i++) { in test_ctrl_queue()
1407 for (i = 0; i < param->sglen; i++) { in test_ctrl_queue()
1410 urb[i]->dev = udev; in test_ctrl_queue()
1411 kfree(urb[i]->setup_packet); in test_ctrl_queue()
1420 /*-------------------------------------------------------------------------*/
1424 int status = urb->status; in unlink1_callback()
1426 /* we "know" -EPIPE (stall) never happens */ in unlink1_callback()
1430 urb->status = status; in unlink1_callback()
1431 complete(urb->context); in unlink1_callback()
1444 return -ENOMEM; in unlink1()
1445 urb->context = &completion; in unlink1()
1446 urb->complete = unlink1_callback; in unlink1()
1448 if (usb_pipeout(urb->pipe)) { in unlink1()
1450 urb->transfer_flags |= URB_ZERO_PACKET; in unlink1()
1453 /* keep the endpoint busy. there are lots of hc/hcd-internal in unlink1()
1461 dev_err(&dev->intf->dev, "submit fail %d\n", retval); in unlink1()
1473 if (retval == 0 && usb_pipein(urb->pipe)) in unlink1()
1477 case -EBUSY: in unlink1()
1478 case -EIDRM: in unlink1()
1488 case -EINPROGRESS: in unlink1()
1492 dev_err(&dev->intf->dev, in unlink1()
1503 retval = urb->status; in unlink1()
1507 return (retval == -ECONNRESET) ? 0 : retval - 1000; in unlink1()
1509 return (retval == -ENOENT || retval == -EPERM) ? in unlink1()
1510 0 : retval - 2000; in unlink1()
1524 /*-------------------------------------------------------------------------*/
1536 int status = urb->status; in unlink_queued_callback()
1537 struct queued_ctx *ctx = urb->context; in unlink_queued_callback()
1539 if (ctx->status) in unlink_queued_callback()
1541 if (urb == ctx->urbs[ctx->num - 4] || urb == ctx->urbs[ctx->num - 2]) { in unlink_queued_callback()
1542 if (status == -ECONNRESET) in unlink_queued_callback()
1547 ctx->status = status; in unlink_queued_callback()
1550 if (atomic_dec_and_test(&ctx->pending)) in unlink_queued_callback()
1551 complete(&ctx->complete); in unlink_queued_callback()
1562 int retval = -ENOMEM; in unlink_queued()
1584 ctx.urbs[i]->transfer_dma = buf_dma; in unlink_queued()
1585 ctx.urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; in unlink_queued()
1587 if (usb_pipeout(ctx.urbs[i]->pipe)) { in unlink_queued()
1589 ctx.urbs[i]->transfer_flags |= URB_ZERO_PACKET; in unlink_queued()
1593 /* Submit all the URBs and then unlink URBs num - 4 and num - 2. */ in unlink_queued()
1598 dev_err(&dev->intf->dev, "submit urbs[%d] fail %d\n", in unlink_queued()
1606 usb_unlink_urb(ctx.urbs[num - 4]); in unlink_queued()
1607 usb_unlink_urb(ctx.urbs[num - 2]); in unlink_queued()
1609 while (--i >= 0) in unlink_queued()
1627 /*-------------------------------------------------------------------------*/
1635 retval = usb_get_std_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); in verify_not_halted()
1637 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", in verify_not_halted()
1643 return -EINVAL; in verify_not_halted()
1647 return -EINVAL; in verify_not_halted()
1657 retval = usb_get_std_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); in verify_halted()
1665 return -EINVAL; in verify_halted()
1667 retval = simple_io(tdev, urb, 1, 0, -EPIPE, __func__); in verify_halted()
1668 if (retval != -EPIPE) in verify_halted()
1669 return -EINVAL; in verify_halted()
1670 retval = simple_io(tdev, urb, 1, 0, -EPIPE, "verify_still_halted"); in verify_halted()
1671 if (retval != -EPIPE) in verify_halted()
1672 return -EINVAL; in verify_halted()
1686 retval = usb_control_msg(urb->dev, usb_sndctrlpipe(urb->dev, 0), in test_halt()
1699 ret = usb_clear_halt(urb->dev, urb->pipe); in test_halt()
1708 retval = usb_clear_halt(urb->dev, urb->pipe); in test_halt()
1727 retval = usb_clear_halt(urb->dev, urb->pipe); in test_toggle_sync()
1736 return -EINVAL; in test_toggle_sync()
1739 retval = usb_clear_halt(urb->dev, urb->pipe); in test_toggle_sync()
1758 if (udev->speed == USB_SPEED_SUPER) in halt_simple()
1763 return -ENOMEM; in halt_simple()
1765 if (dev->in_pipe) { in halt_simple()
1766 ep = usb_pipeendpoint(dev->in_pipe) | USB_DIR_IN; in halt_simple()
1767 urb->pipe = dev->in_pipe; in halt_simple()
1773 if (dev->out_pipe) { in halt_simple()
1774 ep = usb_pipeendpoint(dev->out_pipe); in halt_simple()
1775 urb->pipe = dev->out_pipe; in halt_simple()
1789 unsigned maxp = get_maxpacket(udev, dev->out_pipe); in toggle_sync_simple()
1798 return -ENOMEM; in toggle_sync_simple()
1800 urb->transfer_flags |= URB_ZERO_PACKET; in toggle_sync_simple()
1802 ep = usb_pipeendpoint(dev->out_pipe); in toggle_sync_simple()
1803 urb->pipe = dev->out_pipe; in toggle_sync_simple()
1810 /*-------------------------------------------------------------------------*/
1830 return -EINVAL; in ctrl_out()
1834 return -ENOMEM; in ctrl_out()
1842 * with lots back-to-back queued requests. in ctrl_out()
1856 retval = -EBADMSG; in ctrl_out()
1861 /* read it back -- assuming nothing intervened!! */ in ctrl_out()
1870 retval = -EBADMSG; in ctrl_out()
1880 retval = -EBADMSG; in ctrl_out()
1903 kfree(buf - offset); in ctrl_out()
1907 /*-------------------------------------------------------------------------*/
1910 * - buffer length is split into N packets (mostly maxpacket sized)
1911 * - multi-buffers according to sglen
1928 struct transfer_context *ctx = urb->context; in complicated_callback()
1931 spin_lock_irqsave(&ctx->lock, flags); in complicated_callback()
1932 ctx->count--; in complicated_callback()
1934 ctx->packet_count += urb->number_of_packets; in complicated_callback()
1935 if (urb->error_count > 0) in complicated_callback()
1936 ctx->errors += urb->error_count; in complicated_callback()
1937 else if (urb->status != 0) in complicated_callback()
1938 ctx->errors += (ctx->is_iso ? urb->number_of_packets : 1); in complicated_callback()
1939 else if (urb->actual_length != urb->transfer_buffer_length) in complicated_callback()
1940 ctx->errors++; in complicated_callback()
1941 else if (check_guard_bytes(ctx->dev, urb) != 0) in complicated_callback()
1942 ctx->errors++; in complicated_callback()
1944 if (urb->status == 0 && ctx->count > (ctx->pending - 1) in complicated_callback()
1945 && !ctx->submit_error) { in complicated_callback()
1951 dev_err(&ctx->dev->intf->dev, in complicated_callback()
1955 case -ENODEV: /* disconnected */ in complicated_callback()
1956 case -ESHUTDOWN: /* endpoint disabled */ in complicated_callback()
1957 ctx->submit_error = 1; in complicated_callback()
1962 ctx->pending--; in complicated_callback()
1963 if (ctx->pending == 0) { in complicated_callback()
1964 if (ctx->errors) in complicated_callback()
1965 dev_err(&ctx->dev->intf->dev, in complicated_callback()
1967 ctx->errors, ctx->packet_count); in complicated_callback()
1968 complete(&ctx->done); in complicated_callback()
1971 spin_unlock_irqrestore(&ctx->lock, flags); in complicated_callback()
1989 if (udev->speed >= USB_SPEED_SUPER) in iso_alloc_urb()
1999 urb->dev = udev; in iso_alloc_urb()
2000 urb->pipe = pipe; in iso_alloc_urb()
2002 urb->number_of_packets = packets; in iso_alloc_urb()
2003 urb->transfer_buffer_length = bytes; in iso_alloc_urb()
2004 urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset, in iso_alloc_urb()
2006 &urb->transfer_dma); in iso_alloc_urb()
2007 if (!urb->transfer_buffer) { in iso_alloc_urb()
2012 memset(urb->transfer_buffer, GUARD_BYTE, offset); in iso_alloc_urb()
2013 urb->transfer_buffer += offset; in iso_alloc_urb()
2014 urb->transfer_dma += offset; in iso_alloc_urb()
2018 memset(urb->transfer_buffer, in iso_alloc_urb()
2019 usb_pipein(urb->pipe) ? GUARD_BYTE : 0, in iso_alloc_urb()
2024 urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp); in iso_alloc_urb()
2025 bytes -= urb->iso_frame_desc[i].length; in iso_alloc_urb()
2027 urb->iso_frame_desc[i].offset = maxp * i; in iso_alloc_urb()
2030 urb->complete = complicated_callback; in iso_alloc_urb()
2031 /* urb->context = SET BY CALLER */ in iso_alloc_urb()
2032 urb->interval = 1 << (desc->bInterval - 1); in iso_alloc_urb()
2033 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; in iso_alloc_urb()
2048 if (!param->sglen || param->iterations > UINT_MAX / param->sglen) in test_queue()
2049 return -EINVAL; in test_queue()
2051 if (param->sglen > MAX_SGLEN) in test_queue()
2052 return -EINVAL; in test_queue()
2054 urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL); in test_queue()
2056 return -ENOMEM; in test_queue()
2059 context.count = param->iterations * param->sglen; in test_queue()
2067 for (i = 0; i < param->sglen; i++) { in test_queue()
2070 param->length, offset); in test_queue()
2073 param->length, 0); in test_queue()
2076 status = -ENOMEM; in test_queue()
2079 packets += urbs[i]->number_of_packets; in test_queue()
2080 urbs[i]->context = &context; in test_queue()
2082 packets *= param->iterations; in test_queue()
2087 if (udev->speed >= USB_SPEED_SUPER) in test_queue()
2092 dev_info(&dev->intf->dev, in test_queue()
2094 1 << (desc->bInterval - 1), in test_queue()
2095 (udev->speed >= USB_SPEED_HIGH) ? "micro" : "", in test_queue()
2099 dev_info(&dev->intf->dev, in test_queue()
2101 (packets * (1 << (desc->bInterval - 1))) in test_queue()
2102 / ((udev->speed >= USB_SPEED_HIGH) ? 8 : 1), in test_queue()
2107 for (i = 0; i < param->sglen; i++) { in test_queue()
2119 context.pending--; in test_queue()
2128 for (i = 0; i < param->sglen; i++) { in test_queue()
2140 status = -EACCES; in test_queue()
2143 status = -EIO; in test_queue()
2149 for (i = 0; i < param->sglen; i++) { in test_queue()
2171 return -ENOMEM; in test_unaligned_bulk()
2185 struct scatterlist *sg; in usbtest_do_ioctl() local
2188 int retval = -EOPNOTSUPP; in usbtest_do_ioctl()
2190 if (param->iterations <= 0) in usbtest_do_ioctl()
2191 return -EINVAL; in usbtest_do_ioctl()
2192 if (param->sglen > MAX_SGLEN) in usbtest_do_ioctl()
2193 return -EINVAL; in usbtest_do_ioctl()
2203 switch (param->test_num) { in usbtest_do_ioctl()
2206 dev_info(&intf->dev, "TEST 0: NOP\n"); in usbtest_do_ioctl()
2210 /* Simple non-queued bulk I/O tests */ in usbtest_do_ioctl()
2212 if (dev->out_pipe == 0) in usbtest_do_ioctl()
2214 dev_info(&intf->dev, in usbtest_do_ioctl()
2216 param->length, param->iterations); in usbtest_do_ioctl()
2217 urb = simple_alloc_urb(udev, dev->out_pipe, param->length, 0); in usbtest_do_ioctl()
2219 retval = -ENOMEM; in usbtest_do_ioctl()
2223 retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); in usbtest_do_ioctl()
2227 if (dev->in_pipe == 0) in usbtest_do_ioctl()
2229 dev_info(&intf->dev, in usbtest_do_ioctl()
2231 param->length, param->iterations); in usbtest_do_ioctl()
2232 urb = simple_alloc_urb(udev, dev->in_pipe, param->length, 0); in usbtest_do_ioctl()
2234 retval = -ENOMEM; in usbtest_do_ioctl()
2238 retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); in usbtest_do_ioctl()
2242 if (dev->out_pipe == 0 || param->vary == 0) in usbtest_do_ioctl()
2244 dev_info(&intf->dev, in usbtest_do_ioctl()
2246 param->vary, param->length, param->iterations); in usbtest_do_ioctl()
2247 urb = simple_alloc_urb(udev, dev->out_pipe, param->length, 0); in usbtest_do_ioctl()
2249 retval = -ENOMEM; in usbtest_do_ioctl()
2253 retval = simple_io(dev, urb, param->iterations, param->vary, in usbtest_do_ioctl()
2258 if (dev->in_pipe == 0 || param->vary == 0) in usbtest_do_ioctl()
2260 dev_info(&intf->dev, in usbtest_do_ioctl()
2262 param->vary, param->length, param->iterations); in usbtest_do_ioctl()
2263 urb = simple_alloc_urb(udev, dev->in_pipe, param->length, 0); in usbtest_do_ioctl()
2265 retval = -ENOMEM; in usbtest_do_ioctl()
2269 retval = simple_io(dev, urb, param->iterations, param->vary, in usbtest_do_ioctl()
2276 if (dev->out_pipe == 0 || param->sglen == 0) in usbtest_do_ioctl()
2278 dev_info(&intf->dev, in usbtest_do_ioctl()
2280 param->iterations, in usbtest_do_ioctl()
2281 param->sglen, param->length); in usbtest_do_ioctl()
2282 sg = alloc_sglist(param->sglen, param->length, in usbtest_do_ioctl()
2283 0, dev, dev->out_pipe); in usbtest_do_ioctl()
2284 if (!sg) { in usbtest_do_ioctl()
2285 retval = -ENOMEM; in usbtest_do_ioctl()
2289 retval = perform_sglist(dev, param->iterations, dev->out_pipe, in usbtest_do_ioctl()
2290 &req, sg, param->sglen); in usbtest_do_ioctl()
2291 free_sglist(sg, param->sglen); in usbtest_do_ioctl()
2295 if (dev->in_pipe == 0 || param->sglen == 0) in usbtest_do_ioctl()
2297 dev_info(&intf->dev, in usbtest_do_ioctl()
2299 param->iterations, in usbtest_do_ioctl()
2300 param->sglen, param->length); in usbtest_do_ioctl()
2301 sg = alloc_sglist(param->sglen, param->length, in usbtest_do_ioctl()
2302 0, dev, dev->in_pipe); in usbtest_do_ioctl()
2303 if (!sg) { in usbtest_do_ioctl()
2304 retval = -ENOMEM; in usbtest_do_ioctl()
2308 retval = perform_sglist(dev, param->iterations, dev->in_pipe, in usbtest_do_ioctl()
2309 &req, sg, param->sglen); in usbtest_do_ioctl()
2310 free_sglist(sg, param->sglen); in usbtest_do_ioctl()
2313 if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) in usbtest_do_ioctl()
2315 dev_info(&intf->dev, in usbtest_do_ioctl()
2317 param->vary, param->iterations, in usbtest_do_ioctl()
2318 param->sglen, param->length); in usbtest_do_ioctl()
2319 sg = alloc_sglist(param->sglen, param->length, in usbtest_do_ioctl()
2320 param->vary, dev, dev->out_pipe); in usbtest_do_ioctl()
2321 if (!sg) { in usbtest_do_ioctl()
2322 retval = -ENOMEM; in usbtest_do_ioctl()
2326 retval = perform_sglist(dev, param->iterations, dev->out_pipe, in usbtest_do_ioctl()
2327 &req, sg, param->sglen); in usbtest_do_ioctl()
2328 free_sglist(sg, param->sglen); in usbtest_do_ioctl()
2331 if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) in usbtest_do_ioctl()
2333 dev_info(&intf->dev, in usbtest_do_ioctl()
2335 param->vary, param->iterations, in usbtest_do_ioctl()
2336 param->sglen, param->length); in usbtest_do_ioctl()
2337 sg = alloc_sglist(param->sglen, param->length, in usbtest_do_ioctl()
2338 param->vary, dev, dev->in_pipe); in usbtest_do_ioctl()
2339 if (!sg) { in usbtest_do_ioctl()
2340 retval = -ENOMEM; in usbtest_do_ioctl()
2344 retval = perform_sglist(dev, param->iterations, dev->in_pipe, in usbtest_do_ioctl()
2345 &req, sg, param->sglen); in usbtest_do_ioctl()
2346 free_sglist(sg, param->sglen); in usbtest_do_ioctl()
2349 /* non-queued sanity tests for control (chapter 9 subset) */ in usbtest_do_ioctl()
2352 dev_info(&intf->dev, in usbtest_do_ioctl()
2354 param->iterations); in usbtest_do_ioctl()
2355 for (i = param->iterations; retval == 0 && i--; /* NOP */) in usbtest_do_ioctl()
2358 dev_err(&intf->dev, "ch9 subset failed, " in usbtest_do_ioctl()
2365 dev_info(&intf->dev, in usbtest_do_ioctl()
2367 param->sglen, in usbtest_do_ioctl()
2368 param->iterations); in usbtest_do_ioctl()
2372 /* simple non-queued unlinks (ring with one urb) */ in usbtest_do_ioctl()
2374 if (dev->in_pipe == 0 || !param->length) in usbtest_do_ioctl()
2377 dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", in usbtest_do_ioctl()
2378 param->iterations, param->length); in usbtest_do_ioctl()
2379 for (i = param->iterations; retval == 0 && i--; /* NOP */) in usbtest_do_ioctl()
2380 retval = unlink_simple(dev, dev->in_pipe, in usbtest_do_ioctl()
2381 param->length); in usbtest_do_ioctl()
2383 dev_err(&intf->dev, "unlink reads failed %d, " in usbtest_do_ioctl()
2387 if (dev->out_pipe == 0 || !param->length) in usbtest_do_ioctl()
2390 dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", in usbtest_do_ioctl()
2391 param->iterations, param->length); in usbtest_do_ioctl()
2392 for (i = param->iterations; retval == 0 && i--; /* NOP */) in usbtest_do_ioctl()
2393 retval = unlink_simple(dev, dev->out_pipe, in usbtest_do_ioctl()
2394 param->length); in usbtest_do_ioctl()
2396 dev_err(&intf->dev, "unlink writes failed %d, " in usbtest_do_ioctl()
2402 if (dev->out_pipe == 0 && dev->in_pipe == 0) in usbtest_do_ioctl()
2405 dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", in usbtest_do_ioctl()
2406 param->iterations); in usbtest_do_ioctl()
2407 for (i = param->iterations; retval == 0 && i--; /* NOP */) in usbtest_do_ioctl()
2416 if (!dev->info->ctrl_out) in usbtest_do_ioctl()
2418 dev_info(&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n", in usbtest_do_ioctl()
2419 param->iterations, in usbtest_do_ioctl()
2420 realworld ? 1 : 0, param->length, in usbtest_do_ioctl()
2421 param->vary); in usbtest_do_ioctl()
2422 retval = ctrl_out(dev, param->iterations, in usbtest_do_ioctl()
2423 param->length, param->vary, 0); in usbtest_do_ioctl()
2428 if (dev->out_iso_pipe == 0 || param->sglen == 0) in usbtest_do_ioctl()
2430 dev_info(&intf->dev, in usbtest_do_ioctl()
2432 param->iterations, in usbtest_do_ioctl()
2433 param->sglen, param->length); in usbtest_do_ioctl()
2436 dev->out_iso_pipe, dev->iso_out, 0); in usbtest_do_ioctl()
2441 if (dev->in_iso_pipe == 0 || param->sglen == 0) in usbtest_do_ioctl()
2443 dev_info(&intf->dev, in usbtest_do_ioctl()
2445 param->iterations, in usbtest_do_ioctl()
2446 param->sglen, param->length); in usbtest_do_ioctl()
2449 dev->in_iso_pipe, dev->iso_in, 0); in usbtest_do_ioctl()
2456 if (dev->out_pipe == 0) in usbtest_do_ioctl()
2458 dev_info(&intf->dev, in usbtest_do_ioctl()
2460 param->length, param->iterations); in usbtest_do_ioctl()
2463 dev, dev->out_pipe, in usbtest_do_ioctl()
2464 param->length, param->iterations, in usbtest_do_ioctl()
2469 if (dev->in_pipe == 0) in usbtest_do_ioctl()
2471 dev_info(&intf->dev, in usbtest_do_ioctl()
2473 param->length, param->iterations); in usbtest_do_ioctl()
2476 dev, dev->in_pipe, in usbtest_do_ioctl()
2477 param->length, param->iterations, in usbtest_do_ioctl()
2483 if (dev->out_pipe == 0) in usbtest_do_ioctl()
2485 dev_info(&intf->dev, in usbtest_do_ioctl()
2487 param->length, param->iterations); in usbtest_do_ioctl()
2490 dev, dev->out_pipe, in usbtest_do_ioctl()
2491 param->length, param->iterations, in usbtest_do_ioctl()
2496 if (dev->in_pipe == 0) in usbtest_do_ioctl()
2498 dev_info(&intf->dev, in usbtest_do_ioctl()
2500 param->length, param->iterations); in usbtest_do_ioctl()
2503 dev, dev->in_pipe, in usbtest_do_ioctl()
2504 param->length, param->iterations, in usbtest_do_ioctl()
2510 if (!dev->info->ctrl_out) in usbtest_do_ioctl()
2512 dev_info(&intf->dev, in usbtest_do_ioctl()
2514 param->iterations, in usbtest_do_ioctl()
2515 realworld ? 1 : 0, param->length, in usbtest_do_ioctl()
2516 param->vary); in usbtest_do_ioctl()
2517 retval = ctrl_out(dev, param->iterations, in usbtest_do_ioctl()
2518 param->length, param->vary, 1); in usbtest_do_ioctl()
2523 if (dev->out_iso_pipe == 0 || param->sglen == 0) in usbtest_do_ioctl()
2525 dev_info(&intf->dev, in usbtest_do_ioctl()
2527 param->iterations, in usbtest_do_ioctl()
2528 param->sglen, param->length); in usbtest_do_ioctl()
2530 dev->out_iso_pipe, dev->iso_out, 1); in usbtest_do_ioctl()
2534 if (dev->in_iso_pipe == 0 || param->sglen == 0) in usbtest_do_ioctl()
2536 dev_info(&intf->dev, in usbtest_do_ioctl()
2538 param->iterations, in usbtest_do_ioctl()
2539 param->sglen, param->length); in usbtest_do_ioctl()
2541 dev->in_iso_pipe, dev->iso_in, 1); in usbtest_do_ioctl()
2544 /* unlink URBs from a bulk-OUT queue */ in usbtest_do_ioctl()
2546 if (dev->out_pipe == 0 || !param->length || param->sglen < 4) in usbtest_do_ioctl()
2549 dev_info(&intf->dev, "TEST 24: unlink from %d queues of " in usbtest_do_ioctl()
2550 "%d %d-byte writes\n", in usbtest_do_ioctl()
2551 param->iterations, param->sglen, param->length); in usbtest_do_ioctl()
2552 for (i = param->iterations; retval == 0 && i > 0; --i) { in usbtest_do_ioctl()
2553 retval = unlink_queued(dev, dev->out_pipe, in usbtest_do_ioctl()
2554 param->sglen, param->length); in usbtest_do_ioctl()
2556 dev_err(&intf->dev, in usbtest_do_ioctl()
2564 /* Simple non-queued interrupt I/O tests */ in usbtest_do_ioctl()
2566 if (dev->out_int_pipe == 0) in usbtest_do_ioctl()
2568 dev_info(&intf->dev, in usbtest_do_ioctl()
2570 param->length, param->iterations); in usbtest_do_ioctl()
2571 urb = simple_alloc_urb(udev, dev->out_int_pipe, param->length, in usbtest_do_ioctl()
2572 dev->int_out->bInterval); in usbtest_do_ioctl()
2574 retval = -ENOMEM; in usbtest_do_ioctl()
2578 retval = simple_io(dev, urb, param->iterations, 0, 0, "test25"); in usbtest_do_ioctl()
2582 if (dev->in_int_pipe == 0) in usbtest_do_ioctl()
2584 dev_info(&intf->dev, in usbtest_do_ioctl()
2586 param->length, param->iterations); in usbtest_do_ioctl()
2587 urb = simple_alloc_urb(udev, dev->in_int_pipe, param->length, in usbtest_do_ioctl()
2588 dev->int_in->bInterval); in usbtest_do_ioctl()
2590 retval = -ENOMEM; in usbtest_do_ioctl()
2594 retval = simple_io(dev, urb, param->iterations, 0, 0, "test26"); in usbtest_do_ioctl()
2599 if (dev->out_pipe == 0 || param->sglen == 0 || pattern != 0) in usbtest_do_ioctl()
2601 dev_info(&intf->dev, in usbtest_do_ioctl()
2602 "TEST 27: bulk write %dMbytes\n", (param->iterations * in usbtest_do_ioctl()
2603 param->sglen * param->length) / (1024 * 1024)); in usbtest_do_ioctl()
2605 dev->out_pipe, NULL, 0); in usbtest_do_ioctl()
2608 if (dev->in_pipe == 0 || param->sglen == 0 || pattern != 0) in usbtest_do_ioctl()
2610 dev_info(&intf->dev, in usbtest_do_ioctl()
2611 "TEST 28: bulk read %dMbytes\n", (param->iterations * in usbtest_do_ioctl()
2612 param->sglen * param->length) / (1024 * 1024)); in usbtest_do_ioctl()
2614 dev->in_pipe, NULL, 0); in usbtest_do_ioctl()
2618 if (dev->out_pipe == 0) in usbtest_do_ioctl()
2621 dev_info(&intf->dev, "TEST 29: Clear toggle between bulk writes %d times\n", in usbtest_do_ioctl()
2622 param->iterations); in usbtest_do_ioctl()
2623 for (i = param->iterations; retval == 0 && i > 0; --i) in usbtest_do_ioctl()
2634 /*-------------------------------------------------------------------------*/
2649 * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
2651 * the device-under-test, hub_wq will wait block forever waiting for the
2668 int retval = -EOPNOTSUPP; in usbtest_ioctl()
2674 if (mutex_lock_interruptible(&dev->lock)) in usbtest_ioctl()
2675 return -ERESTARTSYS; in usbtest_ioctl()
2679 /* some devices, like ez-usb default devices, need a non-default in usbtest_ioctl()
2683 if (dev->info->alt >= 0) { in usbtest_ioctl()
2684 if (intf->altsetting->desc.bInterfaceNumber) { in usbtest_ioctl()
2685 retval = -ENODEV; in usbtest_ioctl()
2688 retval = set_altsetting(dev, dev->info->alt); in usbtest_ioctl()
2690 dev_err(&intf->dev, in usbtest_ioctl()
2692 dev->info->alt, retval); in usbtest_ioctl()
2699 temp.test_num = param_64->test_num; in usbtest_ioctl()
2700 temp.iterations = param_64->iterations; in usbtest_ioctl()
2701 temp.length = param_64->length; in usbtest_ioctl()
2702 temp.sglen = param_64->sglen; in usbtest_ioctl()
2703 temp.vary = param_64->vary; in usbtest_ioctl()
2711 retval = -EOPNOTSUPP; in usbtest_ioctl()
2730 param_32->duration_sec = temp.duration_sec; in usbtest_ioctl()
2731 param_32->duration_usec = temp.duration_usec; in usbtest_ioctl()
2735 param_64->duration_sec = temp.duration_sec; in usbtest_ioctl()
2736 param_64->duration_usec = temp.duration_usec; in usbtest_ioctl()
2741 mutex_unlock(&dev->lock); in usbtest_ioctl()
2745 /*-------------------------------------------------------------------------*/
2754 MODULE_PARM_DESC(vendor, "vendor code (from usb-if)");
2775 if (id->match_flags == 0) { in usbtest_probe()
2777 if (!vendor || le16_to_cpu(udev->descriptor.idVendor) != (u16)vendor) in usbtest_probe()
2778 return -ENODEV; in usbtest_probe()
2779 if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) in usbtest_probe()
2780 return -ENODEV; in usbtest_probe()
2781 dev_info(&intf->dev, "matched module params, " in usbtest_probe()
2783 le16_to_cpu(udev->descriptor.idVendor), in usbtest_probe()
2784 le16_to_cpu(udev->descriptor.idProduct)); in usbtest_probe()
2790 return -ENOMEM; in usbtest_probe()
2791 info = (struct usbtest_info *) id->driver_info; in usbtest_probe()
2792 dev->info = info; in usbtest_probe()
2793 mutex_init(&dev->lock); in usbtest_probe()
2795 dev->intf = intf; in usbtest_probe()
2797 /* cacheline-aligned scratch for i/o */ in usbtest_probe()
2798 dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); in usbtest_probe()
2799 if (dev->buf == NULL) { in usbtest_probe()
2801 return -ENOMEM; in usbtest_probe()
2811 if (force_interrupt || udev->speed == USB_SPEED_LOW) { in usbtest_probe()
2812 if (info->ep_in) { in usbtest_probe()
2813 dev->in_pipe = usb_rcvintpipe(udev, info->ep_in); in usbtest_probe()
2814 rtest = " intr-in"; in usbtest_probe()
2816 if (info->ep_out) { in usbtest_probe()
2817 dev->out_pipe = usb_sndintpipe(udev, info->ep_out); in usbtest_probe()
2818 wtest = " intr-out"; in usbtest_probe()
2821 if (override_alt >= 0 || info->autoconf) { in usbtest_probe()
2828 kfree(dev->buf); in usbtest_probe()
2834 if (info->ep_in) in usbtest_probe()
2835 dev->in_pipe = usb_rcvbulkpipe(udev, in usbtest_probe()
2836 info->ep_in); in usbtest_probe()
2837 if (info->ep_out) in usbtest_probe()
2838 dev->out_pipe = usb_sndbulkpipe(udev, in usbtest_probe()
2839 info->ep_out); in usbtest_probe()
2841 if (dev->in_pipe) in usbtest_probe()
2842 rtest = " bulk-in"; in usbtest_probe()
2843 if (dev->out_pipe) in usbtest_probe()
2844 wtest = " bulk-out"; in usbtest_probe()
2845 if (dev->in_iso_pipe) in usbtest_probe()
2846 irtest = " iso-in"; in usbtest_probe()
2847 if (dev->out_iso_pipe) in usbtest_probe()
2848 iwtest = " iso-out"; in usbtest_probe()
2849 if (dev->in_int_pipe) in usbtest_probe()
2850 intrtest = " int-in"; in usbtest_probe()
2851 if (dev->out_int_pipe) in usbtest_probe()
2852 intwtest = " int-out"; in usbtest_probe()
2856 dev_info(&intf->dev, "%s\n", info->name); in usbtest_probe()
2857 dev_info(&intf->dev, "%s {control%s%s%s%s%s%s%s} tests%s\n", in usbtest_probe()
2858 usb_speed_string(udev->speed), in usbtest_probe()
2859 info->ctrl_out ? " in/out" : "", in usbtest_probe()
2863 info->alt >= 0 ? " (+alt)" : ""); in usbtest_probe()
2883 dev_dbg(&intf->dev, "disconnect\n"); in usbtest_disconnect()
2884 kfree(dev->buf); in usbtest_disconnect()
2892 * into EZ-USB chips. There's a default vendor ID which can be overridden
2899 /* an21xx or fx versions of ez-usb */
2901 .name = "EZ-USB device",
2907 /* fx2 version of ez-usb */
2928 * its user-mode cousin. different versions of this use
2944 .alt = -1,
2951 .alt = -1,
2961 .alt = -1,
2969 .alt = -1,
2976 /*-------------------------------------------------------------*/
2978 /* EZ-USB devices which download firmware to replace (or in our
2982 /* generic EZ-USB FX controller */
2987 /* CY3671 development board with EZ-USB FX */
2992 /* generic EZ-USB FX2 controller (or development board) */
2997 /* re-enumerated usb test device firmware */
3007 /* so does a user-mode variant */
3012 /* ... and a user-mode variant that talks iso */
3018 /* Keyspan 19qi uses an21xx (original EZ-USB) */
3025 /*-------------------------------------------------------------*/
3028 /* iBOT2 makes a nice source of high speed bulk-in data */
3035 /*-------------------------------------------------------------*/
3042 /*-------------------------------------------------------------*/
3058 /*-------------------------------------------------------------------------*/