From 4b373263e4641507fc4fdd22202466958149b49a Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Wed, 4 Jan 2012 16:26:57 +0000 Subject: [PATCH] pn53x_idle() returns now 0 on success and libnfc error code on failure. --- libnfc/chips/pn53x.c | 29 +++++++++++++++-------------- libnfc/chips/pn53x.h | 2 +- libnfc/nfc-internal.h | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index cc19323..eaccbeb 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -822,43 +822,44 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co return NFC_EINVARG; } -bool +int pn53x_idle (struct nfc_device *pnd) { + int res = 0; switch (CHIP_DATA (pnd)->operating_mode) { case TARGET: // InRelease used in target mode stops the target emulation and no more // tag are seen from external initiator - if (pn53x_InRelease (pnd, 0) < 0) { - return false; + if ((res = pn53x_InRelease (pnd, 0)) < 0) { + return res; } if (CHIP_DATA (pnd)->type == PN532) { // Use PowerDown to go in "Low VBat" power mode - if (pn53x_PowerDown (pnd) < 0) { - return false; + if ((res = pn53x_PowerDown (pnd)) < 0) { + return res; } CHIP_DATA (pnd)->power_mode = LOWVBAT; } break; case INITIATOR: // Deselect all active communications - if (pn53x_InDeselect (pnd, 0) < 0) { - return false; + if ((res = pn53x_InDeselect (pnd, 0)) < 0) { + return res; } // Disable RF field to avoid heating - if (nfc_device_set_property_bool (pnd, NP_ACTIVATE_FIELD, false) < 0) { - return false; + if ((res = nfc_device_set_property_bool (pnd, NP_ACTIVATE_FIELD, false)) < 0) { + return res; } if (CHIP_DATA (pnd)->type == PN532) { // Use PowerDown to go in "Low VBat" power mode - if (pn53x_PowerDown (pnd) < 0) { - return false; + if ((res = pn53x_PowerDown (pnd)) < 0) { + return res; } CHIP_DATA (pnd)->power_mode = LOWVBAT; } else { // Use InRelease to go in "Standby mode" - if (pn53x_InRelease (pnd, 0) < 0) { - return false; + if ((res = pn53x_InRelease (pnd, 0)) < 0) { + return res; } } break; @@ -867,7 +868,7 @@ pn53x_idle (struct nfc_device *pnd) break; }; CHIP_DATA (pnd)->operating_mode = IDLE; - return true; + return NFC_SUCCESS; } int diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index ceafa75..f8bac33 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -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_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 int pn53x_initiator_init (struct nfc_device *pnd); diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 2092144..f816ea6 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -152,7 +152,7 @@ struct nfc_driver_t { int (*device_set_property_int) (struct nfc_device *pnd, const nfc_property property, const int value); bool (*abort_command) (struct nfc_device *pnd); - bool (*idle) (struct nfc_device *pnd); + int (*idle) (struct nfc_device *pnd); }; # define DEVICE_NAME_LENGTH 256