static int lusb_probe(backend_probe_target probe_target, struct bladerf_devinfo_list *info_list) { int status, i, n; ssize_t count; libusb_device **list; struct bladerf_devinfo info; libusb_context *context; /* Initialize libusb for device tree walking */ status = libusb_init(&context); if (status) { log_error("Could not initialize libusb: %s\n", libusb_error_name(status)); goto lusb_probe_done; } count = libusb_get_device_list(context, &list); /* Iterate through all the USB devices */ for (i = 0, n = 0; i < count && status == 0; i++) { if (device_is_probe_target(probe_target, list[i])) { /* Open the USB device and get some information */ status = get_devinfo(list[i], &info); if (status) { /* We may not be able to open the device if another * driver (e.g., CyUSB3) is associated with it. Therefore, * just log to the debug level and carry on. */ status = 0; log_debug("Could not open device: %s\n", libusb_error_name(status) ); } else { info.instance = n++; status = bladerf_devinfo_list_add(info_list, &info); if( status ) { log_error("Could not add device to list: %s\n", bladerf_strerror(status) ); } else { log_verbose("Added instance %d to device list\n", info.instance); } } } } libusb_free_device_list(list, 1); libusb_exit(context); lusb_probe_done: return status; }
static int lusb_probe(backend_probe_target probe_target, struct bladerf_devinfo_list *info_list) { int status, i, n; ssize_t count; libusb_device **list; struct bladerf_devinfo info; bool printed_access_warning = false; libusb_context *context; /* Initialize libusb for device tree walking */ status = libusb_init(&context); if (status) { log_error("Could not initialize libusb: %s\n", libusb_error_name(status)); goto lusb_probe_done; } count = libusb_get_device_list(context, &list); /* Iterate through all the USB devices */ for (i = 0, n = 0; i < count && status == 0; i++) { if (device_is_probe_target(probe_target, list[i])) { /* Open the USB device and get some information */ status = get_devinfo(list[i], &info); if (status) { /* We may not be able to open the device if another * driver (e.g., CyUSB3) is associated with it. Therefore, * just log to the debug level and carry on. */ log_debug("Could not open device: %s\n", libusb_error_name(status) ); if (status == LIBUSB_ERROR_ACCESS && !printed_access_warning) { printed_access_warning = true; log_warning("Found a bladeRF via VID/PID, but could not " "open it due to insufficient permissions.\n"); } /* Don't stop probing because one device was "problematic" */ status = 0; } else { info.instance = n++; status = bladerf_devinfo_list_add(info_list, &info); if( status ) { log_error("Could not add device to list: %s\n", bladerf_strerror(status) ); } else { log_verbose("Added instance %d to device list\n", info.instance); } } } } libusb_free_device_list(list, 1); libusb_exit(context); lusb_probe_done: return status; }