Merge pull request #561 from jpwidera/master

Added check for USB alternate settings
This commit is contained in:
Adam Laurie 2020-04-05 14:37:22 +01:00 committed by GitHub
commit 692038ceaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -427,12 +427,15 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring)
goto free_mem; goto free_mem;
} }
res = usb_set_altinterface(data.pudh, 0); // Check if there are more than 0 alternative interfaces and claim the first one
if (res < 0) { if (dev->config->interface->altsetting->bAlternateSetting > 0) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set alternate setting on USB interface (%s)", _usb_strerror(res)); res = usb_set_altinterface(data.pudh, 0);
usb_close(data.pudh); if (res < 0) {
// we failed to use the specified device log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set alternate setting on USB interface (%s)", _usb_strerror(res));
goto free_mem; 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 // Allocate memory for the device info and specification, fill it and return the info