carl9170 firmware tools: fix libcarlfw on 64bit cpus
authorChristian Lamparter <chunkeey@googlemail.com>
Thu, 13 Jan 2011 13:45:51 +0000 (14:45 +0100)
committerChristian Lamparter <chunkeey@googlemail.com>
Thu, 13 Jan 2011 13:45:51 +0000 (14:45 +0100)
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
include/shared/fwdesc.h
tools/lib/carlfw.c

index 71f3821f60581d721bd203cea46ed31245e26679..b5428d66feb232655d3405dd2907d80235c08202 100644 (file)
@@ -88,8 +88,10 @@ enum carl9170fw_feature_list {
 #define CARL9170FW_GET_MONTH(m) ((((m) / 31) % 12) + 1)
 #define CARL9170FW_GET_YEAR(y) ((y) / 372 + 10)
 
+#define CARL9170FW_MAGIC_SIZE                  4
+
 struct carl9170fw_desc_head {
-       u8      magic[4];
+       u8      magic[CARL9170FW_MAGIC_SIZE];
        __le16 length;
        u8 min_ver;
        u8 cur_ver;
@@ -189,8 +191,8 @@ struct carl9170fw_last_desc {
        }
 
 static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head,
-                                        u8 magic[4], __le16 length,
-                                        u8 min_ver, u8 cur_ver)
+                                        u8 magic[CARL9170FW_MAGIC_SIZE],
+                                        __le16 length, u8 min_ver, u8 cur_ver)
 {
        head->magic[0] = magic[0];
        head->magic[1] = magic[1];
@@ -204,7 +206,7 @@ static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head,
 
 #define carl9170fw_for_each_hdr(desc, fw_desc)                         \
        for (desc = fw_desc;                                            \
-            memcmp(desc->magic, LAST_MAGIC, 4) &&                      \
+            memcmp(desc->magic, LAST_MAGIC, CARL9170FW_MAGIC_SIZE) &&  \
             le16_to_cpu(desc->length) >= CARL9170FW_DESC_HEAD_SIZE &&  \
             le16_to_cpu(desc->length) < CARL9170FW_DESC_MAX_LENGTH;    \
             desc = (void *)((unsigned long)desc + le16_to_cpu(desc->length)))
@@ -218,8 +220,8 @@ static inline bool carl9170fw_supports(__le32 list, u8 feature)
 }
 
 static inline bool carl9170fw_desc_cmp(const struct carl9170fw_desc_head *head,
-                                      const u8 descid[4], u16 min_len,
-                                      u8 compatible_revision)
+                                      const u8 descid[CARL9170FW_MAGIC_SIZE],
+                                      u16 min_len, u8 compatible_revision)
 {
        if (descid[0] == head->magic[0] && descid[1] == head->magic[1] &&
            descid[2] == head->magic[2] && descid[3] == head->magic[3] &&
index b75253558cfcfacafb1360849f86067d4127a17c..44897e39ef8ee07a1c0b464a1cc7857f303bb854 100644 (file)
@@ -190,18 +190,18 @@ static void *__carlfw_find_desc(struct carlfw_file *file,
        struct carl9170fw_desc_head *tmp = NULL;
 
        while (scan >= 0) {
-               if (file->data[scan] == descid[sizeof(descid) - found - 1])
+               if (file->data[scan] == descid[CARL9170FW_MAGIC_SIZE - found - 1])
                        found++;
                else
                        found = 0;
 
-               if (found == sizeof(descid))
+               if (found == CARL9170FW_MAGIC_SIZE)
                        break;
 
                scan--;
        }
 
-       if (found == sizeof(descid)) {
+       if (found == CARL9170FW_MAGIC_SIZE) {
                tmp = (void *) &file->data[scan];
 
                if (!CHECK_HDR_VERSION(tmp, compatible_revision) &&