diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-10-18 17:51:09 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-10-18 18:29:36 -0400 |
commit | 84897fc0524d7cbfc81d0bdf9f92ade6e3c3816b (patch) | |
tree | e24975ac12a1947c1a74dde7d23e795e27c41146 | |
parent | 30514ccfc5651b0b1eb27d5ac1cb580b152cd85f (diff) |
pcmcia: pccard_read_tuple and TUPLE_RETURN_COMMON cleanup
pccard_read_tuple(), which is only used by the PCMCIA core, should
handle TUPLE_RETURN_COMMON more sensibly: If a specific function (which
may be 0) is requested, set tuple.Attributes = 0 as was done in all
PCMCIA drivers. If, however, BIND_FN_ALL is requested, return the
"common" tuple. As to the callers of pccard_read_tuple():
- All calls to pcmcia_validate_cis() had set the "function" parameter to
BIND_FN_ALL. Therefore, remove the "function" parameter and make the
parameter to pccard_read_tuple explicit.
- Calls to CISTPL_VERS_1 and CISTPL_MANFID now set BIND_FN_ALL. This was
already the case for calls to CISTPL_LONGLINK_MFC.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r-- | drivers/pcmcia/cistpl.c | 20 | ||||
-rw-r--r-- | drivers/pcmcia/cs_internal.h | 3 | ||||
-rw-r--r-- | drivers/pcmcia/ds.c | 6 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 2 | ||||
-rw-r--r-- | drivers/pcmcia/rsrc_nonstatic.c | 2 | ||||
-rw-r--r-- | drivers/pcmcia/socket_sysfs.c | 2 |
6 files changed, 18 insertions, 17 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 4a110b7b2673..6c4a4fc83630 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -1463,7 +1463,9 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t | |||
1463 | return -ENOMEM; | 1463 | return -ENOMEM; |
1464 | } | 1464 | } |
1465 | tuple.DesiredTuple = code; | 1465 | tuple.DesiredTuple = code; |
1466 | tuple.Attributes = TUPLE_RETURN_COMMON; | 1466 | tuple.Attributes = 0; |
1467 | if (function == BIND_FN_ALL) | ||
1468 | tuple.Attributes = TUPLE_RETURN_COMMON; | ||
1467 | ret = pccard_get_first_tuple(s, function, &tuple); | 1469 | ret = pccard_get_first_tuple(s, function, &tuple); |
1468 | if (ret != 0) | 1470 | if (ret != 0) |
1469 | goto done; | 1471 | goto done; |
@@ -1490,7 +1492,7 @@ EXPORT_SYMBOL(pccard_read_tuple); | |||
1490 | 1492 | ||
1491 | ======================================================================*/ | 1493 | ======================================================================*/ |
1492 | 1494 | ||
1493 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int *info) | 1495 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info) |
1494 | { | 1496 | { |
1495 | tuple_t *tuple; | 1497 | tuple_t *tuple; |
1496 | cisparse_t *p; | 1498 | cisparse_t *p; |
@@ -1515,30 +1517,30 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned | |||
1515 | count = reserved = 0; | 1517 | count = reserved = 0; |
1516 | tuple->DesiredTuple = RETURN_FIRST_TUPLE; | 1518 | tuple->DesiredTuple = RETURN_FIRST_TUPLE; |
1517 | tuple->Attributes = TUPLE_RETURN_COMMON; | 1519 | tuple->Attributes = TUPLE_RETURN_COMMON; |
1518 | ret = pccard_get_first_tuple(s, function, tuple); | 1520 | ret = pccard_get_first_tuple(s, BIND_FN_ALL, tuple); |
1519 | if (ret != 0) | 1521 | if (ret != 0) |
1520 | goto done; | 1522 | goto done; |
1521 | 1523 | ||
1522 | /* First tuple should be DEVICE; we should really have either that | 1524 | /* First tuple should be DEVICE; we should really have either that |
1523 | or a CFTABLE_ENTRY of some sort */ | 1525 | or a CFTABLE_ENTRY of some sort */ |
1524 | if ((tuple->TupleCode == CISTPL_DEVICE) || | 1526 | if ((tuple->TupleCode == CISTPL_DEVICE) || |
1525 | (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == 0) || | 1527 | (pccard_read_tuple(s, BIND_FN_ALL, CISTPL_CFTABLE_ENTRY, p) == 0) || |
1526 | (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == 0)) | 1528 | (pccard_read_tuple(s, BIND_FN_ALL, CISTPL_CFTABLE_ENTRY_CB, p) == 0)) |
1527 | dev_ok++; | 1529 | dev_ok++; |
1528 | 1530 | ||
1529 | /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 | 1531 | /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 |
1530 | tuple, for card identification. Certain old D-Link and Linksys | 1532 | tuple, for card identification. Certain old D-Link and Linksys |
1531 | cards have only a broken VERS_2 tuple; hence the bogus test. */ | 1533 | cards have only a broken VERS_2 tuple; hence the bogus test. */ |
1532 | if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) || | 1534 | if ((pccard_read_tuple(s, BIND_FN_ALL, CISTPL_MANFID, p) == 0) || |
1533 | (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) || | 1535 | (pccard_read_tuple(s, BIND_FN_ALL, CISTPL_VERS_1, p) == 0) || |
1534 | (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC)) | 1536 | (pccard_read_tuple(s, BIND_FN_ALL, CISTPL_VERS_2, p) != -ENOSPC)) |
1535 | ident_ok++; | 1537 | ident_ok++; |
1536 | 1538 | ||
1537 | if (!dev_ok && !ident_ok) | 1539 | if (!dev_ok && !ident_ok) |
1538 | goto done; | 1540 | goto done; |
1539 | 1541 | ||
1540 | for (count = 1; count < MAX_TUPLES; count++) { | 1542 | for (count = 1; count < MAX_TUPLES; count++) { |
1541 | ret = pccard_get_next_tuple(s, function, tuple); | 1543 | ret = pccard_get_next_tuple(s, BIND_FN_ALL, tuple); |
1542 | if (ret != 0) | 1544 | if (ret != 0) |
1543 | break; | 1545 | break; |
1544 | if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || | 1546 | if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || |
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 79615e6d540b..1f4098f1354d 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h | |||
@@ -197,8 +197,7 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, | |||
197 | cisdata_t code, void *parse); | 197 | cisdata_t code, void *parse); |
198 | int pcmcia_replace_cis(struct pcmcia_socket *s, | 198 | int pcmcia_replace_cis(struct pcmcia_socket *s, |
199 | const u8 *data, const size_t len); | 199 | const u8 *data, const size_t len); |
200 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, | 200 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count); |
201 | unsigned int *count); | ||
202 | 201 | ||
203 | /* rsrc_mgr.c */ | 202 | /* rsrc_mgr.c */ |
204 | int pcmcia_validate_mem(struct pcmcia_socket *s); | 203 | int pcmcia_validate_mem(struct pcmcia_socket *s); |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 9f300d3cb125..c70fb3bc0e0f 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -547,7 +547,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) | |||
547 | if (!vers1) | 547 | if (!vers1) |
548 | return -ENOMEM; | 548 | return -ENOMEM; |
549 | 549 | ||
550 | if (!pccard_read_tuple(p_dev->socket, p_dev->func, | 550 | if (!pccard_read_tuple(p_dev->socket, BIND_FN_ALL, |
551 | CISTPL_MANFID, &manf_id)) { | 551 | CISTPL_MANFID, &manf_id)) { |
552 | p_dev->manf_id = manf_id.manf; | 552 | p_dev->manf_id = manf_id.manf; |
553 | p_dev->card_id = manf_id.card; | 553 | p_dev->card_id = manf_id.card; |
@@ -581,7 +581,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) | |||
581 | kfree(devgeo); | 581 | kfree(devgeo); |
582 | } | 582 | } |
583 | 583 | ||
584 | if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1, | 584 | if (!pccard_read_tuple(p_dev->socket, BIND_FN_ALL, CISTPL_VERS_1, |
585 | vers1)) { | 585 | vers1)) { |
586 | for (i=0; i < vers1->ns; i++) { | 586 | for (i=0; i < vers1->ns; i++) { |
587 | char *tmp; | 587 | char *tmp; |
@@ -733,7 +733,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s) | |||
733 | return -EAGAIN; /* try again, but later... */ | 733 | return -EAGAIN; /* try again, but later... */ |
734 | } | 734 | } |
735 | 735 | ||
736 | ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains); | 736 | ret = pccard_validate_cis(s, &no_chains); |
737 | if (ret || !no_chains) { | 737 | if (ret || !no_chains) { |
738 | ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n"); | 738 | ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n"); |
739 | return -ENODEV; | 739 | return -ENODEV; |
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 32c44040c1e8..30cf71d2ee23 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -881,7 +881,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
881 | mutex_lock(&s->skt_mutex); | 881 | mutex_lock(&s->skt_mutex); |
882 | pcmcia_validate_mem(s); | 882 | pcmcia_validate_mem(s); |
883 | mutex_unlock(&s->skt_mutex); | 883 | mutex_unlock(&s->skt_mutex); |
884 | ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo.Chains); | 884 | ret = pccard_validate_cis(s, &buf->cisinfo.Chains); |
885 | break; | 885 | break; |
886 | case DS_SUSPEND_CARD: | 886 | case DS_SUSPEND_CARD: |
887 | ret = pcmcia_suspend_card(s); | 887 | ret = pcmcia_suspend_card(s); |
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 909b1968098b..7039f3cf5b77 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -276,7 +276,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res, | |||
276 | s->cis_mem.res = res; | 276 | s->cis_mem.res = res; |
277 | s->cis_virt = ioremap(res->start, s->map_size); | 277 | s->cis_virt = ioremap(res->start, s->map_size); |
278 | if (s->cis_virt) { | 278 | if (s->cis_virt) { |
279 | ret = pccard_validate_cis(s, BIND_FN_ALL, count); | 279 | ret = pccard_validate_cis(s, count); |
280 | /* invalidate mapping and CIS cache */ | 280 | /* invalidate mapping and CIS cache */ |
281 | iounmap(s->cis_virt); | 281 | iounmap(s->cis_virt); |
282 | s->cis_virt = NULL; | 282 | s->cis_virt = NULL; |
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index ff9a3bb3c88d..78d5aab542f7 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c | |||
@@ -300,7 +300,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, | |||
300 | 300 | ||
301 | if (!(s->state & SOCKET_PRESENT)) | 301 | if (!(s->state & SOCKET_PRESENT)) |
302 | return -ENODEV; | 302 | return -ENODEV; |
303 | if (pccard_validate_cis(s, BIND_FN_ALL, &chains)) | 303 | if (pccard_validate_cis(s, &chains)) |
304 | return -EIO; | 304 | return -EIO; |
305 | if (!chains) | 305 | if (!chains) |
306 | return -ENODATA; | 306 | return -ENODATA; |