Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8e68fd8 authored by Dominik Brodowski's avatar Dominik Brodowski
Browse files

pcmcia: do not break rsrc_nonstatic when handling anonymous cards



Patch 1c6c9b1d 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: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent d19319af
Loading
Loading
Loading
Loading
+9 −19
Original line number Original line Diff line number Diff line
@@ -1449,26 +1449,16 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
done:
done:
	/* invalidate CIS cache on failure */
	/* invalidate CIS cache on failure */
	if (!dev_ok || !ident_ok || !count) {
	if (!dev_ok || !ident_ok || !count) {
#if defined(CONFIG_MTD_PCMCIA_ANONYMOUS)
		/* Set up as an anonymous card. If we don't have anonymous
		   memory support then just error the card as there is no
		   point trying to second guess.

		   Note: some cards have just a device entry, it may be
		   worth extending support to cover these in future */
		if (!dev_ok || !ident_ok) {
			dev_info(&s->dev, "no CIS, assuming an anonymous memory card.\n");
			pcmcia_replace_cis(s, "\xFF", 1);
			count = 1;
			ret = 0;
		} else
#endif
		{
		mutex_lock(&s->ops_mutex);
		mutex_lock(&s->ops_mutex);
		destroy_cis_cache(s);
		destroy_cis_cache(s);
		mutex_unlock(&s->ops_mutex);
		mutex_unlock(&s->ops_mutex);
		/* We differentiate between dev_ok, ident_ok and count
		   failures to allow for an override for anonymous cards
		   in ds.c */
		if (!dev_ok || !ident_ok)
			ret = -EIO;
			ret = -EIO;
		}
		else
			ret = -EFAULT;
	}
	}


	if (info)
	if (info)
+18 −2
Original line number Original line Diff line number Diff line
@@ -633,9 +633,25 @@ static int pcmcia_card_add(struct pcmcia_socket *s)


	ret = pccard_validate_cis(s, &no_chains);
	ret = pccard_validate_cis(s, &no_chains);
	if (ret || !no_chains) {
	if (ret || !no_chains) {
#if defined(CONFIG_MTD_PCMCIA_ANONYMOUS)
		/* Set up as an anonymous card. If we don't have anonymous
		   memory support then just error the card as there is no
		   point trying to second guess.

		   Note: some cards have just a device entry, it may be
		   worth extending support to cover these in future */
		if (ret == -EIO) {
			dev_info(&s->dev, "no CIS, assuming an anonymous memory card.\n");
			pcmcia_replace_cis(s, "\xFF", 1);
			no_chains = 1;
			ret = 0;
		} else
#endif
		{
			dev_dbg(&s->dev, "invalid CIS or invalid resources\n");
			dev_dbg(&s->dev, "invalid CIS or invalid resources\n");
			return -ENODEV;
			return -ENODEV;
		}
		}
	}


	if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
	if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
		no_funcs = mfc.nfn;
		no_funcs = mfc.nfn;