From 683505f39b0c4b738e96286edc0a33ae969f9507 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 31 Jan 2013 01:16:37 +0100 Subject: [PATCH] pn53x_idle: call driver-dependent PowerDown & do InRelease first, skip redundant InDeselect --- libnfc/chips/pn53x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index cd7c9d5..92ce658 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -947,30 +947,25 @@ pn53x_idle(struct nfc_device *pnd) if ((res = pn53x_InRelease(pnd, 0)) < 0) { return res; } - if (CHIP_DATA(pnd)->type == PN532) { + if ((CHIP_DATA(pnd)->type == PN532) && (pnd->driver->powerdown)) { // Use PowerDown to go in "Low VBat" power mode - if ((res = pn53x_PowerDown(pnd)) < 0) { + if ((res = pnd->driver->powerdown(pnd)) < 0) { return res; } } break; case INITIATOR: - // Deselect all active communications - if ((res = pn53x_InDeselect(pnd, 0)) < 0) { + // Use InRelease to go in "Standby mode" + if ((res = pn53x_InRelease(pnd, 0)) < 0) { return res; } // Disable RF field to avoid heating if ((res = nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, false)) < 0) { return res; } - if (CHIP_DATA(pnd)->type == PN532) { + if ((CHIP_DATA(pnd)->type == PN532) && (pnd->driver->powerdown)) { // Use PowerDown to go in "Low VBat" power mode - if ((res = pn53x_PowerDown(pnd)) < 0) { - return res; - } - } else { - // Use InRelease to go in "Standby mode" - if ((res = pn53x_InRelease(pnd, 0)) < 0) { + if ((res = pnd->driver->powerdown(pnd)) < 0) { return res; } }