From 8bc7a1c2918ceb1cb9afc87d3649a75f25654cab Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 31 Jan 2013 01:18:23 +0100 Subject: [PATCH] call idle() from driver-dependent close() rather than from nfc_close() as some driver still need to do an ack() before --- ChangeLog | 1 + libnfc/drivers/acr122_pcsc.c | 2 ++ libnfc/drivers/acr122_usb.c | 1 + libnfc/drivers/acr122s.c | 2 ++ libnfc/drivers/arygon.c | 2 ++ libnfc/drivers/pn532_uart.c | 2 ++ libnfc/drivers/pn53x_usb.c | 4 ++-- libnfc/nfc.c | 3 --- 8 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3575187..e7b104b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ Fixes: - Fix nfc-scan-device -i option - Remove wrong exit() calls in library - Fix issue in driver acr122_usb affecting Touchatag + - Reenable some idle in all drivers, add selectively PowerDown when possible Changes: - nfc_emulate_target() now takes timeout parameter diff --git a/libnfc/drivers/acr122_pcsc.c b/libnfc/drivers/acr122_pcsc.c index b87cd2b..105a392 100644 --- a/libnfc/drivers/acr122_pcsc.c +++ b/libnfc/drivers/acr122_pcsc.c @@ -324,6 +324,8 @@ error: static void acr122_pcsc_close(nfc_device *pnd) { + pn53x_idle(pnd); + SCardDisconnect(DRIVER_DATA(pnd)->hCard, SCARD_LEAVE_CARD); acr122_pcsc_free_scardcontext(); diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index 533a3ed..da14a60 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -551,6 +551,7 @@ static void acr122_usb_close(nfc_device *pnd) { acr122_usb_ack(pnd); + pn53x_idle(pnd); int res; if ((res = usb_release_interface(DRIVER_DATA(pnd)->pudh, 0)) < 0) { diff --git a/libnfc/drivers/acr122s.c b/libnfc/drivers/acr122s.c index 2c018d2..932d7c0 100644 --- a/libnfc/drivers/acr122s.c +++ b/libnfc/drivers/acr122s.c @@ -520,6 +520,8 @@ static void acr122s_close(nfc_device *pnd) { acr122s_deactivate_sam(pnd); + pn53x_idle(pnd); + uart_close(DRIVER_DATA(pnd)->port); #ifndef WIN32 diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index 315f36e..e713d4e 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -211,6 +211,8 @@ arygon_connstring_decode(const nfc_connstring connstring, struct arygon_descript static void arygon_close(nfc_device *pnd) { + pn53x_idle(pnd); + // Release UART port uart_close(DRIVER_DATA(pnd)->port); diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index 10d71bd..c3bcd9d 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -188,6 +188,8 @@ pn532_connstring_decode(const nfc_connstring connstring, struct pn532_uart_descr static void pn532_uart_close(nfc_device *pnd) { + pn53x_idle(pnd); + // Release UART port uart_close(DRIVER_DATA(pnd)->port); diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index f0580ff..6340cb7 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -447,14 +447,14 @@ pn53x_usb_close(nfc_device *pnd) { pn53x_usb_ack(pnd); - pn53x_idle(pnd); - if (DRIVER_DATA(pnd)->model == ASK_LOGO) { /* Set P30, P31, P32, P33, P35 to logic 1 and P34 to 0 logic */ /* ie. Switch all LEDs off and turn off progressive field */ pn53x_write_register(pnd, PN53X_SFR_P3, 0xFF, _BV(P30) | _BV(P31) | _BV(P32) | _BV(P33) | _BV(P35)); } + pn53x_idle(pnd); + int res; if ((res = usb_release_interface(DRIVER_DATA(pnd)->pudh, 0)) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to release USB interface (%s)", _usb_strerror(res)); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 272f8e0..b1dc537 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -209,11 +209,8 @@ void nfc_close(nfc_device *pnd) { if (pnd) { - // Go in idle mode - nfc_idle(pnd); // Close, clean up and release the device pnd->driver->close(pnd); - } }