pn53x_usb: minor code clean up.

This commit is contained in:
Romuald Conty 2012-01-18 09:39:33 +00:00
parent 324af418db
commit 38bdfe3281
2 changed files with 5 additions and 34 deletions

View file

@ -66,37 +66,6 @@ Thanks to d18c7db and Okko for example code
#define DRIVER_DATA(pnd) ((struct pn53x_usb_data*)(pnd->driver_data)) #define DRIVER_DATA(pnd) ((struct pn53x_usb_data*)(pnd->driver_data))
/* This modified from some GNU example _not_ to overwrite y */
int timeval_subtract(struct timeval *result,
const struct timeval *x,
const struct timeval *y)
{
struct timeval tmp;
tmp.tv_sec = y->tv_sec;
tmp.tv_usec = y->tv_usec;
/* Perform the carry for the later subtraction */
if (x->tv_usec < y->tv_usec) {
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
tmp.tv_usec -= 1000000 * nsec;
tmp.tv_sec += nsec;
}
if (x->tv_usec - y->tv_usec > 1000000) {
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
tmp.tv_usec += 1000000 * nsec;
tmp.tv_sec -= nsec;
}
/* Compute the time remaining to wait.
tv_usec is certainly positive. */
result->tv_sec = x->tv_sec - tmp.tv_sec;
result->tv_usec = x->tv_usec - tmp.tv_usec;
/* Return 1 if result is negative. */
return x->tv_sec < tmp.tv_sec;
}
typedef enum { typedef enum {
UNKNOWN, UNKNOWN,
NXP_PN531, NXP_PN531,

View file

@ -29,6 +29,8 @@
#include <nfc/nfc-types.h> #include <nfc/nfc-types.h>
#include "nfc-internal.h"
bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); bool pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound);
nfc_device *pn53x_usb_open (const nfc_connstring connstring); nfc_device *pn53x_usb_open (const nfc_connstring connstring);
int pn53x_usb_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout); int pn53x_usb_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, int timeout);