From ebe6335fc1f7362400d0fcbf7a0b0e97941939eb Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sat, 22 Jun 2013 20:03:45 +0200 Subject: [PATCH] Rerun usb_find_busses() and usb_find_devices() without recalling usb_init() Fixes issue #252 --- libnfc/buses/usbbus.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/libnfc/buses/usbbus.c b/libnfc/buses/usbbus.c index 184b7c0..4584421 100644 --- a/libnfc/buses/usbbus.c +++ b/libnfc/buses/usbbus.c @@ -43,21 +43,20 @@ int usb_prepare(void) { static bool usb_initialized = false; - if (usb_initialized) { - return 0; - } + if (!usb_initialized) { #ifdef ENVVARS - char *env_log_level = getenv("LIBNFC_LOG_LEVEL"); - // Set libusb debug only if asked explicitely: - // 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)) { - setenv("USB_DEBUG", "255", 1); - } + char *env_log_level = getenv("LIBNFC_LOG_LEVEL"); + // Set libusb debug only if asked explicitely: + // 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)) { + setenv("USB_DEBUG", "255", 1); + } #endif - usb_init(); - usb_initialized = true; + usb_init(); + usb_initialized = true; + } int res; // usb_find_busses will find all of the busses on the system. Returns the