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>
This commit is contained in:
Dominik Brodowski 2009-10-18 23:51:09 +02:00
parent 30514ccfc5
commit 84897fc052
6 changed files with 18 additions and 17 deletions

View File

@ -1463,7 +1463,9 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t
return -ENOMEM;
}
tuple.DesiredTuple = code;
tuple.Attributes = TUPLE_RETURN_COMMON;
tuple.Attributes = 0;
if (function == BIND_FN_ALL)
tuple.Attributes = TUPLE_RETURN_COMMON;
ret = pccard_get_first_tuple(s, function, &tuple);
if (ret != 0)
goto done;
@ -1490,7 +1492,7 @@ EXPORT_SYMBOL(pccard_read_tuple);
======================================================================*/
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int *info)
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
{
tuple_t *tuple;
cisparse_t *p;
@ -1515,30 +1517,30 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned
count = reserved = 0;
tuple->DesiredTuple = RETURN_FIRST_TUPLE;
tuple->Attributes = TUPLE_RETURN_COMMON;
ret = pccard_get_first_tuple(s, function, tuple);
ret = pccard_get_first_tuple(s, BIND_FN_ALL, tuple);
if (ret != 0)
goto done;
/* First tuple should be DEVICE; we should really have either that
or a CFTABLE_ENTRY of some sort */
if ((tuple->TupleCode == CISTPL_DEVICE) ||
(pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == 0) ||
(pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == 0))
(pccard_read_tuple(s, BIND_FN_ALL, CISTPL_CFTABLE_ENTRY, p) == 0) ||
(pccard_read_tuple(s, BIND_FN_ALL, CISTPL_CFTABLE_ENTRY_CB, p) == 0))
dev_ok++;
/* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2
tuple, for card identification. Certain old D-Link and Linksys
cards have only a broken VERS_2 tuple; hence the bogus test. */
if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) ||
(pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) ||
(pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC))
if ((pccard_read_tuple(s, BIND_FN_ALL, CISTPL_MANFID, p) == 0) ||
(pccard_read_tuple(s, BIND_FN_ALL, CISTPL_VERS_1, p) == 0) ||
(pccard_read_tuple(s, BIND_FN_ALL, CISTPL_VERS_2, p) != -ENOSPC))
ident_ok++;
if (!dev_ok && !ident_ok)
goto done;
for (count = 1; count < MAX_TUPLES; count++) {
ret = pccard_get_next_tuple(s, function, tuple);
ret = pccard_get_next_tuple(s, BIND_FN_ALL, tuple);
if (ret != 0)
break;
if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||

View File

@ -197,8 +197,7 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
cisdata_t code, void *parse);
int pcmcia_replace_cis(struct pcmcia_socket *s,
const u8 *data, const size_t len);
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function,
unsigned int *count);
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
/* rsrc_mgr.c */
int pcmcia_validate_mem(struct pcmcia_socket *s);

View File

@ -547,7 +547,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
if (!vers1)
return -ENOMEM;
if (!pccard_read_tuple(p_dev->socket, p_dev->func,
if (!pccard_read_tuple(p_dev->socket, BIND_FN_ALL,
CISTPL_MANFID, &manf_id)) {
p_dev->manf_id = manf_id.manf;
p_dev->card_id = manf_id.card;
@ -581,7 +581,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
kfree(devgeo);
}
if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1,
if (!pccard_read_tuple(p_dev->socket, BIND_FN_ALL, CISTPL_VERS_1,
vers1)) {
for (i=0; i < vers1->ns; i++) {
char *tmp;
@ -733,7 +733,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
return -EAGAIN; /* try again, but later... */
}
ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains);
ret = pccard_validate_cis(s, &no_chains);
if (ret || !no_chains) {
ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n");
return -ENODEV;

View File

@ -881,7 +881,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
mutex_lock(&s->skt_mutex);
pcmcia_validate_mem(s);
mutex_unlock(&s->skt_mutex);
ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo.Chains);
ret = pccard_validate_cis(s, &buf->cisinfo.Chains);
break;
case DS_SUSPEND_CARD:
ret = pcmcia_suspend_card(s);

View File

@ -276,7 +276,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
s->cis_mem.res = res;
s->cis_virt = ioremap(res->start, s->map_size);
if (s->cis_virt) {
ret = pccard_validate_cis(s, BIND_FN_ALL, count);
ret = pccard_validate_cis(s, count);
/* invalidate mapping and CIS cache */
iounmap(s->cis_virt);
s->cis_virt = NULL;

View File

@ -300,7 +300,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
if (pccard_validate_cis(s, BIND_FN_ALL, &chains))
if (pccard_validate_cis(s, &chains))
return -EIO;
if (!chains)
return -ENODATA;