Prepare RFID compilation in firmware mode
[librfid] / src / rfid_asic_rc632.c
index 39e1273..f8a8483 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic Philips CL RC632 Routines
  *
- * (C) Harald Welte <laforge@gnumonks.org>
+ * (C) 2005-2006 Harald Welte <laforge@gnumonks.org>
  *
  */
 
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <limits.h>
 #include <sys/types.h>
 
 #include <librfid/rfid.h>
@@ -40,7 +41,7 @@
 #define RC632_TMO_AUTH1        14000
 
 #define ENTER()                DEBUGP("entering\n")
-struct rfid_asic rc632;
+const struct rfid_asic rc632;
 
 /* Register and FIFO Access functions */
 static int 
@@ -171,7 +172,7 @@ static int best_prescaler(u_int64_t timeout, u_int8_t *prescaler,
        u_int8_t best_prescaler, best_divisor, i;
        int64_t smallest_diff;
 
-       smallest_diff = 0x7fffffffffffffff;
+       smallest_diff = LLONG_MAX;
        best_prescaler = 0;
 
        for (i = 0; i < 21; i++) {
@@ -232,7 +233,7 @@ rc632_timer_set(struct rfid_asic_handle *handle,
 }
 
 /* Wait until RC632 is idle or TIMER IRQ has happened */
-static rc632_wait_idle_timer(struct rfid_asic_handle *handle)
+static int rc632_wait_idle_timer(struct rfid_asic_handle *handle)
 {
        int ret;
        u_int8_t irq, cmd;
@@ -595,7 +596,7 @@ rc632_open(struct rfid_asic_transport_handle *th)
 {
        struct rfid_asic_handle *h;
 
-       h = malloc(sizeof(*h));
+       h = malloc_asic_handle(sizeof(*h));
        if (!h)
                return NULL;
        memset(h, 0, sizeof(*h));
@@ -608,7 +609,7 @@ rc632_open(struct rfid_asic_transport_handle *th)
        h->mtu = h->mru = 64;
 
        if (rc632_init(h) < 0) {
-               free(h);
+               free_asic_handle(h);
                return NULL;
        }
 
@@ -619,14 +620,14 @@ void
 rc632_close(struct rfid_asic_handle *h)
 {
        rc632_fini(h);
-       free(h);
+       free_asic_handle(h);
 }
 
 
 /* 
  * Philips CL RC632 primitives for ISO 14443-A compliant PICC's
  *
- * (C) 2005 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
  *
  */
 
@@ -1002,8 +1003,7 @@ static struct tx_config tx_configs[] = {
 };
 
 static int rc632_iso14443a_set_speed(struct rfid_asic_handle *handle,
-                                    unsigned int tx,
-                                    u_int8_t rate)
+                                    unsigned int tx, unsigned int rate)
 {
        int rc;
        u_int8_t reg;
@@ -1581,7 +1581,7 @@ rc632_mifare_transceive(struct rfid_asic_handle *handle,
        return 0; 
 }
 
-struct rfid_asic rc632 = {
+const struct rfid_asic rc632 = {
        .name   = "Philips CL RC632",
        .fc     = ISO14443_FREQ_CARRIER,
        .priv.rc632 = {