Lines Matching refs:handle
67 static int try_interfaces(IOUSBDeviceInterface182 **dev, usb_handle *handle) { in try_interfaces() argument
171 if ((*interface)->GetInterfaceClass(interface, &handle->info.ifc_class) != 0 || in try_interfaces()
172 (*interface)->GetInterfaceSubClass(interface, &handle->info.ifc_subclass) != 0 || in try_interfaces()
173 (*interface)->GetInterfaceProtocol(interface, &handle->info.ifc_protocol) != 0) in try_interfaces()
179 handle->info.has_bulk_in = 0; in try_interfaces()
180 handle->info.has_bulk_out = 0; in try_interfaces()
201 handle->info.has_bulk_in = 1; in try_interfaces()
202 handle->bulkIn = endpoint; in try_interfaces()
204 handle->info.has_bulk_out = 1; in try_interfaces()
205 handle->bulkOut = endpoint; in try_interfaces()
208 if (handle->info.ifc_protocol == 0x01) { in try_interfaces()
209 handle->zero_mask = maxPacketSize - 1; in try_interfaces()
215 if (handle->info.has_bulk_in && handle->info.has_bulk_out) { in try_interfaces()
220 if (handle->callback(&handle->info) == 0) { in try_interfaces()
221 handle->interface = interface; in try_interfaces()
222 handle->success = 1; in try_interfaces()
230 if (handle->info.has_bulk_in) { in try_interfaces()
232 handle->bulkIn); in try_interfaces()
238 if (handle->info.has_bulk_out) { in try_interfaces()
240 handle->bulkOut); in try_interfaces()
260 static int try_device(io_service_t device, usb_handle *handle) { in try_device() argument
296 kr = (*dev)->GetDeviceVendor(dev, &handle->info.dev_vendor); in try_device()
302 kr = (*dev)->GetDeviceProduct(dev, &handle->info.dev_product); in try_device()
308 kr = (*dev)->GetDeviceClass(dev, &handle->info.dev_class); in try_device()
314 kr = (*dev)->GetDeviceSubClass(dev, &handle->info.dev_subclass); in try_device()
320 kr = (*dev)->GetDeviceProtocol(dev, &handle->info.dev_protocol); in try_device()
331 snprintf(handle->info.device_path, sizeof(handle->info.device_path), "usb:%lX", locationId); in try_device()
354 handle->info.serial_number[i] = buffer[i + 1]; in try_device()
355 handle->info.serial_number[i] = 0; in try_device()
359 handle->info.serial_number[0] = 0; in try_device()
361 handle->info.writable = 1; in try_device()
363 if (try_interfaces(dev, handle)) { in try_device()
381 static int init_usb(ifc_match_func callback, usb_handle **handle) { in init_usb() argument
434 *handle = calloc(1, sizeof(usb_handle)); in init_usb()
435 memcpy(*handle, &h, sizeof(usb_handle)); in init_usb()
455 usb_handle *handle = NULL; in usb_open() local
457 if (init_usb(callback, &handle) < 0) { in usb_open()
462 return handle; in usb_open()