pn53x_idle() returns now 0 on success and libnfc error code on failure.

This commit is contained in:
Audrey Diacre 2012-01-04 16:26:57 +00:00
parent 7e1c776bc1
commit 4b373263e4
3 changed files with 17 additions and 16 deletions

View file

@ -822,43 +822,44 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
return NFC_EINVARG; return NFC_EINVARG;
} }
bool int
pn53x_idle (struct nfc_device *pnd) pn53x_idle (struct nfc_device *pnd)
{ {
int res = 0;
switch (CHIP_DATA (pnd)->operating_mode) { switch (CHIP_DATA (pnd)->operating_mode) {
case TARGET: case TARGET:
// InRelease used in target mode stops the target emulation and no more // InRelease used in target mode stops the target emulation and no more
// tag are seen from external initiator // tag are seen from external initiator
if (pn53x_InRelease (pnd, 0) < 0) { if ((res = pn53x_InRelease (pnd, 0)) < 0) {
return false; return res;
} }
if (CHIP_DATA (pnd)->type == PN532) { if (CHIP_DATA (pnd)->type == PN532) {
// Use PowerDown to go in "Low VBat" power mode // Use PowerDown to go in "Low VBat" power mode
if (pn53x_PowerDown (pnd) < 0) { if ((res = pn53x_PowerDown (pnd)) < 0) {
return false; return res;
} }
CHIP_DATA (pnd)->power_mode = LOWVBAT; CHIP_DATA (pnd)->power_mode = LOWVBAT;
} }
break; break;
case INITIATOR: case INITIATOR:
// Deselect all active communications // Deselect all active communications
if (pn53x_InDeselect (pnd, 0) < 0) { if ((res = pn53x_InDeselect (pnd, 0)) < 0) {
return false; return res;
} }
// Disable RF field to avoid heating // Disable RF field to avoid heating
if (nfc_device_set_property_bool (pnd, NP_ACTIVATE_FIELD, false) < 0) { if ((res = nfc_device_set_property_bool (pnd, NP_ACTIVATE_FIELD, false)) < 0) {
return false; return res;
} }
if (CHIP_DATA (pnd)->type == PN532) { if (CHIP_DATA (pnd)->type == PN532) {
// Use PowerDown to go in "Low VBat" power mode // Use PowerDown to go in "Low VBat" power mode
if (pn53x_PowerDown (pnd) < 0) { if ((res = pn53x_PowerDown (pnd)) < 0) {
return false; return res;
} }
CHIP_DATA (pnd)->power_mode = LOWVBAT; CHIP_DATA (pnd)->power_mode = LOWVBAT;
} else { } else {
// Use InRelease to go in "Standby mode" // Use InRelease to go in "Standby mode"
if (pn53x_InRelease (pnd, 0) < 0) { if ((res = pn53x_InRelease (pnd, 0)) < 0) {
return false; return res;
} }
} }
break; break;
@ -867,7 +868,7 @@ pn53x_idle (struct nfc_device *pnd)
break; break;
}; };
CHIP_DATA (pnd)->operating_mode = IDLE; CHIP_DATA (pnd)->operating_mode = IDLE;
return true; return NFC_SUCCESS;
} }
int int

View file

@ -280,7 +280,7 @@ int pn53x_set_property_int (struct nfc_device *pnd, const nfc_property proper
int pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, const bool bEnable); int pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, const bool bEnable);
int pn53x_check_communication (struct nfc_device *pnd); int pn53x_check_communication (struct nfc_device *pnd);
bool pn53x_idle (struct nfc_device *pnd); int pn53x_idle (struct nfc_device *pnd);
// NFC device as Initiator functions // NFC device as Initiator functions
int pn53x_initiator_init (struct nfc_device *pnd); int pn53x_initiator_init (struct nfc_device *pnd);

View file

@ -152,7 +152,7 @@ struct nfc_driver_t {
int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value); int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value);
bool (*abort_command) (struct nfc_device *pnd); bool (*abort_command) (struct nfc_device *pnd);
bool (*idle) (struct nfc_device *pnd); int (*idle) (struct nfc_device *pnd);
}; };
# define DEVICE_NAME_LENGTH 256 # define DEVICE_NAME_LENGTH 256