
From: Dominik Brodowski <linux@dominikbrodowski.de>

All in-kernel PCMCIA devices do unregister their client in their respective
->detach() function after a REMOVAL event.  So, AFAICS, the dev_list iteration
should always be false.

Signed-off-by: Dominik Brodowski <linux@brodo.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/bluetooth/bluecard_cs.c    |    5 ----
 25-akpm/drivers/bluetooth/bt3c_cs.c        |    5 ----
 25-akpm/drivers/bluetooth/btuart_cs.c      |    5 ----
 25-akpm/drivers/bluetooth/dtl1_cs.c        |    5 ----
 25-akpm/drivers/char/pcmcia/synclink_cs.c  |    8 -------
 25-akpm/drivers/ide/legacy/ide-cs.c        |    3 --
 25-akpm/drivers/isdn/hardware/avm/avm_cs.c |    8 -------
 25-akpm/drivers/isdn/hisax/avma1_cs.c      |    8 -------
 25-akpm/drivers/isdn/hisax/elsa_cs.c       |    5 ----
 25-akpm/drivers/isdn/hisax/sedlbauer_cs.c  |    8 -------
 25-akpm/drivers/isdn/hisax/teles_cs.c      |    5 ----
 25-akpm/drivers/mtd/maps/pcmciamtd.c       |   30 -----------------------------
 25-akpm/drivers/net/pcmcia/3c574_cs.c      |    3 --
 25-akpm/drivers/net/pcmcia/3c589_cs.c      |    3 --
 25-akpm/drivers/net/pcmcia/axnet_cs.c      |    3 --
 25-akpm/drivers/net/pcmcia/com20020_cs.c   |    3 --
 25-akpm/drivers/net/pcmcia/fmvj18x_cs.c    |    3 --
 25-akpm/drivers/net/pcmcia/ibmtr_cs.c      |    3 --
 25-akpm/drivers/net/pcmcia/nmclan_cs.c     |    3 --
 25-akpm/drivers/net/pcmcia/pcnet_cs.c      |    3 --
 25-akpm/drivers/net/pcmcia/smc91c92_cs.c   |    3 --
 25-akpm/drivers/net/pcmcia/xirc2ps_cs.c    |    4 ---
 25-akpm/drivers/net/wireless/airo_cs.c     |    8 -------
 25-akpm/drivers/net/wireless/atmel_cs.c    |    8 -------
 25-akpm/drivers/net/wireless/netwave_cs.c  |    4 ---
 25-akpm/drivers/net/wireless/orinoco_cs.c  |    9 --------
 25-akpm/drivers/net/wireless/ray_cs.c      |    3 --
 25-akpm/drivers/net/wireless/wl3501_cs.c   |    8 -------
 25-akpm/drivers/parport/parport_cs.c       |    5 ----
 25-akpm/drivers/scsi/pcmcia/aha152x_stub.c |    5 ----
 25-akpm/drivers/scsi/pcmcia/fdomain_stub.c |    5 ----
 25-akpm/drivers/scsi/pcmcia/nsp_cs.c       |    4 +--
 25-akpm/drivers/scsi/pcmcia/qlogic_stub.c  |    5 ----
 25-akpm/drivers/serial/serial_cs.c         |    5 ----
 25-akpm/drivers/telephony/ixj_pcmcia.c     |    5 ----
 25-akpm/sound/pcmcia/pdaudiocf/pdaudiocf.c |   11 ----------
 25-akpm/sound/pcmcia/vx/vx_entry.c         |   10 ---------
 25-akpm/sound/pcmcia/vx/vxpocket.c         |    2 -
 25-akpm/sound/pcmcia/vx/vxpocket.h         |    1 
 39 files changed, 38 insertions(+), 186 deletions(-)

