From 17c63aebb5942f18de96f7e88796e0e214ba542b Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 25 May 2011 12:08:42 +0000 Subject: [PATCH] pn53x_usb: continue to search a available device on usb errors (r1092 reverted then issue fixed). --- libnfc/drivers/pn53x_usb.c | 13 +++++++++++-- libnfc/nfc.c | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index 1f3a4e6..8484a49 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -202,6 +202,15 @@ pn53x_usb_probe (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * psz } usb_dev_handle *udev = usb_open (dev); + + // Set configuration + int res = usb_set_configuration (udev, 1); + if (res < 0) { + usb_close (udev); + // we failed to use the device + continue; + } + pn53x_usb_get_usb_device_name (dev, udev, pnddDevices[*pszDeviceFound].acDevice, sizeof (pnddDevices[*pszDeviceFound].acDevice)); usb_close (udev); pnddDevices[*pszDeviceFound].pcDriver = PN53X_USB_DRIVER_NAME; @@ -280,7 +289,7 @@ pn53x_usb_connect (const nfc_device_desc_t *pndd) } usb_close (data.pudh); // we failed to use the specified device - continue; + return NULL; } res = usb_claim_interface (data.pudh, 0); @@ -288,7 +297,7 @@ pn53x_usb_connect (const nfc_device_desc_t *pndd) DBG ("Can't claim interface (%s)", strerror (-res)); usb_close (data.pudh); // we failed to use the specified device - continue; + return NULL; } data.model = pn53x_usb_get_device_model (dev->descriptor.idVendor, dev->descriptor.idProduct); // Allocate memory for the device info and specification, fill it and return the info diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 3fa5861..a534de0 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -154,6 +154,7 @@ nfc_pick_device (void) DBG ("No %s device found", ndr->name); free (pndd); } else { + DBG ("One %s device found", ndr->name); return pndd; } }