bk://bk.arm.linux.org.uk/linux-2.6-pcmcia
rmk@flint.arm.linux.org.uk|ChangeSet|20041022201237|23298 rmk

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/10/22 21:12:37+01:00 rmk@flint.arm.linux.org.uk 
#   [PCMCIA] Fix PCMCIA behaviour on resume with different card.
#   
#   PCMCIA checks the card CIS against its cached copy.  If it finds
#   that the card does not match, it destroys the bindings with existing
#   drivers, issues an remove event followed by an insert event.  However,
#   ds.c delays the remove event by 100ms, so cardmgr sees the insert
#   before remove.  It thereby ignores the new card.
#   
#   Also, we ended up leaving the fake CIS intact, so the new card appears
#   to be described by the fake CIS.  Destroy the fake CIS in addition to
#   the CIS cache.
# 
# drivers/pcmcia/cs.c
#   2004/10/22 21:09:33+01:00 rmk@flint.arm.linux.org.uk +8 -4
#   Move fake CIS destruction into cistpl.c
#   Report via debug whether the CIS verification was successful on resume.
#   Wait 200ms before sending a new card insertion event.
# 
# drivers/pcmcia/cistpl.c
#   2004/10/22 21:09:32+01:00 rmk@flint.arm.linux.org.uk +8 -0
#   When we destroy the CIS cache, also destroy the fake CIS as well.
# 
# ChangeSet
#   2004/10/19 22:06:25-07:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-pcmcia
# 
# drivers/pcmcia/Makefile
#   2004/10/19 22:06:21-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# drivers/pcmcia/Kconfig
#   2004/10/19 22:06:21-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/10/19 17:15:53-07:00 akpm@bix.(none) 
#   Merge
# 
# drivers/pcmcia/Makefile
#   2004/10/19 17:15:51-07:00 akpm@bix.(none) +0 -0
#   SCCS merged
# 
# drivers/pcmcia/Kconfig
#   2004/10/19 17:11:33-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
--- a/drivers/pcmcia/cistpl.c	2004-10-26 18:44:25 -07:00
+++ b/drivers/pcmcia/cistpl.c	2004-10-26 18:44:25 -07:00
@@ -331,6 +331,14 @@
 		list_del(&cis->node);
 		kfree(cis);
 	}
+
+	/*
+	 * If there was a fake CIS, destroy that as well.
+	 */
+	if (s->fake_cis) {
+		kfree(s->fake_cis);
+		s->fake_cis = NULL;
+	}
 }
 
 /*======================================================================
diff -Nru a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
--- a/drivers/pcmcia/cs.c	2004-10-26 18:44:25 -07:00
+++ b/drivers/pcmcia/cs.c	2004-10-26 18:44:25 -07:00
@@ -364,10 +364,6 @@
     s->irq.AssignedIRQ = s->irq.Config = 0;
     s->lock_count = 0;
     destroy_cis_cache(s);
-    if (s->fake_cis) {
-	kfree(s->fake_cis);
-	s->fake_cis = NULL;
-    }
 #ifdef CONFIG_CARDBUS
     cb_free(s);
 #endif
@@ -613,10 +609,18 @@
 		 * FIXME: need a better check here for cardbus cards.
 		 */
 		if (verify_cis_cache(skt) != 0) {
+			cs_dbg(skt, 4, "cis mismatch - different card\n");
 			socket_remove_drivers(skt);
 			destroy_cis_cache(skt);
+			/*
+			 * Workaround: give DS time to schedule removal.
+			 * Remove me once the 100ms delay is eliminated
+			 * in ds.c
+			 */
+			msleep(200);
 			send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
 		} else {
+			cs_dbg(skt, 4, "cis matches cache\n");
 			send_event(skt, CS_EVENT_PM_RESUME, CS_EVENT_PRI_LOW);
 		}
 	} else {