diff -puN drivers/bluetooth/bluecard_cs.c~pcmcia-bug-on-dev_list-=-null drivers/bluetooth/bluecard_cs.c
--- 25/drivers/bluetooth/bluecard_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.115228688 -0800
+++ 25-akpm/drivers/bluetooth/bluecard_cs.c	2004-12-03 18:44:43.175219568 -0800
@@ -1117,10 +1117,7 @@ static int __init init_bluecard_cs(void)
 static void __exit exit_bluecard_cs(void)
 {
 	pcmcia_unregister_driver(&bluecard_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		bluecard_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_bluecard_cs);
diff -puN drivers/bluetooth/bt3c_cs.c~pcmcia-bug-on-dev_list-=-null drivers/bluetooth/bt3c_cs.c
--- 25/drivers/bluetooth/bt3c_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.117228384 -0800
+++ 25-akpm/drivers/bluetooth/bt3c_cs.c	2004-12-03 18:44:43.176219416 -0800
@@ -967,10 +967,7 @@ static int __init init_bt3c_cs(void)
 static void __exit exit_bt3c_cs(void)
 {
 	pcmcia_unregister_driver(&bt3c_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		bt3c_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_bt3c_cs);
diff -puN drivers/bluetooth/btuart_cs.c~pcmcia-bug-on-dev_list-=-null drivers/bluetooth/btuart_cs.c
--- 25/drivers/bluetooth/btuart_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.119228080 -0800
+++ 25-akpm/drivers/bluetooth/btuart_cs.c	2004-12-03 18:44:43.177219264 -0800
@@ -887,10 +887,7 @@ static int __init init_btuart_cs(void)
 static void __exit exit_btuart_cs(void)
 {
 	pcmcia_unregister_driver(&btuart_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		btuart_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_btuart_cs);
diff -puN drivers/bluetooth/dtl1_cs.c~pcmcia-bug-on-dev_list-=-null drivers/bluetooth/dtl1_cs.c
--- 25/drivers/bluetooth/dtl1_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.120227928 -0800
+++ 25-akpm/drivers/bluetooth/dtl1_cs.c	2004-12-03 18:44:43.178219112 -0800
@@ -839,10 +839,7 @@ static int __init init_dtl1_cs(void)
 static void __exit exit_dtl1_cs(void)
 {
 	pcmcia_unregister_driver(&dtl1_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		dtl1_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_dtl1_cs);
diff -puN drivers/char/pcmcia/synclink_cs.c~pcmcia-bug-on-dev_list-=-null drivers/char/pcmcia/synclink_cs.c
--- 25/drivers/char/pcmcia/synclink_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.122227624 -0800
+++ 25-akpm/drivers/char/pcmcia/synclink_cs.c	2004-12-03 18:44:43.181218656 -0800
@@ -3147,13 +3147,7 @@ static void synclink_cs_cleanup(void)
 	}
 
 	pcmcia_unregister_driver(&mgslpc_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL) {
-		if (dev_list->state & DEV_CONFIG)
-			mgslpc_release((u_long)dev_list);
-		mgslpc_detach(dev_list);
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 static int __init synclink_cs_init(void)
diff -puN drivers/ide/legacy/ide-cs.c~pcmcia-bug-on-dev_list-=-null drivers/ide/legacy/ide-cs.c
--- 25/drivers/ide/legacy/ide-cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.124227320 -0800
+++ 25-akpm/drivers/ide/legacy/ide-cs.c	2004-12-03 18:44:43.182218504 -0800
@@ -485,8 +485,7 @@ static int __init init_ide_cs(void)
 static void __exit exit_ide_cs(void)
 {
 	pcmcia_unregister_driver(&ide_cs_driver);
-	while (dev_list != NULL)
-		ide_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_ide_cs);
diff -puN drivers/isdn/hardware/avm/avm_cs.c~pcmcia-bug-on-dev_list-=-null drivers/isdn/hardware/avm/avm_cs.c
--- 25/drivers/isdn/hardware/avm/avm_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.125227168 -0800
+++ 25-akpm/drivers/isdn/hardware/avm/avm_cs.c	2004-12-03 18:44:43.182218504 -0800
@@ -521,13 +521,7 @@ static int __init avmcs_init(void)
 static void __exit avmcs_exit(void)
 {
 	pcmcia_unregister_driver(&avmcs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL) {
-		if (dev_list->state & DEV_CONFIG)
-			avmcs_release(dev_list);
-		avmcs_detach(dev_list);
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(avmcs_init);
diff -puN drivers/isdn/hisax/avma1_cs.c~pcmcia-bug-on-dev_list-=-null drivers/isdn/hisax/avma1_cs.c
--- 25/drivers/isdn/hisax/avma1_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.126227016 -0800
+++ 25-akpm/drivers/isdn/hisax/avma1_cs.c	2004-12-03 18:44:43.183218352 -0800
@@ -531,13 +531,7 @@ static int __init init_avma1_cs(void)
 static void __exit exit_avma1_cs(void)
 {
 	pcmcia_unregister_driver(&avma1cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL) {
-		if (dev_list->state & DEV_CONFIG)
-			avma1cs_release(dev_list);
-		avma1cs_detach(dev_list);
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_avma1_cs);
diff -puN drivers/isdn/hisax/elsa_cs.c~pcmcia-bug-on-dev_list-=-null drivers/isdn/hisax/elsa_cs.c
--- 25/drivers/isdn/hisax/elsa_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.128226712 -0800
+++ 25-akpm/drivers/isdn/hisax/elsa_cs.c	2004-12-03 18:44:43.183218352 -0800
@@ -541,10 +541,7 @@ static int __init init_elsa_cs(void)
 static void __exit exit_elsa_cs(void)
 {
 	pcmcia_unregister_driver(&elsa_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		elsa_cs_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_elsa_cs);
diff -puN drivers/isdn/hisax/sedlbauer_cs.c~pcmcia-bug-on-dev_list-=-null drivers/isdn/hisax/sedlbauer_cs.c
--- 25/drivers/isdn/hisax/sedlbauer_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.129226560 -0800
+++ 25-akpm/drivers/isdn/hisax/sedlbauer_cs.c	2004-12-03 18:44:43.184218200 -0800
@@ -648,13 +648,7 @@ static int __init init_sedlbauer_cs(void
 static void __exit exit_sedlbauer_cs(void)
 {
 	pcmcia_unregister_driver(&sedlbauer_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL) {
-		if (dev_list->state & DEV_CONFIG)
-			sedlbauer_release(dev_list);
-		sedlbauer_detach(dev_list);
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_sedlbauer_cs);
diff -puN drivers/isdn/hisax/teles_cs.c~pcmcia-bug-on-dev_list-=-null drivers/isdn/hisax/teles_cs.c
--- 25/drivers/isdn/hisax/teles_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.131226256 -0800
+++ 25-akpm/drivers/isdn/hisax/teles_cs.c	2004-12-03 18:44:43.185218048 -0800
@@ -522,10 +522,7 @@ static int __init init_teles_cs(void)
 static void __exit exit_teles_cs(void)
 {
 	pcmcia_unregister_driver(&teles_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		teles_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_teles_cs);
diff -puN drivers/mtd/maps/pcmciamtd.c~pcmcia-bug-on-dev_list-=-null drivers/mtd/maps/pcmciamtd.c
--- 25/drivers/mtd/maps/pcmciamtd.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.132226104 -0800
+++ 25-akpm/drivers/mtd/maps/pcmciamtd.c	2004-12-03 18:44:43.186217896 -0800
@@ -854,35 +854,7 @@ static void __exit exit_pcmciamtd(void)
 {
 	DEBUG(1, DRIVER_DESC " unloading");
 	pcmcia_unregister_driver(&pcmciamtd_driver);
-
-	while(dev_list) {
-		dev_link_t *link = dev_list;
-
-		dev_list = link->next;
-		if (link) {
-			struct pcmciamtd_dev *dev = link->priv;
-			
- 			if(dev) {
-				if(link->state & DEV_PRESENT) {
-					if (!(link->state & DEV_STALE_LINK)) {
-						pcmciamtd_detach(link);
-					}
-					link->state &= ~DEV_PRESENT;
-					if(dev->mtd_info) {
-						del_mtd_device(dev->mtd_info);
-						info("mtd%d: Removed",
-						     dev->mtd_info->index);
-					}
-				}
-				if(dev->mtd_info) {
-					DEBUG(2, "Destroying map for mtd%d",
-					      dev->mtd_info->index);
-					map_destroy(dev->mtd_info);
-				}
-				kfree(dev);
-			}
-		}
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_pcmciamtd);
diff -puN drivers/net/pcmcia/3c574_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/3c574_cs.c
--- 25/drivers/net/pcmcia/3c574_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.133225952 -0800
+++ 25-akpm/drivers/net/pcmcia/3c574_cs.c	2004-12-03 18:44:43.187217744 -0800
@@ -1308,8 +1308,7 @@ static int __init init_tc574(void)
 static void __exit exit_tc574(void)
 {
 	pcmcia_unregister_driver(&tc574_driver);
-	while (dev_list != NULL)
-		tc574_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_tc574);
diff -puN drivers/net/pcmcia/3c589_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/3c589_cs.c
--- 25/drivers/net/pcmcia/3c589_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.135225648 -0800
+++ 25-akpm/drivers/net/pcmcia/3c589_cs.c	2004-12-03 18:44:43.188217592 -0800
@@ -1083,8 +1083,7 @@ static int __init init_tc589(void)
 static void __exit exit_tc589(void)
 {
 	pcmcia_unregister_driver(&tc589_driver);
-	while (dev_list != NULL)
-		tc589_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_tc589);
diff -puN drivers/net/pcmcia/axnet_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/axnet_cs.c
--- 25/drivers/net/pcmcia/axnet_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.136225496 -0800
+++ 25-akpm/drivers/net/pcmcia/axnet_cs.c	2004-12-03 18:44:43.189217440 -0800
@@ -877,8 +877,7 @@ static int __init init_axnet_cs(void)
 static void __exit exit_axnet_cs(void)
 {
 	pcmcia_unregister_driver(&axnet_cs_driver);
-	while (dev_list != NULL)
-		axnet_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_axnet_cs);
diff -puN drivers/net/pcmcia/com20020_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/com20020_cs.c
--- 25/drivers/net/pcmcia/com20020_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.138225192 -0800
+++ 25-akpm/drivers/net/pcmcia/com20020_cs.c	2004-12-03 18:44:43.190217288 -0800
@@ -513,8 +513,7 @@ static int __init init_com20020_cs(void)
 static void __exit exit_com20020_cs(void)
 {
 	pcmcia_unregister_driver(&com20020_cs_driver);
-	while (dev_list != NULL)
-		com20020_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_com20020_cs);
diff -puN drivers/net/pcmcia/fmvj18x_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/fmvj18x_cs.c
--- 25/drivers/net/pcmcia/fmvj18x_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.139225040 -0800
+++ 25-akpm/drivers/net/pcmcia/fmvj18x_cs.c	2004-12-03 18:44:43.191217136 -0800
@@ -792,8 +792,7 @@ static int __init init_fmvj18x_cs(void)
 static void __exit exit_fmvj18x_cs(void)
 {
 	pcmcia_unregister_driver(&fmvj18x_cs_driver);
-	while (dev_list != NULL)
-		fmvj18x_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_fmvj18x_cs);
diff -puN drivers/net/pcmcia/ibmtr_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/ibmtr_cs.c
--- 25/drivers/net/pcmcia/ibmtr_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.141224736 -0800
+++ 25-akpm/drivers/net/pcmcia/ibmtr_cs.c	2004-12-03 18:44:43.192216984 -0800
@@ -539,8 +539,7 @@ static int __init init_ibmtr_cs(void)
 static void __exit exit_ibmtr_cs(void)
 {
 	pcmcia_unregister_driver(&ibmtr_cs_driver);
-	while (dev_list != NULL)
-		ibmtr_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_ibmtr_cs);
diff -puN drivers/net/pcmcia/nmclan_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/nmclan_cs.c
--- 25/drivers/net/pcmcia/nmclan_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.142224584 -0800
+++ 25-akpm/drivers/net/pcmcia/nmclan_cs.c	2004-12-03 18:44:43.193216832 -0800
@@ -1702,8 +1702,7 @@ static int __init init_nmclan_cs(void)
 static void __exit exit_nmclan_cs(void)
 {
 	pcmcia_unregister_driver(&nmclan_cs_driver);
-	while (dev_list != NULL)
-		nmclan_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_nmclan_cs);
diff -puN drivers/net/pcmcia/pcnet_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/pcnet_cs.c
--- 25/drivers/net/pcmcia/pcnet_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.144224280 -0800
+++ 25-akpm/drivers/net/pcmcia/pcnet_cs.c	2004-12-03 18:44:43.195216528 -0800
@@ -1662,8 +1662,7 @@ static void __exit exit_pcnet_cs(void)
 {
     DEBUG(0, "pcnet_cs: unloading\n");
     pcmcia_unregister_driver(&pcnet_driver);
-    while (dev_list != NULL)
-	pcnet_detach(dev_list);
+    BUG_ON(dev_list != NULL);
 }
 
 module_init(init_pcnet_cs);
diff -puN drivers/net/pcmcia/smc91c92_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/smc91c92_cs.c
--- 25/drivers/net/pcmcia/smc91c92_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.146223976 -0800
+++ 25-akpm/drivers/net/pcmcia/smc91c92_cs.c	2004-12-03 18:44:43.197216224 -0800
@@ -2263,8 +2263,7 @@ static int __init init_smc91c92_cs(void)
 static void __exit exit_smc91c92_cs(void)
 {
 	pcmcia_unregister_driver(&smc91c92_cs_driver);
-	while (dev_list != NULL)
-		smc91c92_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_smc91c92_cs);
diff -puN drivers/net/pcmcia/xirc2ps_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/pcmcia/xirc2ps_cs.c
--- 25/drivers/net/pcmcia/xirc2ps_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.147223824 -0800
+++ 25-akpm/drivers/net/pcmcia/xirc2ps_cs.c	2004-12-03 18:44:43.198216072 -0800
@@ -2016,9 +2016,7 @@ static void __exit
 exit_xirc2ps_cs(void)
 {
 	pcmcia_unregister_driver(&xirc2ps_cs_driver);
-
-	while (dev_list)
-		xirc2ps_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_xirc2ps_cs);
diff -puN drivers/net/wireless/airo_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/wireless/airo_cs.c
--- 25/drivers/net/wireless/airo_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.149223520 -0800
+++ 25-akpm/drivers/net/wireless/airo_cs.c	2004-12-03 18:44:43.199215920 -0800
@@ -592,13 +592,7 @@ static int airo_cs_init(void)
 static void airo_cs_cleanup(void)
 {
 	pcmcia_unregister_driver(&airo_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL) {
-		if (dev_list->state & DEV_CONFIG)
-			airo_release(dev_list);
-		airo_detach(dev_list);
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 /*
diff -puN drivers/net/wireless/atmel_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/wireless/atmel_cs.c
--- 25/drivers/net/wireless/atmel_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.150223368 -0800
+++ 25-akpm/drivers/net/wireless/atmel_cs.c	2004-12-03 18:44:43.200215768 -0800
@@ -693,13 +693,7 @@ static int atmel_cs_init(void)
 static void atmel_cs_cleanup(void)
 {
         pcmcia_unregister_driver(&atmel_driver);
-
-        /* XXX: this really needs to move into generic code.. */
-        while (dev_list != NULL) {
-                if (dev_list->state & DEV_CONFIG)
-                        atmel_release(dev_list);
-                atmel_detach(dev_list);
-        }
+	BUG_ON(dev_list != NULL);
 }
 
 /*
diff -puN drivers/net/wireless/netwave_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/wireless/netwave_cs.c
--- 25/drivers/net/wireless/netwave_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.152223064 -0800
+++ 25-akpm/drivers/net/wireless/netwave_cs.c	2004-12-03 18:44:43.202215464 -0800
@@ -1696,9 +1696,7 @@ static int __init init_netwave_cs(void)
 static void __exit exit_netwave_cs(void)
 {
 	pcmcia_unregister_driver(&netwave_driver);
-
-	if (dev_list != NULL)	/* Critical situation */
-		printk("netwave_cs: devices remaining when removing module\n");
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_netwave_cs);
diff -puN drivers/net/wireless/orinoco_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/wireless/orinoco_cs.c
--- 25/drivers/net/wireless/orinoco_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.153222912 -0800
+++ 25-akpm/drivers/net/wireless/orinoco_cs.c	2004-12-03 18:44:43.203215312 -0800
@@ -659,14 +659,7 @@ static void __exit
 exit_orinoco_cs(void)
 {
 	pcmcia_unregister_driver(&orinoco_driver);
-
-	if (dev_list)
-		DEBUG(0, PFX "Removing leftover devices.\n");
-	while (dev_list != NULL) {
-		if (dev_list->state & DEV_CONFIG)
-			orinoco_cs_release(dev_list);
-		orinoco_cs_detach(dev_list);
-	}
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_orinoco_cs);
diff -puN drivers/net/wireless/ray_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/wireless/ray_cs.c
--- 25/drivers/net/wireless/ray_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.155222608 -0800
+++ 25-akpm/drivers/net/wireless/ray_cs.c	2004-12-03 18:44:43.205215008 -0800
@@ -2952,8 +2952,7 @@ static void __exit exit_ray_cs(void)
 #endif
 
     pcmcia_unregister_driver(&ray_driver);
-    while (dev_list != NULL)
-        ray_detach(dev_list);
+    BUG_ON(dev_list != NULL);
 } /* exit_ray_cs */
 
 module_init(init_ray_cs);
diff -puN drivers/net/wireless/wl3501_cs.c~pcmcia-bug-on-dev_list-=-null drivers/net/wireless/wl3501_cs.c
--- 25/drivers/net/wireless/wl3501_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.156222456 -0800
+++ 25-akpm/drivers/net/wireless/wl3501_cs.c	2004-12-03 18:44:43.207214704 -0800
@@ -2267,13 +2267,7 @@ static void __exit wl3501_exit_module(vo
 {
 	dprintk(0, ": unloading");
 	pcmcia_unregister_driver(&wl3501_driver);
-	while (wl3501_dev_list) {
-		/* Mark the device as non-existing to minimize calls to card */
-		wl3501_dev_list->state &= ~DEV_PRESENT;
-		if (wl3501_dev_list->state & DEV_CONFIG)
-			wl3501_release(wl3501_dev_list);
-		wl3501_detach(wl3501_dev_list);
-	}
+	BUG_ON(wl3501_dev_list != NULL);
 }
 
 module_init(wl3501_init_module);
diff -puN drivers/parport/parport_cs.c~pcmcia-bug-on-dev_list-=-null drivers/parport/parport_cs.c
--- 25/drivers/parport/parport_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.158222152 -0800
+++ 25-akpm/drivers/parport/parport_cs.c	2004-12-03 18:44:43.208214552 -0800
@@ -401,10 +401,7 @@ static int __init init_parport_cs(void)
 static void __exit exit_parport_cs(void)
 {
 	pcmcia_unregister_driver(&parport_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		parport_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_parport_cs);
diff -puN drivers/scsi/pcmcia/aha152x_stub.c~pcmcia-bug-on-dev_list-=-null drivers/scsi/pcmcia/aha152x_stub.c
--- 25/drivers/scsi/pcmcia/aha152x_stub.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.159222000 -0800
+++ 25-akpm/drivers/scsi/pcmcia/aha152x_stub.c	2004-12-03 18:44:43.208214552 -0800
@@ -347,10 +347,7 @@ static int __init init_aha152x_cs(void)
 static void __exit exit_aha152x_cs(void)
 {
 	pcmcia_unregister_driver(&aha152x_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		aha152x_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_aha152x_cs);
diff -puN drivers/scsi/pcmcia/fdomain_stub.c~pcmcia-bug-on-dev_list-=-null drivers/scsi/pcmcia/fdomain_stub.c
--- 25/drivers/scsi/pcmcia/fdomain_stub.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.161221696 -0800
+++ 25-akpm/drivers/scsi/pcmcia/fdomain_stub.c	2004-12-03 18:44:43.209214400 -0800
@@ -328,10 +328,7 @@ static int __init init_fdomain_cs(void)
 static void __exit exit_fdomain_cs(void)
 {
 	pcmcia_unregister_driver(&fdomain_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		fdomain_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_fdomain_cs);
diff -puN drivers/scsi/pcmcia/nsp_cs.c~pcmcia-bug-on-dev_list-=-null drivers/scsi/pcmcia/nsp_cs.c
--- 25/drivers/scsi/pcmcia/nsp_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.162221544 -0800
+++ 25-akpm/drivers/scsi/pcmcia/nsp_cs.c	2004-12-03 18:44:43.210214248 -0800
@@ -2194,10 +2194,9 @@ static void __exit nsp_cs_exit(void)
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68))
 	pcmcia_unregister_driver(&nsp_driver);
+	BUG_ON(dev_list != NULL);
 #else
 	unregister_pcmcia_driver(&dev_info);
-#endif
-
 	/* XXX: this really needs to move into generic code.. */
 	while (dev_list != NULL) {
 		if (dev_list->state & DEV_CONFIG) {
@@ -2205,6 +2204,7 @@ static void __exit nsp_cs_exit(void)
 		}
 		nsp_cs_detach(dev_list);
 	}
+#endif
 }
 
 
diff -puN drivers/scsi/pcmcia/qlogic_stub.c~pcmcia-bug-on-dev_list-=-null drivers/scsi/pcmcia/qlogic_stub.c
--- 25/drivers/scsi/pcmcia/qlogic_stub.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.163221392 -0800
+++ 25-akpm/drivers/scsi/pcmcia/qlogic_stub.c	2004-12-03 18:44:43.211214096 -0800
@@ -432,10 +432,7 @@ static int __init init_qlogic_cs(void)
 static void __exit exit_qlogic_cs(void)
 {
 	pcmcia_unregister_driver(&qlogic_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		qlogic_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
diff -puN drivers/serial/serial_cs.c~pcmcia-bug-on-dev_list-=-null drivers/serial/serial_cs.c
--- 25/drivers/serial/serial_cs.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.165221088 -0800
+++ 25-akpm/drivers/serial/serial_cs.c	2004-12-03 18:44:43.212213944 -0800
@@ -749,10 +749,7 @@ static int __init init_serial_cs(void)
 static void __exit exit_serial_cs(void)
 {
 	pcmcia_unregister_driver(&serial_cs_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		serial_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_serial_cs);
diff -puN drivers/telephony/ixj_pcmcia.c~pcmcia-bug-on-dev_list-=-null drivers/telephony/ixj_pcmcia.c
--- 25/drivers/telephony/ixj_pcmcia.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.166220936 -0800
+++ 25-akpm/drivers/telephony/ixj_pcmcia.c	2004-12-03 18:44:43.212213944 -0800
@@ -313,10 +313,7 @@ static int __init ixj_pcmcia_init(void)
 static void ixj_pcmcia_exit(void)
 {
 	pcmcia_unregister_driver(&ixj_driver);
-
-	/* XXX: this really needs to move into generic code.. */
-	while (dev_list != NULL)
-		ixj_detach(dev_list);
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(ixj_pcmcia_init);
diff -puN sound/pcmcia/pdaudiocf/pdaudiocf.c~pcmcia-bug-on-dev_list-=-null sound/pcmcia/pdaudiocf/pdaudiocf.c
--- 25/sound/pcmcia/pdaudiocf/pdaudiocf.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.167220784 -0800
+++ 25-akpm/sound/pcmcia/pdaudiocf/pdaudiocf.c	2004-12-03 18:44:43.213213792 -0800
@@ -274,15 +274,6 @@ static void snd_pdacf_detach(dev_link_t 
 }
 
 /*
- * snd_pdacf_detach_all - detach all instances linked to the hw
- */
-static void snd_pdacf_detach_all(void)
-{
-	while (dev_list != NULL)
-		snd_pdacf_detach(dev_list);
-}
-
-/*
  * configuration callback
  */
 
@@ -413,7 +404,7 @@ static int __init init_pdacf(void)
 static void __exit exit_pdacf(void)
 {
 	pcmcia_unregister_driver(&pdacf_cs_driver);
-	snd_pdacf_detach_all();
+	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_pdacf);
diff -puN sound/pcmcia/vx/vx_entry.c~pcmcia-bug-on-dev_list-=-null sound/pcmcia/vx/vx_entry.c
--- 25/sound/pcmcia/vx/vx_entry.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.169220480 -0800
+++ 25-akpm/sound/pcmcia/vx/vx_entry.c	2004-12-03 18:44:43.213213792 -0800
@@ -245,15 +245,6 @@ void snd_vxpocket_detach(struct snd_vxp_
 }
 
 /*
- * snd_vxpocket_detach_all - detach all instances linked to the hw
- */
-void snd_vxpocket_detach_all(struct snd_vxp_entry *hw)
-{
-	while (hw->dev_list != NULL)
-		snd_vxpocket_detach(hw, hw->dev_list);
-}
-
-/*
  * configuration callback
  */
 
@@ -373,4 +364,3 @@ static int vxpocket_event(event_t event,
 EXPORT_SYMBOL(snd_vxpocket_ops);
 EXPORT_SYMBOL(snd_vxpocket_attach);
 EXPORT_SYMBOL(snd_vxpocket_detach);
-EXPORT_SYMBOL(snd_vxpocket_detach_all);
diff -puN sound/pcmcia/vx/vxpocket.c~pcmcia-bug-on-dev_list-=-null sound/pcmcia/vx/vxpocket.c
--- 25/sound/pcmcia/vx/vxpocket.c~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.170220328 -0800
+++ 25-akpm/sound/pcmcia/vx/vxpocket.c	2004-12-03 18:44:43.214213640 -0800
@@ -165,7 +165,7 @@ static int __init init_vxpocket(void)
 static void __exit exit_vxpocket(void)
 {
 	pcmcia_unregister_driver(&vxp_cs_driver);
-	snd_vxpocket_detach_all(&hw_entry);
+	BUG_ON(hw_entry.dev_list != NULL);
 }
 
 module_init(init_vxpocket);
diff -puN sound/pcmcia/vx/vxpocket.h~pcmcia-bug-on-dev_list-=-null sound/pcmcia/vx/vxpocket.h
--- 25/sound/pcmcia/vx/vxpocket.h~pcmcia-bug-on-dev_list-=-null	2004-12-03 18:44:43.171220176 -0800
+++ 25-akpm/sound/pcmcia/vx/vxpocket.h	2004-12-03 18:44:43.214213640 -0800
@@ -77,7 +77,6 @@ void vx_set_mic_level(vx_core_t *chip, i
  */
 dev_link_t *snd_vxpocket_attach(struct snd_vxp_entry *hw);
 void snd_vxpocket_detach(struct snd_vxp_entry *hw, dev_link_t *link);
-void snd_vxpocket_detach_all(struct snd_vxp_entry *hw);
 
 int vxp_add_mic_controls(vx_core_t *chip);
 
_
