Set correctly last_error when running pn53x_initiator_target_is_present()

This commit is contained in:
Romuald Conty 2014-01-28 10:40:18 +01:00
parent 9a0a10826b
commit b7f590acc8

View file

@ -1730,12 +1730,12 @@ pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt)
{ {
// Check if there is a saved target // Check if there is a saved target
if (CHIP_DATA(pnd)->current_target == NULL) { if (CHIP_DATA(pnd)->current_target == NULL) {
return NFC_ETGRELEASED; return pnd->last_error = NFC_ETGRELEASED;
} }
// Check if the argument target nt is equals to current saved target // Check if the argument target nt is equals to current saved target
if ((pnt != NULL) && (!pn53x_current_target_is(pnd, pnt))) { if ((pnt != NULL) && (!pn53x_current_target_is(pnd, pnt))) {
return NFC_ETGRELEASED; return pnd->last_error = NFC_ETGRELEASED;
} }
// Send Card Presence command // Send Card Presence command
@ -1749,12 +1749,12 @@ pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt)
if ((res = pn53x_transceive(pnd, abtCmd, sizeof(abtCmd), abtRx, sizeof(abtRx), 700)) < 0) if ((res = pn53x_transceive(pnd, abtCmd, sizeof(abtCmd), abtRx, sizeof(abtRx), 700)) < 0)
return res; return res;
if (res == 1) { if (res == 1) {
return NFC_SUCCESS; return pnd->last_error = NFC_SUCCESS;
} }
// Target is not reachable anymore // Target is not reachable anymore
pn53x_current_target_free(pnd); pn53x_current_target_free(pnd);
return NFC_ETGRELEASED; return pnd->last_error = NFC_ETGRELEASED;
} }
#define SAK_ISO14443_4_COMPLIANT 0x20 #define SAK_ISO14443_4_COMPLIANT 0x20