chips/pn53x: drivers now uses pn53x_data_new() and pn53x_data_free() to handle strcut pn53x_data allocation, initialization and freeing.
This commit is contained in:
parent
c45d4e685a
commit
22e25a8b1e
8 changed files with 22 additions and 8 deletions
|
@ -10,7 +10,6 @@ pkgconfig_DATA = libnfc.pc
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
CMakeLists.txt \
|
CMakeLists.txt \
|
||||||
Doxyfile \
|
Doxyfile \
|
||||||
LICENSE \
|
|
||||||
README-Windows.txt \
|
README-Windows.txt \
|
||||||
pn53x.conf \
|
pn53x.conf \
|
||||||
pn53x.rules
|
pn53x.rules
|
||||||
|
|
|
@ -2467,3 +2467,12 @@ pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io)
|
||||||
CHIP_DATA (pnd)->wb_trigged = false;
|
CHIP_DATA (pnd)->wb_trigged = false;
|
||||||
memset (CHIP_DATA (pnd)->wb_mask, 0x00, PN53X_CACHE_REGISTER_SIZE);
|
memset (CHIP_DATA (pnd)->wb_mask, 0x00, PN53X_CACHE_REGISTER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pn53x_data_free (nfc_device_t * pnd)
|
||||||
|
{
|
||||||
|
if (CHIP_DATA (pnd)->current_target) {
|
||||||
|
free (CHIP_DATA (pnd)->current_target);
|
||||||
|
}
|
||||||
|
free (pnd->chip_data);
|
||||||
|
}
|
||||||
|
|
|
@ -337,5 +337,6 @@ bool pn53x_check_error_frame (nfc_device_t * pnd, const byte_t * pbtRxFrame,
|
||||||
bool pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData);
|
bool pn53x_build_frame (byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData);
|
||||||
|
|
||||||
void pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io);
|
void pn53x_data_new (nfc_device_t * pnd, const struct pn53x_io* io);
|
||||||
|
void pn53x_data_free (nfc_device_t * pnd);
|
||||||
|
|
||||||
#endif // __NFC_CHIPS_PN53X_H__
|
#endif // __NFC_CHIPS_PN53X_H__
|
||||||
|
|
|
@ -245,6 +245,7 @@ acr122_disconnect (nfc_device_t * pnd)
|
||||||
SCardDisconnect (DRIVER_DATA (pnd)->hCard, SCARD_LEAVE_CARD);
|
SCardDisconnect (DRIVER_DATA (pnd)->hCard, SCARD_LEAVE_CARD);
|
||||||
acr122_free_scardcontext ();
|
acr122_free_scardcontext ();
|
||||||
|
|
||||||
|
pn53x_data_free (pnd);
|
||||||
nfc_device_free (pnd);
|
nfc_device_free (pnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,11 +175,13 @@ arygon_connect (const nfc_device_desc_t * pndd)
|
||||||
|
|
||||||
pnd->driver_data = malloc(sizeof(struct arygon_data));
|
pnd->driver_data = malloc(sizeof(struct arygon_data));
|
||||||
DRIVER_DATA (pnd)->port = sp;
|
DRIVER_DATA (pnd)->port = sp;
|
||||||
pnd->chip_data = malloc(sizeof(struct pn53x_data));
|
|
||||||
|
// Alloc and init chip's data
|
||||||
|
pn53x_data_new (pnd, &arygon_tama_io);
|
||||||
|
|
||||||
// The PN53x chip connected to ARYGON MCU doesn't seems to be in SLEEP mode
|
// The PN53x chip connected to ARYGON MCU doesn't seems to be in LowVBat mode
|
||||||
CHIP_DATA (pnd)->power_mode = NORMAL;
|
CHIP_DATA (pnd)->power_mode = NORMAL;
|
||||||
CHIP_DATA (pnd)->io = &arygon_tama_io;
|
|
||||||
// empirical tuning
|
// empirical tuning
|
||||||
CHIP_DATA (pnd)->timer_correction = 46;
|
CHIP_DATA (pnd)->timer_correction = 46;
|
||||||
pnd->driver = &arygon_driver;
|
pnd->driver = &arygon_driver;
|
||||||
|
@ -220,6 +222,7 @@ arygon_disconnect (nfc_device_t * pnd)
|
||||||
close (DRIVER_DATA (pnd)->iAbortFds[1]);
|
close (DRIVER_DATA (pnd)->iAbortFds[1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pn53x_data_free(pnd);
|
||||||
nfc_device_free (pnd);
|
nfc_device_free (pnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,10 +163,11 @@ pn532_uart_connect (const nfc_device_desc_t * pndd)
|
||||||
|
|
||||||
pnd->driver_data = malloc(sizeof(struct pn532_uart_data));
|
pnd->driver_data = malloc(sizeof(struct pn532_uart_data));
|
||||||
DRIVER_DATA(pnd)->port = sp;
|
DRIVER_DATA(pnd)->port = sp;
|
||||||
pnd->chip_data = malloc(sizeof(struct pn53x_data));
|
// Alloc and init chip's data
|
||||||
CHIP_DATA(pnd)->type = PN532;
|
pn53x_data_new (pnd, &pn532_uart_io);
|
||||||
|
// This device starts in LowVBat mode
|
||||||
CHIP_DATA(pnd)->power_mode = LOWVBAT;
|
CHIP_DATA(pnd)->power_mode = LOWVBAT;
|
||||||
CHIP_DATA(pnd)->io = &pn532_uart_io;
|
|
||||||
// empirical tuning
|
// empirical tuning
|
||||||
CHIP_DATA(pnd)->timer_correction = 48;
|
CHIP_DATA(pnd)->timer_correction = 48;
|
||||||
pnd->driver = &pn532_uart_driver;
|
pnd->driver = &pn532_uart_driver;
|
||||||
|
|
|
@ -365,6 +365,7 @@ pn53x_usb_disconnect (nfc_device_t * pnd)
|
||||||
if ((res = usb_close (DRIVER_DATA (pnd)->pudh)) < 0) {
|
if ((res = usb_close (DRIVER_DATA (pnd)->pudh)) < 0) {
|
||||||
ERR ("usb_close failed (%i)", res);
|
ERR ("usb_close failed (%i)", res);
|
||||||
}
|
}
|
||||||
|
pn53x_data_free (pnd);
|
||||||
nfc_device_free (pnd);
|
nfc_device_free (pnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,6 @@ nfc_device_free (nfc_device_t *nfc_device)
|
||||||
{
|
{
|
||||||
if (nfc_device) {
|
if (nfc_device) {
|
||||||
free (nfc_device->driver_data);
|
free (nfc_device->driver_data);
|
||||||
free (nfc_device->chip_data);
|
|
||||||
free (nfc_device);
|
free (nfc_device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue