Lines Matching +full:libusb +full:- +full:dev

6  * binary, for any purpose, commercial or non-commercial, and by any
28 #include <libusb.h>
39 * struct test_state - describes test program state
56 * test_init - initialize test program
65 state->found = NULL; in test_init()
66 state->ctx = NULL; in test_init()
67 state->handle = NULL; in test_init()
68 state->attached = 0; in test_init()
70 ret = libusb_init(&state->ctx); in test_init()
72 printf("cannot init libusb: %s\n", libusb_error_name(ret)); in test_init()
76 cnt = libusb_get_device_list(state->ctx, &list); in test_init()
83 libusb_device *dev = list[i]; in test_init() local
85 ret = libusb_get_device_descriptor(dev, &desc); in test_init()
92 state->found = dev; in test_init()
97 if (!state->found) { in test_init()
102 ret = libusb_open(state->found, &state->handle); in test_init()
108 if (libusb_claim_interface(state->handle, 0)) { in test_init()
109 ret = libusb_detach_kernel_driver(state->handle, 0); in test_init()
115 state->attached = 1; in test_init()
116 ret = libusb_claim_interface(state->handle, 0); in test_init()
127 if (state->attached == 1) in test_init()
128 libusb_attach_kernel_driver(state->handle, 0); in test_init()
131 libusb_close(state->handle); in test_init()
137 libusb_exit(state->ctx); in test_init()
142 * test_exit - cleanup test program
147 libusb_release_interface(state->handle, 0); in test_exit()
148 if (state->attached == 1) in test_exit()
149 libusb_attach_kernel_driver(state->handle, 0); in test_exit()
150 libusb_close(state->handle); in test_exit()
151 libusb_exit(state->ctx); in test_exit()
165 iface = &conf->interface[0].altsetting[0]; in main()
166 in_addr = iface->endpoint[0].bEndpointAddress; in main()
167 out_addr = iface->endpoint[1].bEndpointAddress; in main()