Lines Matching refs:state
64 int test_init(struct test_state *state) in test_init() argument
70 state->found = NULL; in test_init()
71 state->ctx = NULL; in test_init()
72 state->handle = NULL; in test_init()
73 state->attached = 0; in test_init()
75 ret = libusb_init(&state->ctx); in test_init()
81 cnt = libusb_get_device_list(state->ctx, &list); in test_init()
97 state->found = dev; in test_init()
102 if (!state->found) { in test_init()
107 ret = libusb_open(state->found, &state->handle); in test_init()
113 if (libusb_claim_interface(state->handle, 0)) { in test_init()
114 ret = libusb_detach_kernel_driver(state->handle, 0); in test_init()
120 state->attached = 1; in test_init()
121 ret = libusb_claim_interface(state->handle, 0); in test_init()
132 if (state->attached == 1) in test_init()
133 libusb_attach_kernel_driver(state->handle, 0); in test_init()
136 libusb_close(state->handle); in test_init()
142 libusb_exit(state->ctx); in test_init()
150 void test_exit(struct test_state *state) in test_exit() argument
152 libusb_release_interface(state->handle, 0); in test_exit()
153 if (state->attached == 1) in test_exit()
154 libusb_attach_kernel_driver(state->handle, 0); in test_exit()
155 libusb_close(state->handle); in test_exit()
156 libusb_exit(state->ctx); in test_exit()
161 struct test_state state; in main() local
163 if (test_init(&state)) in main()
169 libusb_bulk_transfer(state.handle, EP_BULK_IN, buffer, BUF_LEN, in main()
171 libusb_bulk_transfer(state.handle, EP_BULK_OUT, buffer, BUF_LEN, in main()
174 test_exit(&state); in main()