mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-12 18:43:47 +00:00
pn53x_idle: call driver-dependent PowerDown & do InRelease first, skip redundant InDeselect
This commit is contained in:
@@ -947,30 +947,25 @@ pn53x_idle(struct nfc_device *pnd)
|
|||||||
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
|
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
|
||||||
return res;
|
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
|
// Use PowerDown to go in "Low VBat" power mode
|
||||||
if ((res = pn53x_PowerDown(pnd)) < 0) {
|
if ((res = pnd->driver->powerdown(pnd)) < 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INITIATOR:
|
case INITIATOR:
|
||||||
// Deselect all active communications
|
// Use InRelease to go in "Standby mode"
|
||||||
if ((res = pn53x_InDeselect(pnd, 0)) < 0) {
|
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// Disable RF field to avoid heating
|
// Disable RF field to avoid heating
|
||||||
if ((res = 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 res;
|
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
|
// Use PowerDown to go in "Low VBat" power mode
|
||||||
if ((res = pn53x_PowerDown(pnd)) < 0) {
|
if ((res = pnd->driver->powerdown(pnd)) < 0) {
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Use InRelease to go in "Standby mode"
|
|
||||||
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user