Commit 84897fc0 authored by Dominik Brodowski's avatar Dominik Brodowski

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: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 30514ccf
...@@ -1463,6 +1463,8 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t ...@@ -1463,6 +1463,8 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t
return -ENOMEM; return -ENOMEM;
} }
tuple.DesiredTuple = code; tuple.DesiredTuple = code;
tuple.Attributes = 0;
if (function == BIND_FN_ALL)
tuple.Attributes = TUPLE_RETURN_COMMON; tuple.Attributes = TUPLE_RETURN_COMMON;
ret = pccard_get_first_tuple(s, function, &tuple); ret = pccard_get_first_tuple(s, function, &tuple);
if (ret != 0) if (ret != 0)
...@@ -1490,7 +1492,7 @@ EXPORT_SYMBOL(pccard_read_tuple); ...@@ -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; tuple_t *tuple;
cisparse_t *p; cisparse_t *p;
...@@ -1515,30 +1517,30 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned ...@@ -1515,30 +1517,30 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned
count = reserved = 0; count = reserved = 0;
tuple->DesiredTuple = RETURN_FIRST_TUPLE; tuple->DesiredTuple = RETURN_FIRST_TUPLE;
tuple->Attributes = TUPLE_RETURN_COMMON; 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) if (ret != 0)
goto done; goto done;
/* First tuple should be DEVICE; we should really have either that /* First tuple should be DEVICE; we should really have either that
or a CFTABLE_ENTRY of some sort */ or a CFTABLE_ENTRY of some sort */
if ((tuple->TupleCode == CISTPL_DEVICE) || if ((tuple->TupleCode == CISTPL_DEVICE) ||
(pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == 0) || (pccard_read_tuple(s, BIND_FN_ALL, 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_CB, p) == 0))
dev_ok++; dev_ok++;
/* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 /* 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 tuple, for card identification. Certain old D-Link and Linksys
cards have only a broken VERS_2 tuple; hence the bogus test. */ cards have only a broken VERS_2 tuple; hence the bogus test. */
if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) || if ((pccard_read_tuple(s, BIND_FN_ALL, CISTPL_MANFID, p) == 0) ||
(pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) || (pccard_read_tuple(s, BIND_FN_ALL, CISTPL_VERS_1, p) == 0) ||
(pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC)) (pccard_read_tuple(s, BIND_FN_ALL, CISTPL_VERS_2, p) != -ENOSPC))
ident_ok++; ident_ok++;
if (!dev_ok && !ident_ok) if (!dev_ok && !ident_ok)
goto done; goto done;
for (count = 1; count < MAX_TUPLES; count++) { 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) if (ret != 0)
break; break;
if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||
......
...@@ -197,8 +197,7 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, ...@@ -197,8 +197,7 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
cisdata_t code, void *parse); cisdata_t code, void *parse);
int pcmcia_replace_cis(struct pcmcia_socket *s, int pcmcia_replace_cis(struct pcmcia_socket *s,
const u8 *data, const size_t len); const u8 *data, const size_t len);
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
unsigned int *count);
/* rsrc_mgr.c */ /* rsrc_mgr.c */
int pcmcia_validate_mem(struct pcmcia_socket *s); int pcmcia_validate_mem(struct pcmcia_socket *s);
......
...@@ -547,7 +547,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) ...@@ -547,7 +547,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
if (!vers1) if (!vers1)
return -ENOMEM; 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)) { CISTPL_MANFID, &manf_id)) {
p_dev->manf_id = manf_id.manf; p_dev->manf_id = manf_id.manf;
p_dev->card_id = manf_id.card; p_dev->card_id = manf_id.card;
...@@ -581,7 +581,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) ...@@ -581,7 +581,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
kfree(devgeo); 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)) { vers1)) {
for (i=0; i < vers1->ns; i++) { for (i=0; i < vers1->ns; i++) {
char *tmp; char *tmp;
...@@ -733,7 +733,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s) ...@@ -733,7 +733,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
return -EAGAIN; /* try again, but later... */ 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) { if (ret || !no_chains) {
ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n"); ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n");
return -ENODEV; return -ENODEV;
......
...@@ -881,7 +881,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, ...@@ -881,7 +881,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
mutex_lock(&s->skt_mutex); mutex_lock(&s->skt_mutex);
pcmcia_validate_mem(s); pcmcia_validate_mem(s);
mutex_unlock(&s->skt_mutex); 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; break;
case DS_SUSPEND_CARD: case DS_SUSPEND_CARD:
ret = pcmcia_suspend_card(s); ret = pcmcia_suspend_card(s);
......
...@@ -276,7 +276,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res, ...@@ -276,7 +276,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
s->cis_mem.res = res; s->cis_mem.res = res;
s->cis_virt = ioremap(res->start, s->map_size); s->cis_virt = ioremap(res->start, s->map_size);
if (s->cis_virt) { if (s->cis_virt) {
ret = pccard_validate_cis(s, BIND_FN_ALL, count); ret = pccard_validate_cis(s, count);
/* invalidate mapping and CIS cache */ /* invalidate mapping and CIS cache */
iounmap(s->cis_virt); iounmap(s->cis_virt);
s->cis_virt = NULL; s->cis_virt = NULL;
......
...@@ -300,7 +300,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, ...@@ -300,7 +300,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
if (!(s->state & SOCKET_PRESENT)) if (!(s->state & SOCKET_PRESENT))
return -ENODEV; return -ENODEV;
if (pccard_validate_cis(s, BIND_FN_ALL, &chains)) if (pccard_validate_cis(s, &chains))
return -EIO; return -EIO;
if (!chains) if (!chains)
return -ENODATA; return -ENODATA;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment