]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pcmcia/cistpl.c
net: Print the module name as part of the watchdog message
[linux-2.6-omap-h63xx.git] / drivers / pcmcia / cistpl.c
index 06a85d7d5aa2fecb63edd53fb528aeb2d7ad828c..65129b54eb09c309ef87e9ebf94a3c60869efdd9 100644 (file)
@@ -30,7 +30,6 @@
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
 #include <pcmcia/cs.h>
-#include <pcmcia/bulkmem.h>
 #include <pcmcia/cisreg.h>
 #include <pcmcia/cistpl.h>
 #include "cs_internal.h"
@@ -402,15 +401,6 @@ EXPORT_SYMBOL(pcmcia_replace_cis);
     
 ======================================================================*/
 
-static inline u16 cis_get_u16(void *ptr)
-{
-       return le16_to_cpu(get_unaligned((__le16 *) ptr));
-}
-static inline u32 cis_get_u32(void *ptr)
-{
-       return le32_to_cpu(get_unaligned((__le32 *) ptr));
-}
-
 typedef struct tuple_flags {
     u_int              link_space:4;
     u_int              has_link:1;
@@ -471,7 +461,7 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
        /* Get indirect link from the MFC tuple */
        read_cis_cache(s, LINK_SPACE(tuple->Flags),
                       tuple->LinkOffset, 5, link);
-       ofs = cis_get_u32(link + 1);
+       ofs = get_unaligned_le32(link + 1);
        SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR);
        /* Move to the next indirect link */
        tuple->LinkOffset += 5;
@@ -679,8 +669,8 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
     if (tuple->TupleDataLen < 5)
        return CS_BAD_TUPLE;
     p = (u_char *) tuple->TupleData;
-    csum->addr = tuple->CISOffset + cis_get_u16(p) - 2;
-    csum->len = cis_get_u16(p + 2);
+    csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2;
+    csum->len = get_unaligned_le16(p + 2);
     csum->sum = *(p + 4);
     return CS_SUCCESS;
 }
@@ -691,7 +681,7 @@ static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link)
 {
     if (tuple->TupleDataLen < 4)
        return CS_BAD_TUPLE;
-    link->addr = cis_get_u32(tuple->TupleData);
+    link->addr = get_unaligned_le32(tuple->TupleData);
     return CS_SUCCESS;
 }
 
@@ -710,7 +700,7 @@ static int parse_longlink_mfc(tuple_t *tuple,
        return CS_BAD_TUPLE;
     for (i = 0; i < link->nfn; i++) {
        link->fn[i].space = *p; p++;
-       link->fn[i].addr = cis_get_u32(p);
+       link->fn[i].addr = get_unaligned_le32(p);
        p += 4;
     }
     return CS_SUCCESS;
@@ -800,8 +790,8 @@ static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m)
 {
     if (tuple->TupleDataLen < 4)
        return CS_BAD_TUPLE;
-    m->manf = cis_get_u16(tuple->TupleData);
-    m->card = cis_get_u16(tuple->TupleData + 2);
+    m->manf = get_unaligned_le16(tuple->TupleData);
+    m->card = get_unaligned_le16(tuple->TupleData + 2);
     return CS_SUCCESS;
 }
 
@@ -1100,7 +1090,7 @@ static int parse_cftable_entry(tuple_t *tuple,
        break;
     case 0x20:
        entry->mem.nwin = 1;
-       entry->mem.win[0].len = cis_get_u16(p) << 8;
+       entry->mem.win[0].len = get_unaligned_le16(p) << 8;
        entry->mem.win[0].card_addr = 0;
        entry->mem.win[0].host_addr = 0;
        p += 2;
@@ -1108,8 +1098,8 @@ static int parse_cftable_entry(tuple_t *tuple,
        break;
     case 0x40:
        entry->mem.nwin = 1;
-       entry->mem.win[0].len = cis_get_u16(p) << 8;
-       entry->mem.win[0].card_addr = cis_get_u16(p + 2) << 8;
+       entry->mem.win[0].len = get_unaligned_le16(p) << 8;
+       entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8;
        entry->mem.win[0].host_addr = 0;
        p += 4;
        if (p > q) return CS_BAD_TUPLE;
@@ -1146,7 +1136,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar)
     p = (u_char *)tuple->TupleData;
     bar->attr = *p;
     p += 2;
-    bar->size = cis_get_u32(p);
+    bar->size = get_unaligned_le32(p);
     return CS_SUCCESS;
 }
 
@@ -1159,7 +1149,7 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config)
        return CS_BAD_TUPLE;
     config->last_idx = *(++p);
     p++;
-    config->base = cis_get_u32(p);
+    config->base = get_unaligned_le32(p);
     config->subtuples = tuple->TupleDataLen - 6;
     return CS_SUCCESS;
 }
@@ -1275,7 +1265,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
 
     v2->vers = p[0];
     v2->comply = p[1];
-    v2->dindex = cis_get_u16(p +2 );
+    v2->dindex = get_unaligned_le16(p +2 );
     v2->vspec8 = p[6];
     v2->vspec9 = p[7];
     v2->nhdr = p[8];
@@ -1316,8 +1306,8 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
 
     fmt->type = p[0];
     fmt->edc = p[1];
-    fmt->offset = cis_get_u32(p + 2);
-    fmt->length = cis_get_u32(p + 6);
+    fmt->offset = get_unaligned_le32(p + 2);
+    fmt->length = get_unaligned_le32(p + 6);
 
     return CS_SUCCESS;
 }
@@ -1448,10 +1438,11 @@ EXPORT_SYMBOL(pccard_read_tuple);
     
 ======================================================================*/
 
-int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_t *info)
+int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int *info)
 {
     tuple_t *tuple;
     cisparse_t *p;
+    unsigned int count = 0;
     int ret, reserved, dev_ok = 0, ident_ok = 0;
 
     if (!s)
@@ -1466,7 +1457,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_
        return CS_OUT_OF_RESOURCE;
     }
 
-    info->Chains = reserved = 0;
+    count = reserved = 0;
     tuple->DesiredTuple = RETURN_FIRST_TUPLE;
     tuple->Attributes = TUPLE_RETURN_COMMON;
     ret = pccard_get_first_tuple(s, function, tuple);
@@ -1491,7 +1482,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_
     if (!dev_ok && !ident_ok)
        goto done;
 
-    for (info->Chains = 1; info->Chains < MAX_TUPLES; info->Chains++) {
+    for (count = 1; count < MAX_TUPLES; count++) {
        ret = pccard_get_next_tuple(s, function, tuple);
        if (ret != CS_SUCCESS) break;
        if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||
@@ -1499,11 +1490,13 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_
            ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff)))
            reserved++;
     }
-    if ((info->Chains == MAX_TUPLES) || (reserved > 5) ||
-       ((!dev_ok || !ident_ok) && (info->Chains > 10)))
-       info->Chains = 0;
+    if ((count == MAX_TUPLES) || (reserved > 5) ||
+       ((!dev_ok || !ident_ok) && (count > 10)))
+       count = 0;
 
 done:
+    if (info)
+           *info = count;
     kfree(tuple);
     kfree(p);
     return CS_SUCCESS;