Lines Matching refs:dev

198 		libusb_device *dev = dev_list[i];  in find_busses()  local
199 uint8_t bus_num = libusb_get_bus_number(dev); in find_busses()
312 struct usb_device *dev; in find_devices() local
322 dev = malloc(sizeof(*dev)); in find_devices()
323 if (!dev) in find_devices()
328 dev->dev = newlib_dev; in find_devices()
330 dev->bus = bus; in find_devices()
331 dev->devnum = libusb_get_device_address(newlib_dev); in find_devices()
332 sprintf(dev->filename, "%03d", dev->devnum); in find_devices()
333 LIST_ADD(devices, dev); in find_devices()
340 dev = devices; in find_devices()
341 while (dev) { in find_devices()
342 struct usb_device *tdev = dev->next; in find_devices()
343 free(dev); in find_devices()
344 dev = tdev; in find_devices()
389 static void clear_device(struct usb_device *dev) in clear_device() argument
392 for (i = 0; i < dev->descriptor.bNumConfigurations; i++) in clear_device()
393 clear_config_descriptor(dev->config + i); in clear_device()
506 static int initialize_device(struct usb_device *dev) in initialize_device() argument
508 libusb_device *newlib_dev = dev->dev; in initialize_device()
516 (struct libusb_device_descriptor *) &dev->descriptor); in initialize_device()
522 num_configurations = dev->descriptor.bNumConfigurations; in initialize_device()
524 dev->config = malloc(alloc_size); in initialize_device()
525 if (!dev->config) in initialize_device()
527 memset(dev->config, 0, alloc_size); in initialize_device()
537 clear_device(dev); in initialize_device()
538 free(dev->config); in initialize_device()
541 r = copy_config_descriptor(dev->config + i, newlib_config); in initialize_device()
544 clear_device(dev); in initialize_device()
545 free(dev->config); in initialize_device()
552 dev->num_children = 0; in initialize_device()
553 dev->children = NULL; in initialize_device()
559 static void free_device(struct usb_device *dev) in free_device() argument
561 clear_device(dev); in free_device()
562 libusb_unref_device(dev->dev); in free_device()
563 free(dev); in free_device()
586 struct usb_device *dev; in usb_find_devices() local
597 dev = bus->devices; in usb_find_devices()
598 while (dev) { in usb_find_devices()
600 struct usb_device *tdev = dev->next; in usb_find_devices()
604 if (ndev->devnum == dev->devnum) { in usb_find_devices()
615 dev->bus->location, dev->devnum); in usb_find_devices()
616 LIST_DEL(bus->devices, dev); in usb_find_devices()
617 free_device(dev); in usb_find_devices()
621 dev = tdev; in usb_find_devices()
625 dev = new_devices; in usb_find_devices()
626 while (dev) { in usb_find_devices()
627 struct usb_device *tdev = dev->next; in usb_find_devices()
628 r = initialize_device(dev); in usb_find_devices()
631 dev->bus->location, dev->devnum, r); in usb_find_devices()
632 dev = tdev; in usb_find_devices()
635 usbi_dbg("device %d.%d added", dev->bus->location, dev->devnum); in usb_find_devices()
636 LIST_DEL(new_devices, dev); in usb_find_devices()
637 LIST_ADD(bus->devices, dev); in usb_find_devices()
639 dev = tdev; in usb_find_devices()
652 API_EXPORTED usb_dev_handle *usb_open(struct usb_device *dev) in usb_open() argument
661 r = libusb_open((libusb_device *) dev->dev, &udev->handle); in usb_open()
670 udev->device = dev; in usb_open()
674 API_EXPORTED int usb_close(usb_dev_handle *dev) in usb_close() argument
677 libusb_close(dev->handle); in usb_close()
678 free(dev); in usb_close()
682 API_EXPORTED struct usb_device *usb_device(usb_dev_handle *dev) in usb_device() argument
684 return dev->device; in usb_device()
687 API_EXPORTED int usb_set_configuration(usb_dev_handle *dev, int configuration) in usb_set_configuration() argument
690 return compat_err(libusb_set_configuration(dev->handle, configuration)); in usb_set_configuration()
693 API_EXPORTED int usb_claim_interface(usb_dev_handle *dev, int interface) in usb_claim_interface() argument
698 r = libusb_claim_interface(dev->handle, interface); in usb_claim_interface()
700 dev->last_claimed_interface = interface; in usb_claim_interface()
707 API_EXPORTED int usb_release_interface(usb_dev_handle *dev, int interface) in usb_release_interface() argument
712 r = libusb_release_interface(dev->handle, interface); in usb_release_interface()
714 dev->last_claimed_interface = -1; in usb_release_interface()
719 API_EXPORTED int usb_set_altinterface(usb_dev_handle *dev, int alternate) in usb_set_altinterface() argument
722 if (dev->last_claimed_interface < 0) in usb_set_altinterface()
725 return compat_err(libusb_set_interface_alt_setting(dev->handle, in usb_set_altinterface()
726 dev->last_claimed_interface, alternate)); in usb_set_altinterface()
729 API_EXPORTED int usb_resetep(usb_dev_handle *dev, unsigned int ep) in usb_resetep() argument
731 return compat_err(usb_clear_halt(dev, ep)); in usb_resetep()
734 API_EXPORTED int usb_clear_halt(usb_dev_handle *dev, unsigned int ep) in usb_clear_halt() argument
737 return compat_err(libusb_clear_halt(dev->handle, ep & 0xff)); in usb_clear_halt()
740 API_EXPORTED int usb_reset(usb_dev_handle *dev) in usb_reset() argument
743 return compat_err(libusb_reset_device(dev->handle)); in usb_reset()
746 static int usb_bulk_io(usb_dev_handle *dev, int ep, char *bytes, in usb_bulk_io() argument
752 r = libusb_bulk_transfer(dev->handle, ep & 0xff, bytes, size, in usb_bulk_io()
763 API_EXPORTED int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, in usb_bulk_read() argument
774 return usb_bulk_io(dev, ep, bytes, size, timeout); in usb_bulk_read()
777 API_EXPORTED int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, in usb_bulk_write() argument
788 return usb_bulk_io(dev, ep, bytes, size, timeout); in usb_bulk_write()
791 static int usb_interrupt_io(usb_dev_handle *dev, int ep, char *bytes, in usb_interrupt_io() argument
797 r = libusb_interrupt_transfer(dev->handle, ep & 0xff, bytes, size, in usb_interrupt_io()
808 API_EXPORTED int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, in usb_interrupt_read() argument
818 return usb_interrupt_io(dev, ep, bytes, size, timeout); in usb_interrupt_read()
821 API_EXPORTED int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, in usb_interrupt_write() argument
832 return usb_interrupt_io(dev, ep, bytes, size, timeout); in usb_interrupt_write()
835 API_EXPORTED int usb_control_msg(usb_dev_handle *dev, int bmRequestType, in usb_control_msg() argument
842 r = libusb_control_transfer(dev->handle, bmRequestType & 0xff, in usb_control_msg()
852 API_EXPORTED int usb_get_string(usb_dev_handle *dev, int desc_index, int langid, in usb_get_string() argument
856 r = libusb_get_string_descriptor(dev->handle, desc_index & 0xff, in usb_get_string()
863 API_EXPORTED int usb_get_string_simple(usb_dev_handle *dev, int desc_index, in usb_get_string_simple() argument
867 r = libusb_get_string_descriptor_ascii(dev->handle, desc_index & 0xff, in usb_get_string_simple()
874 API_EXPORTED int usb_get_descriptor(usb_dev_handle *dev, unsigned char type, in usb_get_descriptor() argument
878 r = libusb_get_descriptor(dev->handle, type, desc_index, buf, size); in usb_get_descriptor()
884 API_EXPORTED int usb_get_descriptor_by_endpoint(usb_dev_handle *dev, int ep, in usb_get_descriptor_by_endpoint() argument
891 r = libusb_control_transfer(dev->handle, in usb_get_descriptor_by_endpoint()
899 API_EXPORTED int usb_get_driver_np(usb_dev_handle *dev, int interface, in usb_get_driver_np() argument
902 int r = libusb_kernel_driver_active(dev->handle, interface); in usb_get_driver_np()
914 API_EXPORTED int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface) in usb_detach_kernel_driver_np() argument
916 return compat_err(libusb_detach_kernel_driver(dev->handle, interface)); in usb_detach_kernel_driver_np()