diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-04-29 04:03:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:28 -0400 |
commit | 6b1e6f637469647f435f8f8ab00fbafa3c129712 (patch) | |
tree | 15ccc691f4a3e2eebc44730281024d0eac110b66 | |
parent | 533dd1b0be103b0ff11da71152877e1ba530f1c2 (diff) |
pcmcia: use get/put_unaligned_* helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Daniel Ritz <daniel.ritz@gmx.ch>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/pcmcia/cistpl.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 06a85d7d5aa2..36379535f9da 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -402,15 +402,6 @@ EXPORT_SYMBOL(pcmcia_replace_cis); | |||
402 | 402 | ||
403 | ======================================================================*/ | 403 | ======================================================================*/ |
404 | 404 | ||
405 | static inline u16 cis_get_u16(void *ptr) | ||
406 | { | ||
407 | return le16_to_cpu(get_unaligned((__le16 *) ptr)); | ||
408 | } | ||
409 | static inline u32 cis_get_u32(void *ptr) | ||
410 | { | ||
411 | return le32_to_cpu(get_unaligned((__le32 *) ptr)); | ||
412 | } | ||
413 | |||
414 | typedef struct tuple_flags { | 405 | typedef struct tuple_flags { |
415 | u_int link_space:4; | 406 | u_int link_space:4; |
416 | u_int has_link:1; | 407 | u_int has_link:1; |
@@ -471,7 +462,7 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple) | |||
471 | /* Get indirect link from the MFC tuple */ | 462 | /* Get indirect link from the MFC tuple */ |
472 | read_cis_cache(s, LINK_SPACE(tuple->Flags), | 463 | read_cis_cache(s, LINK_SPACE(tuple->Flags), |
473 | tuple->LinkOffset, 5, link); | 464 | tuple->LinkOffset, 5, link); |
474 | ofs = cis_get_u32(link + 1); | 465 | ofs = get_unaligned_le32(link + 1); |
475 | SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR); | 466 | SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR); |
476 | /* Move to the next indirect link */ | 467 | /* Move to the next indirect link */ |
477 | tuple->LinkOffset += 5; | 468 | tuple->LinkOffset += 5; |
@@ -679,8 +670,8 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) | |||
679 | if (tuple->TupleDataLen < 5) | 670 | if (tuple->TupleDataLen < 5) |
680 | return CS_BAD_TUPLE; | 671 | return CS_BAD_TUPLE; |
681 | p = (u_char *) tuple->TupleData; | 672 | p = (u_char *) tuple->TupleData; |
682 | csum->addr = tuple->CISOffset + cis_get_u16(p) - 2; | 673 | csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; |
683 | csum->len = cis_get_u16(p + 2); | 674 | csum->len = get_unaligned_le16(p + 2); |
684 | csum->sum = *(p + 4); | 675 | csum->sum = *(p + 4); |
685 | return CS_SUCCESS; | 676 | return CS_SUCCESS; |
686 | } | 677 | } |
@@ -691,7 +682,7 @@ static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) | |||
691 | { | 682 | { |
692 | if (tuple->TupleDataLen < 4) | 683 | if (tuple->TupleDataLen < 4) |
693 | return CS_BAD_TUPLE; | 684 | return CS_BAD_TUPLE; |
694 | link->addr = cis_get_u32(tuple->TupleData); | 685 | link->addr = get_unaligned_le32(tuple->TupleData); |
695 | return CS_SUCCESS; | 686 | return CS_SUCCESS; |
696 | } | 687 | } |
697 | 688 | ||
@@ -710,7 +701,7 @@ static int parse_longlink_mfc(tuple_t *tuple, | |||
710 | return CS_BAD_TUPLE; | 701 | return CS_BAD_TUPLE; |
711 | for (i = 0; i < link->nfn; i++) { | 702 | for (i = 0; i < link->nfn; i++) { |
712 | link->fn[i].space = *p; p++; | 703 | link->fn[i].space = *p; p++; |
713 | link->fn[i].addr = cis_get_u32(p); | 704 | link->fn[i].addr = get_unaligned_le32(p); |
714 | p += 4; | 705 | p += 4; |
715 | } | 706 | } |
716 | return CS_SUCCESS; | 707 | return CS_SUCCESS; |
@@ -800,8 +791,8 @@ static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) | |||
800 | { | 791 | { |
801 | if (tuple->TupleDataLen < 4) | 792 | if (tuple->TupleDataLen < 4) |
802 | return CS_BAD_TUPLE; | 793 | return CS_BAD_TUPLE; |
803 | m->manf = cis_get_u16(tuple->TupleData); | 794 | m->manf = get_unaligned_le16(tuple->TupleData); |
804 | m->card = cis_get_u16(tuple->TupleData + 2); | 795 | m->card = get_unaligned_le16(tuple->TupleData + 2); |
805 | return CS_SUCCESS; | 796 | return CS_SUCCESS; |
806 | } | 797 | } |
807 | 798 | ||
@@ -1100,7 +1091,7 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1100 | break; | 1091 | break; |
1101 | case 0x20: | 1092 | case 0x20: |
1102 | entry->mem.nwin = 1; | 1093 | entry->mem.nwin = 1; |
1103 | entry->mem.win[0].len = cis_get_u16(p) << 8; | 1094 | entry->mem.win[0].len = get_unaligned_le16(p) << 8; |
1104 | entry->mem.win[0].card_addr = 0; | 1095 | entry->mem.win[0].card_addr = 0; |
1105 | entry->mem.win[0].host_addr = 0; | 1096 | entry->mem.win[0].host_addr = 0; |
1106 | p += 2; | 1097 | p += 2; |
@@ -1108,8 +1099,8 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1108 | break; | 1099 | break; |
1109 | case 0x40: | 1100 | case 0x40: |
1110 | entry->mem.nwin = 1; | 1101 | entry->mem.nwin = 1; |
1111 | entry->mem.win[0].len = cis_get_u16(p) << 8; | 1102 | entry->mem.win[0].len = get_unaligned_le16(p) << 8; |
1112 | entry->mem.win[0].card_addr = cis_get_u16(p + 2) << 8; | 1103 | entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; |
1113 | entry->mem.win[0].host_addr = 0; | 1104 | entry->mem.win[0].host_addr = 0; |
1114 | p += 4; | 1105 | p += 4; |
1115 | if (p > q) return CS_BAD_TUPLE; | 1106 | if (p > q) return CS_BAD_TUPLE; |
@@ -1146,7 +1137,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar) | |||
1146 | p = (u_char *)tuple->TupleData; | 1137 | p = (u_char *)tuple->TupleData; |
1147 | bar->attr = *p; | 1138 | bar->attr = *p; |
1148 | p += 2; | 1139 | p += 2; |
1149 | bar->size = cis_get_u32(p); | 1140 | bar->size = get_unaligned_le32(p); |
1150 | return CS_SUCCESS; | 1141 | return CS_SUCCESS; |
1151 | } | 1142 | } |
1152 | 1143 | ||
@@ -1159,7 +1150,7 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) | |||
1159 | return CS_BAD_TUPLE; | 1150 | return CS_BAD_TUPLE; |
1160 | config->last_idx = *(++p); | 1151 | config->last_idx = *(++p); |
1161 | p++; | 1152 | p++; |
1162 | config->base = cis_get_u32(p); | 1153 | config->base = get_unaligned_le32(p); |
1163 | config->subtuples = tuple->TupleDataLen - 6; | 1154 | config->subtuples = tuple->TupleDataLen - 6; |
1164 | return CS_SUCCESS; | 1155 | return CS_SUCCESS; |
1165 | } | 1156 | } |
@@ -1275,7 +1266,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2) | |||
1275 | 1266 | ||
1276 | v2->vers = p[0]; | 1267 | v2->vers = p[0]; |
1277 | v2->comply = p[1]; | 1268 | v2->comply = p[1]; |
1278 | v2->dindex = cis_get_u16(p +2 ); | 1269 | v2->dindex = get_unaligned_le16(p +2 ); |
1279 | v2->vspec8 = p[6]; | 1270 | v2->vspec8 = p[6]; |
1280 | v2->vspec9 = p[7]; | 1271 | v2->vspec9 = p[7]; |
1281 | v2->nhdr = p[8]; | 1272 | v2->nhdr = p[8]; |
@@ -1316,8 +1307,8 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) | |||
1316 | 1307 | ||
1317 | fmt->type = p[0]; | 1308 | fmt->type = p[0]; |
1318 | fmt->edc = p[1]; | 1309 | fmt->edc = p[1]; |
1319 | fmt->offset = cis_get_u32(p + 2); | 1310 | fmt->offset = get_unaligned_le32(p + 2); |
1320 | fmt->length = cis_get_u32(p + 6); | 1311 | fmt->length = get_unaligned_le32(p + 6); |
1321 | 1312 | ||
1322 | return CS_SUCCESS; | 1313 | return CS_SUCCESS; |
1323 | } | 1314 | } |