From a77a2a84971f4c588a6377b30975bbe3b15d5ab4 Mon Sep 17 00:00:00 2001 From: jpwidera Date: Thu, 5 Sep 2019 21:59:46 +0200 Subject: [PATCH 1/3] Removed USB alternate setting. Quick and dirty fix for https://github.com/nfc-tools/libnfc/issues/535 --- libnfc/drivers/acr122_usb.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index a6392e8..609a495 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -427,14 +427,6 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) goto free_mem; } - res = usb_set_altinterface(data.pudh, 0); - if (res < 0) { - log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set alternate setting on USB interface (%s)", _usb_strerror(res)); - usb_close(data.pudh); - // we failed to use the specified device - goto free_mem; - } - // Allocate memory for the device info and specification, fill it and return the info pnd = nfc_device_new(context, connstring); if (!pnd) { From 6e035c33f3fd6e14963c884ad6bab680a0848795 Mon Sep 17 00:00:00 2001 From: jpwidera Date: Thu, 5 Sep 2019 22:32:03 +0200 Subject: [PATCH 2/3] Re-enabled claim If there are alternative interfaces, claim interface 0. Otherwise skip this step. --- libnfc/drivers/acr122_usb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index 609a495..8931aab 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -427,6 +427,17 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) goto free_mem; } + // Check if there are more than 0 alternative interfaces and claim the first one + if (dev->config->interface->altsetting->bAlternateSetting > 0) { + res = usb_set_altinterface(data.pudh, 0); + if (res < 0) { + log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set alternate setting on USB interface (%s)", _usb_strerror(res)); + usb_close(data.pudh); + // we failed to use the specified device + goto free_mem; + } + } + // Allocate memory for the device info and specification, fill it and return the info pnd = nfc_device_new(context, connstring); if (!pnd) { From 07f918283b51869e7d5255bfa23f3e26656d8178 Mon Sep 17 00:00:00 2001 From: jpwidera Date: Thu, 5 Sep 2019 22:33:33 +0200 Subject: [PATCH 3/3] Fixed missing whitespaces --- libnfc/drivers/acr122_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index 8931aab..4a88c61 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -428,7 +428,7 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) } // Check if there are more than 0 alternative interfaces and claim the first one - if (dev->config->interface->altsetting->bAlternateSetting > 0) { + if (dev->config->interface->altsetting->bAlternateSetting > 0) { res = usb_set_altinterface(data.pudh, 0); if (res < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set alternate setting on USB interface (%s)", _usb_strerror(res)); @@ -436,7 +436,7 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) // we failed to use the specified device goto free_mem; } - } + } // Allocate memory for the device info and specification, fill it and return the info pnd = nfc_device_new(context, connstring);