Lines Matching full:tuple

432 /* The high-level CIS tuple services */
447 tuple_t *tuple) in pccard_get_first_tuple() argument
454 tuple->TupleLink = tuple->Flags = 0; in pccard_get_first_tuple()
457 tuple->CISOffset = tuple->LinkOffset = 0; in pccard_get_first_tuple()
458 SPACE(tuple->Flags) = HAS_LINK(tuple->Flags) = 1; in pccard_get_first_tuple()
460 if ((s->functions > 1) && !(tuple->Attributes & TUPLE_RETURN_COMMON)) { in pccard_get_first_tuple()
461 cisdata_t req = tuple->DesiredTuple; in pccard_get_first_tuple()
462 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; in pccard_get_first_tuple()
463 if (pccard_get_next_tuple(s, function, tuple) == 0) { in pccard_get_first_tuple()
464 tuple->DesiredTuple = CISTPL_LINKTARGET; in pccard_get_first_tuple()
465 if (pccard_get_next_tuple(s, function, tuple) != 0) in pccard_get_first_tuple()
468 tuple->CISOffset = tuple->TupleLink = 0; in pccard_get_first_tuple()
469 tuple->DesiredTuple = req; in pccard_get_first_tuple()
471 return pccard_get_next_tuple(s, function, tuple); in pccard_get_first_tuple()
474 static int follow_link(struct pcmcia_socket *s, tuple_t *tuple) in follow_link() argument
480 if (MFC_FN(tuple->Flags)) { in follow_link()
481 /* Get indirect link from the MFC tuple */ in follow_link()
482 ret = read_cis_cache(s, LINK_SPACE(tuple->Flags), in follow_link()
483 tuple->LinkOffset, 5, link); in follow_link()
487 SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR); in follow_link()
489 tuple->LinkOffset += 5; in follow_link()
490 MFC_FN(tuple->Flags)--; in follow_link()
491 } else if (HAS_LINK(tuple->Flags)) { in follow_link()
492 ofs = tuple->LinkOffset; in follow_link()
493 SPACE(tuple->Flags) = LINK_SPACE(tuple->Flags); in follow_link()
494 HAS_LINK(tuple->Flags) = 0; in follow_link()
498 if (SPACE(tuple->Flags)) { in follow_link()
501 ret = read_cis_cache(s, SPACE(tuple->Flags), ofs, 5, link); in follow_link()
507 remove_cis_cache(s, SPACE(tuple->Flags), ofs, 5); in follow_link()
511 ret = read_cis_cache(s, SPACE(tuple->Flags), ofs, 5, link); in follow_link()
517 remove_cis_cache(s, SPACE(tuple->Flags), ofs, 5); in follow_link()
522 tuple_t *tuple) in pccard_get_next_tuple() argument
533 link[1] = tuple->TupleLink; in pccard_get_next_tuple()
534 ofs = tuple->CISOffset + tuple->TupleLink; in pccard_get_next_tuple()
535 attr = SPACE(tuple->Flags); in pccard_get_next_tuple()
552 ofs = follow_link(s, tuple); in pccard_get_next_tuple()
555 attr = SPACE(tuple->Flags); in pccard_get_next_tuple()
561 /* Is this a link tuple? Make a note of it */ in pccard_get_next_tuple()
570 HAS_LINK(tuple->Flags) = 1; in pccard_get_next_tuple()
571 LINK_SPACE(tuple->Flags) = attr | IS_ATTR; in pccard_get_next_tuple()
573 &tuple->LinkOffset); in pccard_get_next_tuple()
578 HAS_LINK(tuple->Flags) = 1; in pccard_get_next_tuple()
579 LINK_SPACE(tuple->Flags) = attr & ~IS_ATTR; in pccard_get_next_tuple()
581 &tuple->LinkOffset); in pccard_get_next_tuple()
586 HAS_LINK(tuple->Flags) = 1; in pccard_get_next_tuple()
587 LINK_SPACE(tuple->Flags) = IS_ATTR | in pccard_get_next_tuple()
589 tuple->LinkOffset = 0; in pccard_get_next_tuple()
592 tuple->LinkOffset = ofs + 3; in pccard_get_next_tuple()
593 LINK_SPACE(tuple->Flags) = attr; in pccard_get_next_tuple()
600 MFC_FN(tuple->Flags) = tmp; in pccard_get_next_tuple()
603 MFC_FN(tuple->Flags) = 1; in pccard_get_next_tuple()
604 tuple->LinkOffset += function * 5; in pccard_get_next_tuple()
608 HAS_LINK(tuple->Flags) = 0; in pccard_get_next_tuple()
611 if ((tuple->Attributes & TUPLE_RETURN_LINK) && in pccard_get_next_tuple()
612 (tuple->DesiredTuple == RETURN_FIRST_TUPLE)) in pccard_get_next_tuple()
615 if (tuple->DesiredTuple == RETURN_FIRST_TUPLE) in pccard_get_next_tuple()
618 if (link[0] == tuple->DesiredTuple) in pccard_get_next_tuple()
627 tuple->TupleCode = link[0]; in pccard_get_next_tuple()
628 tuple->TupleLink = link[1]; in pccard_get_next_tuple()
629 tuple->CISOffset = ofs + 2; in pccard_get_next_tuple()
633 int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple) in pccard_get_tuple_data() argument
641 if (tuple->TupleLink < tuple->TupleOffset) in pccard_get_tuple_data()
643 len = tuple->TupleLink - tuple->TupleOffset; in pccard_get_tuple_data()
644 tuple->TupleDataLen = tuple->TupleLink; in pccard_get_tuple_data()
647 ret = read_cis_cache(s, SPACE(tuple->Flags), in pccard_get_tuple_data()
648 tuple->CISOffset + tuple->TupleOffset, in pccard_get_tuple_data()
649 min(len, (u_int) tuple->TupleDataMax), in pccard_get_tuple_data()
650 tuple->TupleData); in pccard_get_tuple_data()
659 static int parse_device(tuple_t *tuple, cistpl_device_t *device) in parse_device() argument
665 p = (u_char *)tuple->TupleData; in parse_device()
666 q = p + tuple->TupleDataLen; in parse_device()
720 static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) in parse_checksum() argument
723 if (tuple->TupleDataLen < 5) in parse_checksum()
725 p = (u_char *) tuple->TupleData; in parse_checksum()
726 csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; in parse_checksum()
733 static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) in parse_longlink() argument
735 if (tuple->TupleDataLen < 4) in parse_longlink()
737 link->addr = get_unaligned_le32(tuple->TupleData); in parse_longlink()
742 static int parse_longlink_mfc(tuple_t *tuple, cistpl_longlink_mfc_t *link) in parse_longlink_mfc() argument
747 p = (u_char *)tuple->TupleData; in parse_longlink_mfc()
750 if (tuple->TupleDataLen <= link->nfn*5) in parse_longlink_mfc()
793 static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1) in parse_vers_1() argument
797 p = (u_char *)tuple->TupleData; in parse_vers_1()
798 q = p + tuple->TupleDataLen; in parse_vers_1()
810 static int parse_altstr(tuple_t *tuple, cistpl_altstr_t *altstr) in parse_altstr() argument
814 p = (u_char *)tuple->TupleData; in parse_altstr()
815 q = p + tuple->TupleDataLen; in parse_altstr()
822 static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec) in parse_jedec() argument
827 p = (u_char *)tuple->TupleData; in parse_jedec()
828 q = p + tuple->TupleDataLen; in parse_jedec()
842 static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) in parse_manfid() argument
844 if (tuple->TupleDataLen < 4) in parse_manfid()
846 m->manf = get_unaligned_le16(tuple->TupleData); in parse_manfid()
847 m->card = get_unaligned_le16(tuple->TupleData + 2); in parse_manfid()
852 static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f) in parse_funcid() argument
855 if (tuple->TupleDataLen < 2) in parse_funcid()
857 p = (u_char *)tuple->TupleData; in parse_funcid()
864 static int parse_funce(tuple_t *tuple, cistpl_funce_t *f) in parse_funce() argument
868 if (tuple->TupleDataLen < 1) in parse_funce()
870 p = (u_char *)tuple->TupleData; in parse_funce()
872 for (i = 1; i < tuple->TupleDataLen; i++) in parse_funce()
878 static int parse_config(tuple_t *tuple, cistpl_config_t *config) in parse_config() argument
883 p = (u_char *)tuple->TupleData; in parse_config()
886 if (tuple->TupleDataLen < rasz+rmsz+4) in parse_config()
898 config->subtuples = tuple->TupleDataLen - (rasz+rmsz+4); in parse_config()
1078 static int parse_cftable_entry(tuple_t *tuple, in parse_cftable_entry() argument
1083 p = tuple->TupleData; in parse_cftable_entry()
1084 q = p + tuple->TupleDataLen; in parse_cftable_entry()
1202 static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo) in parse_device_geo() argument
1207 p = (u_char *)tuple->TupleData; in parse_device_geo()
1208 q = p + tuple->TupleDataLen; in parse_device_geo()
1226 static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2) in parse_vers_2() argument
1230 if (tuple->TupleDataLen < 10) in parse_vers_2()
1233 p = tuple->TupleData; in parse_vers_2()
1234 q = p + tuple->TupleDataLen; in parse_vers_2()
1247 static int parse_org(tuple_t *tuple, cistpl_org_t *org) in parse_org() argument
1252 p = tuple->TupleData; in parse_org()
1253 q = p + tuple->TupleDataLen; in parse_org()
1270 static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) in parse_format() argument
1274 if (tuple->TupleDataLen < 10) in parse_format()
1277 p = tuple->TupleData; in parse_format()
1288 int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse) in pcmcia_parse_tuple() argument
1292 if (tuple->TupleDataLen > tuple->TupleDataMax) in pcmcia_parse_tuple()
1294 switch (tuple->TupleCode) { in pcmcia_parse_tuple()
1297 ret = parse_device(tuple, &parse->device); in pcmcia_parse_tuple()
1300 ret = parse_checksum(tuple, &parse->checksum); in pcmcia_parse_tuple()
1304 ret = parse_longlink(tuple, &parse->longlink); in pcmcia_parse_tuple()
1307 ret = parse_longlink_mfc(tuple, &parse->longlink_mfc); in pcmcia_parse_tuple()
1310 ret = parse_vers_1(tuple, &parse->version_1); in pcmcia_parse_tuple()
1313 ret = parse_altstr(tuple, &parse->altstr); in pcmcia_parse_tuple()
1317 ret = parse_jedec(tuple, &parse->jedec); in pcmcia_parse_tuple()
1320 ret = parse_manfid(tuple, &parse->manfid); in pcmcia_parse_tuple()
1323 ret = parse_funcid(tuple, &parse->funcid); in pcmcia_parse_tuple()
1326 ret = parse_funce(tuple, &parse->funce); in pcmcia_parse_tuple()
1329 ret = parse_config(tuple, &parse->config); in pcmcia_parse_tuple()
1332 ret = parse_cftable_entry(tuple, &parse->cftable_entry); in pcmcia_parse_tuple()
1336 ret = parse_device_geo(tuple, &parse->device_geo); in pcmcia_parse_tuple()
1339 ret = parse_vers_2(tuple, &parse->vers_2); in pcmcia_parse_tuple()
1342 ret = parse_org(tuple, &parse->org); in pcmcia_parse_tuple()
1346 ret = parse_format(tuple, &parse->format); in pcmcia_parse_tuple()
1378 tuple_t *tuple; in pccard_validate_cis() local
1396 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); in pccard_validate_cis()
1397 if (tuple == NULL) { in pccard_validate_cis()
1403 kfree(tuple); in pccard_validate_cis()
1409 tuple->DesiredTuple = RETURN_FIRST_TUPLE; in pccard_validate_cis()
1410 tuple->Attributes = TUPLE_RETURN_COMMON; in pccard_validate_cis()
1411 ret = pccard_get_first_tuple(s, BIND_FN_ALL, tuple); in pccard_validate_cis()
1415 /* First tuple should be DEVICE; we should really have either that in pccard_validate_cis()
1417 if ((tuple->TupleCode == CISTPL_DEVICE) || in pccard_validate_cis()
1422 /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 in pccard_validate_cis()
1423 tuple, for card identification. Certain old D-Link and Linksys in pccard_validate_cis()
1424 cards have only a broken VERS_2 tuple; hence the bogus test. */ in pccard_validate_cis()
1434 ret = pccard_get_next_tuple(s, BIND_FN_ALL, tuple); in pccard_validate_cis()
1437 if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || in pccard_validate_cis()
1438 ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) || in pccard_validate_cis()
1439 ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff))) in pccard_validate_cis()
1465 kfree(tuple); in pccard_validate_cis()
1476 tuple_t tuple; in pccard_extract_cis() local
1493 memset(&tuple, 0, sizeof(tuple_t)); in pccard_extract_cis()
1495 tuple.Attributes = TUPLE_RETURN_LINK | TUPLE_RETURN_COMMON; in pccard_extract_cis()
1496 tuple.DesiredTuple = RETURN_FIRST_TUPLE; in pccard_extract_cis()
1497 tuple.TupleOffset = 0; in pccard_extract_cis()
1499 status = pccard_get_first_tuple(s, BIND_FN_ALL, &tuple); in pccard_extract_cis()
1501 tuple.TupleData = tuplebuffer; in pccard_extract_cis()
1502 tuple.TupleDataMax = 255; in pccard_extract_cis()
1505 status = pccard_get_tuple_data(s, &tuple); in pccard_extract_cis()
1509 if (off < (pointer + 2 + tuple.TupleDataLen)) { in pccard_extract_cis()
1510 tempbuffer[0] = tuple.TupleCode & 0xff; in pccard_extract_cis()
1511 tempbuffer[1] = tuple.TupleLink & 0xff; in pccard_extract_cis()
1512 for (i = 0; i < tuple.TupleDataLen; i++) in pccard_extract_cis()
1515 for (i = 0; i < (2 + tuple.TupleDataLen); i++) { in pccard_extract_cis()
1524 pointer += 2 + tuple.TupleDataLen; in pccard_extract_cis()
1529 if (tuple.TupleCode == CISTPL_END) in pccard_extract_cis()
1531 status = pccard_get_next_tuple(s, BIND_FN_ALL, &tuple); in pccard_extract_cis()