Skip to content

Commit e8e68fd

Browse files
author
Dominik Brodowski
committed
pcmcia: do not break rsrc_nonstatic when handling anonymous cards
Patch 1c6c9b1 caused a regression for rsrc_nonstatic: It relies on pccard_validate_cis() to determine whether an iomem resource can be used for PCMCIA cards. This override, however, lead invalid iomem resources to be accepted -- and lead to a fake CIS being used instead of the original CIS. To fix this issue, move the override for anonymous cards to the one place where it is needed -- when adding a PCMCIA device. Signed-off-by: Dominik Brodowski <[email protected]>
1 parent d19319a commit e8e68fd

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

drivers/pcmcia/cistpl.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,26 +1449,16 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
14491449
done:
14501450
/* invalidate CIS cache on failure */
14511451
if (!dev_ok || !ident_ok || !count) {
1452-
#if defined(CONFIG_MTD_PCMCIA_ANONYMOUS)
1453-
/* Set up as an anonymous card. If we don't have anonymous
1454-
memory support then just error the card as there is no
1455-
point trying to second guess.
1456-
1457-
Note: some cards have just a device entry, it may be
1458-
worth extending support to cover these in future */
1459-
if (!dev_ok || !ident_ok) {
1460-
dev_info(&s->dev, "no CIS, assuming an anonymous memory card.\n");
1461-
pcmcia_replace_cis(s, "\xFF", 1);
1462-
count = 1;
1463-
ret = 0;
1464-
} else
1465-
#endif
1466-
{
1467-
mutex_lock(&s->ops_mutex);
1468-
destroy_cis_cache(s);
1469-
mutex_unlock(&s->ops_mutex);
1452+
mutex_lock(&s->ops_mutex);
1453+
destroy_cis_cache(s);
1454+
mutex_unlock(&s->ops_mutex);
1455+
/* We differentiate between dev_ok, ident_ok and count
1456+
failures to allow for an override for anonymous cards
1457+
in ds.c */
1458+
if (!dev_ok || !ident_ok)
14701459
ret = -EIO;
1471-
}
1460+
else
1461+
ret = -EFAULT;
14721462
}
14731463

14741464
if (info)

drivers/pcmcia/ds.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,24 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
633633

634634
ret = pccard_validate_cis(s, &no_chains);
635635
if (ret || !no_chains) {
636-
dev_dbg(&s->dev, "invalid CIS or invalid resources\n");
637-
return -ENODEV;
636+
#if defined(CONFIG_MTD_PCMCIA_ANONYMOUS)
637+
/* Set up as an anonymous card. If we don't have anonymous
638+
memory support then just error the card as there is no
639+
point trying to second guess.
640+
641+
Note: some cards have just a device entry, it may be
642+
worth extending support to cover these in future */
643+
if (ret == -EIO) {
644+
dev_info(&s->dev, "no CIS, assuming an anonymous memory card.\n");
645+
pcmcia_replace_cis(s, "\xFF", 1);
646+
no_chains = 1;
647+
ret = 0;
648+
} else
649+
#endif
650+
{
651+
dev_dbg(&s->dev, "invalid CIS or invalid resources\n");
652+
return -ENODEV;
653+
}
638654
}
639655

640656
if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))

0 commit comments

Comments
 (0)