Add "usb" keyword support to connstring to specify all usb drivers at once
This commit is contained in:
parent
b4ef1a3a5d
commit
4b5b45f14a
3 changed files with 12 additions and 4 deletions
|
@ -275,7 +275,7 @@ acr122_usb_connstring_decode(const nfc_connstring connstring, struct acr122_usb_
|
||||||
|
|
||||||
int res = sscanf(connstring, "%[^:]:%[^:]:%[^:]", driver_name, dirname, filename);
|
int res = sscanf(connstring, "%[^:]:%[^:]:%[^:]", driver_name, dirname, filename);
|
||||||
|
|
||||||
if (!res || (0 != strcmp(driver_name, ACR122_USB_DRIVER_NAME))) {
|
if (!res || ((0 != strcmp(driver_name, ACR122_USB_DRIVER_NAME)) && (0 != strcmp(driver_name, "usb")))) {
|
||||||
// Driver name does not match.
|
// Driver name does not match.
|
||||||
res = 0;
|
res = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -266,7 +266,7 @@ pn53x_usb_connstring_decode(const nfc_connstring connstring, struct pn53x_usb_de
|
||||||
|
|
||||||
int res = sscanf(connstring, "%[^:]:%[^:]:%[^:]", driver_name, dirname, filename);
|
int res = sscanf(connstring, "%[^:]:%[^:]:%[^:]", driver_name, dirname, filename);
|
||||||
|
|
||||||
if (!res || (0 != strcmp(driver_name, PN53X_USB_DRIVER_NAME))) {
|
if (!res || ((0 != strcmp(driver_name, PN53X_USB_DRIVER_NAME)) && (0 != strcmp(driver_name, "usb")))) {
|
||||||
// Driver name does not match.
|
// Driver name does not match.
|
||||||
res = 0;
|
res = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
12
libnfc/nfc.c
12
libnfc/nfc.c
|
@ -198,13 +198,21 @@ nfc_open(nfc_context *context, const nfc_connstring connstring)
|
||||||
while ((ndr = *pndr)) {
|
while ((ndr = *pndr)) {
|
||||||
// Specific device is requested: using device description
|
// Specific device is requested: using device description
|
||||||
if (0 != strncmp(ndr->name, ncs, strlen(ndr->name))) {
|
if (0 != strncmp(ndr->name, ncs, strlen(ndr->name))) {
|
||||||
pndr++;
|
// Check if connstring driver is usb -> accept any driver *_usb
|
||||||
continue;
|
if ((0 != strncmp("usb", ncs, strlen("usb"))) || 0 != strncmp ("_usb", ndr->name + (strlen(ndr->name) - 4), 4)) {
|
||||||
|
pndr++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pnd = ndr->open(ncs);
|
pnd = ndr->open(ncs);
|
||||||
// Test if the opening was successful
|
// Test if the opening was successful
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
|
if (0 == strncmp("usb", ncs, strlen("usb"))) {
|
||||||
|
// We've to test the other usb drivers before giving up
|
||||||
|
pndr++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
log_put(LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to open \"%s\".", ncs);
|
log_put(LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to open \"%s\".", ncs);
|
||||||
log_fini();
|
log_fini();
|
||||||
return pnd;
|
return pnd;
|
||||||
|
|
Loading…
Add table
Reference in a new issue