Lines Matching refs:state
59 int test_init(struct test_state *state) in test_init() argument
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()
76 cnt = libusb_get_device_list(state->ctx, &list); 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()
145 void test_exit(struct test_state *state) in test_exit() argument
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()
156 struct test_state state; in main() local
161 if (test_init(&state)) in main()
164 libusb_get_config_descriptor(state.found, 0, &conf); in main()
171 libusb_bulk_transfer(state.handle, addr, buffer, BUF_LEN, in main()
174 test_exit(&state); in main()