Lines Matching +full:no +full:- +full:can +full:- +full:fd

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* $(CROSS_COMPILE)cc -Wall -Wextra -g -lpthread -o testusb testusb.c */
12 * kernel driver. It can generate a variety of transfer patterns; you
16 * For more information on how this can be used and on USB testing
17 * refer to <URL:http://www.linux-usb.org/usbtest/>.
36 /*-------------------------------------------------------------------------*/
44 unsigned test_num; /* 0..(TEST_CASES-1) */
55 /*-------------------------------------------------------------------------*/
105 /*-------------------------------------------------------------------------*/
116 case USB_SPEED_SUPER_PLUS: return "super-plus"; in speed()
134 static int testdev_ffs_ifnum(FILE *fd) in testdev_ffs_ifnum() argument
142 if (fread(u.buf, 1, 1, fd) != 1) in testdev_ffs_ifnum()
143 return -1; in testdev_ffs_ifnum()
144 if (fread(u.buf + 1, (unsigned char)u.buf[0] - 1, 1, fd) != 1) in testdev_ffs_ifnum()
145 return -1; in testdev_ffs_ifnum()
157 static int testdev_ifnum(FILE *fd) in testdev_ifnum() argument
161 if (fread(&dev, sizeof dev, 1, fd) != 1) in testdev_ifnum()
162 return -1; in testdev_ifnum()
165 return -1; in testdev_ifnum()
171 /*----------------------------------------------------*/ in testdev_ifnum()
173 /* devices that start up using the EZ-USB default device and in testdev_ifnum()
174 * which we can use after loading simple firmware. hotplug in testdev_ifnum()
175 * can fxload it, and then run this test driver. in testdev_ifnum()
178 * - the device has a "real" driver (maybe usb-serial) that in testdev_ifnum()
180 * - the device doesn't have the test firmware installed. in testdev_ifnum()
183 /* generic EZ-USB FX controller */ in testdev_ifnum()
187 /* generic EZ-USB FX2 controller */ in testdev_ifnum()
191 /* CY3671 development board with EZ-USB FX */ in testdev_ifnum()
195 /* Keyspan 19Qi uses an21xx (original EZ-USB) */ in testdev_ifnum()
199 /*----------------------------------------------------*/ in testdev_ifnum()
201 /* "gadget zero", Linux-USB test software */ in testdev_ifnum()
207 return testdev_ffs_ifnum(fd); in testdev_ifnum()
219 /*----------------------------------------------------*/ in testdev_ifnum()
225 /*----------------------------------------------------*/ in testdev_ifnum()
227 /* the FunctionFS gadget can have the source/sink interface in testdev_ifnum()
234 return testdev_ffs_ifnum(fd); in testdev_ifnum()
236 return -1; in testdev_ifnum()
241 FILE *fd; in find_testdev() local
250 fd = fopen(name, "rb"); in find_testdev()
251 if (!fd) { in find_testdev()
256 ifnum = testdev_ifnum(fd); in find_testdev()
257 fclose(fd); in find_testdev()
265 entry->name = strdup(name); in find_testdev()
266 if (!entry->name) { in find_testdev()
273 entry->ifnum = ifnum; in find_testdev()
274 entry->next = testdevs; in find_testdev()
280 usbdev_ioctl (int fd, int ifno, unsigned request, void *param) in usbdev_ioctl() argument
288 return ioctl (fd, USBDEVFS_IOCTL, &wrapper); in usbdev_ioctl()
294 int fd, i; in handle_testdev() local
297 if ((fd = open (dev->name, O_RDWR)) < 0) { in handle_testdev()
298 perror ("can't open dev file r/w"); in handle_testdev()
302 status = ioctl(fd, USBDEVFS_GET_SPEED, NULL); in handle_testdev()
306 dev->speed = status; in handle_testdev()
308 speed(dev->speed), dev->name, dev->ifnum); in handle_testdev()
312 if (dev->test != -1 && dev->test != i) in handle_testdev()
314 dev->param.test_num = i; in handle_testdev()
316 status = usbdev_ioctl (fd, dev->ifnum, in handle_testdev()
317 USBTEST_REQUEST, &dev->param); in handle_testdev()
323 /* NOTE: each thread emits complete lines; no fragments! */ in handle_testdev()
332 printf ("%s test %d --> %d (%s)\n", in handle_testdev()
333 dev->name, i, errno, buf); in handle_testdev()
335 printf ("%s test %d, %4d.%.06d secs\n", dev->name, i, in handle_testdev()
336 (int) dev->param.duration.tv_sec, in handle_testdev()
337 (int) dev->param.duration.tv_usec); in handle_testdev()
341 if (dev->forever) in handle_testdev()
344 close (fd); in handle_testdev()
366 return -1; in parse_num()
379 int test = -1 /* all */; in main()
384 * Best per-frame data rates: in main()
424 case 'n': /* no test running! */ in main()
447 "\t-D dev only test specific device\n" in main()
448 "\t-A usb-dir\n" in main()
449 "\t-a test all recognized devices\n" in main()
450 "\t-l loop forever(for stress test)\n" in main()
451 "\t-t testnum only run specified case\n" in main()
452 "\t-n no test running, show devices to be tested\n" in main()
454 "\t-c iterations default 1000\n" in main()
455 "\t-s transfer length default 1024\n" in main()
456 "\t-g sglen default 32\n" in main()
457 "\t-v vary default 1024\n", in main()
464 fprintf (stderr, "must specify '-a' or '-D dev', " in main()
474 return -1; in main()
481 return -1; in main()
486 fputs ("no test devices recognized\n", stderr); in main()
487 return -1; in main()
491 if (testdevs && !testdevs->next && !device) in main()
492 device = testdevs->name; in main()
493 for (entry = testdevs; entry; entry = entry->next) { in main()
496 entry->param = param; in main()
497 entry->forever = forever; in main()
498 entry->test = test; in main()
501 if (strcmp (entry->name, device)) in main()
505 status = pthread_create (&entry->thread, 0, handle_testdev, entry); in main()
512 /* kernel can recognize test devices we don't */ in main()
525 for (entry = testdevs; entry; entry = entry->next) { in main()
528 if (pthread_join (entry->thread, &retval)) in main()