Rerun usb_find_busses() and usb_find_devices() without recalling usb_init()

Fixes issue #252
This commit is contained in:
Mike Auty 2013-06-22 20:03:45 +02:00 committed by Philippe Teuwen
parent 03e1f23a40
commit ebe6335fc1

View file

@ -43,21 +43,20 @@
int usb_prepare(void) int usb_prepare(void)
{ {
static bool usb_initialized = false; static bool usb_initialized = false;
if (usb_initialized) { if (!usb_initialized) {
return 0;
}
#ifdef ENVVARS #ifdef ENVVARS
char *env_log_level = getenv("LIBNFC_LOG_LEVEL"); char *env_log_level = getenv("LIBNFC_LOG_LEVEL");
// Set libusb debug only if asked explicitely: // Set libusb debug only if asked explicitely:
// LIBUSB_LOG_LEVEL=12288 (= NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB) // LIBUSB_LOG_LEVEL=12288 (= NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB)
if (env_log_level && (((atoi(env_log_level) >> (NFC_LOG_GROUP_LIBUSB * 2)) & 0x00000003) >= NFC_LOG_PRIORITY_DEBUG)) { if (env_log_level && (((atoi(env_log_level) >> (NFC_LOG_GROUP_LIBUSB * 2)) & 0x00000003) >= NFC_LOG_PRIORITY_DEBUG)) {
setenv("USB_DEBUG", "255", 1); setenv("USB_DEBUG", "255", 1);
} }
#endif #endif
usb_init(); usb_init();
usb_initialized = true; usb_initialized = true;
}
int res; int res;
// usb_find_busses will find all of the busses on the system. Returns the // usb_find_busses will find all of the busses on the system. Returns the