aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/bluetooth/bluecard_cs.c18
-rw-r--r--drivers/bluetooth/bt3c_cs.c18
-rw-r--r--drivers/bluetooth/btuart_cs.c18
-rw-r--r--drivers/bluetooth/dtl1_cs.c18
-rw-r--r--drivers/char/pcmcia/synclink_cs.c14
-rw-r--r--drivers/ide/legacy/ide-cs.c19
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c21
-rw-r--r--drivers/isdn/hisax/avma1_cs.c21
-rw-r--r--drivers/isdn/hisax/elsa_cs.c28
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c28
-rw-r--r--drivers/isdn/hisax/teles_cs.c28
-rw-r--r--drivers/mtd/maps/pcmciamtd.c5
-rw-r--r--drivers/net/pcmcia/3c574_cs.c15
-rw-r--r--drivers/net/pcmcia/3c589_cs.c17
-rw-r--r--drivers/net/pcmcia/axnet_cs.c14
-rw-r--r--drivers/net/pcmcia/com20020_cs.c22
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c16
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c21
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c14
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c14
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c15
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c24
-rw-r--r--drivers/net/wireless/airo_cs.c28
-rw-r--r--drivers/net/wireless/atmel_cs.c25
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c15
-rw-r--r--drivers/net/wireless/netwave_cs.c56
-rw-r--r--drivers/net/wireless/orinoco_cs.c21
-rw-r--r--drivers/net/wireless/spectrum_cs.c11
-rw-r--r--drivers/net/wireless/wavelan_cs.c24
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h1
-rw-r--r--drivers/parport/parport_cs.c14
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c30
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c19
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c16
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c14
-rw-r--r--drivers/serial/serial_cs.c17
-rw-r--r--drivers/telephony/ixj_pcmcia.c14
-rw-r--r--drivers/usb/host/sl811_cs.c16
38 files changed, 78 insertions, 651 deletions
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index f5088cb3812b..bd80535646fa 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -94,8 +94,6 @@ static dev_info_t dev_info = "bluecard_cs";
94static dev_link_t *bluecard_attach(void); 94static dev_link_t *bluecard_attach(void);
95static void bluecard_detach(struct pcmcia_device *p_dev); 95static void bluecard_detach(struct pcmcia_device *p_dev);
96 96
97static dev_link_t *dev_list = NULL;
98
99 97
100/* Default baud rate: 57600, 115200, 230400 or 460800 */ 98/* Default baud rate: 57600, 115200, 230400 or 460800 */
101#define DEFAULT_BAUD_RATE 230400 99#define DEFAULT_BAUD_RATE 230400
@@ -890,8 +888,7 @@ static dev_link_t *bluecard_attach(void)
890 link->conf.IntType = INT_MEMORY_AND_IO; 888 link->conf.IntType = INT_MEMORY_AND_IO;
891 889
892 /* Register with Card Services */ 890 /* Register with Card Services */
893 link->next = dev_list; 891 link->next = NULL;
894 dev_list = link;
895 client_reg.dev_info = &dev_info; 892 client_reg.dev_info = &dev_info;
896 client_reg.Version = 0x0210; 893 client_reg.Version = 0x0210;
897 client_reg.event_callback_args.client_data = link; 894 client_reg.event_callback_args.client_data = link;
@@ -911,22 +908,10 @@ static void bluecard_detach(struct pcmcia_device *p_dev)
911{ 908{
912 dev_link_t *link = dev_to_instance(p_dev); 909 dev_link_t *link = dev_to_instance(p_dev);
913 bluecard_info_t *info = link->priv; 910 bluecard_info_t *info = link->priv;
914 dev_link_t **linkp;
915
916 /* Locate device structure */
917 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
918 if (*linkp == link)
919 break;
920
921 if (*linkp == NULL)
922 return;
923 911
924 if (link->state & DEV_CONFIG) 912 if (link->state & DEV_CONFIG)
925 bluecard_release(link); 913 bluecard_release(link);
926 914
927 /* Unlink device structure, free bits */
928 *linkp = link->next;
929
930 kfree(info); 915 kfree(info);
931} 916}
932 917
@@ -1105,7 +1090,6 @@ static int __init init_bluecard_cs(void)
1105static void __exit exit_bluecard_cs(void) 1090static void __exit exit_bluecard_cs(void)
1106{ 1091{
1107 pcmcia_unregister_driver(&bluecard_driver); 1092 pcmcia_unregister_driver(&bluecard_driver);
1108 BUG_ON(dev_list != NULL);
1109} 1093}
1110 1094
1111module_init(init_bluecard_cs); 1095module_init(init_bluecard_cs);
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 02ce38e33d32..50aa52b3cd20 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -97,8 +97,6 @@ static dev_info_t dev_info = "bt3c_cs";
97static dev_link_t *bt3c_attach(void); 97static dev_link_t *bt3c_attach(void);
98static void bt3c_detach(struct pcmcia_device *p_dev); 98static void bt3c_detach(struct pcmcia_device *p_dev);
99 99
100static dev_link_t *dev_list = NULL;
101
102 100
103/* Transmit states */ 101/* Transmit states */
104#define XMIT_SENDING 1 102#define XMIT_SENDING 1
@@ -691,8 +689,7 @@ static dev_link_t *bt3c_attach(void)
691 link->conf.IntType = INT_MEMORY_AND_IO; 689 link->conf.IntType = INT_MEMORY_AND_IO;
692 690
693 /* Register with Card Services */ 691 /* Register with Card Services */
694 link->next = dev_list; 692 link->next = NULL;
695 dev_list = link;
696 client_reg.dev_info = &dev_info; 693 client_reg.dev_info = &dev_info;
697 client_reg.Version = 0x0210; 694 client_reg.Version = 0x0210;
698 client_reg.event_callback_args.client_data = link; 695 client_reg.event_callback_args.client_data = link;
@@ -712,22 +709,10 @@ static void bt3c_detach(struct pcmcia_device *p_dev)
712{ 709{
713 dev_link_t *link = dev_to_instance(p_dev); 710 dev_link_t *link = dev_to_instance(p_dev);
714 bt3c_info_t *info = link->priv; 711 bt3c_info_t *info = link->priv;
715 dev_link_t **linkp;
716
717 /* Locate device structure */
718 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
719 if (*linkp == link)
720 break;
721
722 if (*linkp == NULL)
723 return;
724 712
725 if (link->state & DEV_CONFIG) 713 if (link->state & DEV_CONFIG)
726 bt3c_release(link); 714 bt3c_release(link);
727 715
728 /* Unlink device structure, free bits */
729 *linkp = link->next;
730
731 kfree(info); 716 kfree(info);
732} 717}
733 718
@@ -949,7 +934,6 @@ static int __init init_bt3c_cs(void)
949static void __exit exit_bt3c_cs(void) 934static void __exit exit_bt3c_cs(void)
950{ 935{
951 pcmcia_unregister_driver(&bt3c_driver); 936 pcmcia_unregister_driver(&bt3c_driver);
952 BUG_ON(dev_list != NULL);
953} 937}
954 938
955module_init(init_bt3c_cs); 939module_init(init_bt3c_cs);
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 63221d383fda..7b04f89f7a71 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -93,8 +93,6 @@ static dev_info_t dev_info = "btuart_cs";
93static dev_link_t *btuart_attach(void); 93static dev_link_t *btuart_attach(void);
94static void btuart_detach(struct pcmcia_device *p_dev); 94static void btuart_detach(struct pcmcia_device *p_dev);
95 95
96static dev_link_t *dev_list = NULL;
97
98 96
99/* Maximum baud rate */ 97/* Maximum baud rate */
100#define SPEED_MAX 115200 98#define SPEED_MAX 115200
@@ -610,8 +608,7 @@ static dev_link_t *btuart_attach(void)
610 link->conf.IntType = INT_MEMORY_AND_IO; 608 link->conf.IntType = INT_MEMORY_AND_IO;
611 609
612 /* Register with Card Services */ 610 /* Register with Card Services */
613 link->next = dev_list; 611 link->next = NULL;
614 dev_list = link;
615 client_reg.dev_info = &dev_info; 612 client_reg.dev_info = &dev_info;
616 client_reg.Version = 0x0210; 613 client_reg.Version = 0x0210;
617 client_reg.event_callback_args.client_data = link; 614 client_reg.event_callback_args.client_data = link;
@@ -631,22 +628,10 @@ static void btuart_detach(struct pcmcia_device *p_dev)
631{ 628{
632 dev_link_t *link = dev_to_instance(p_dev); 629 dev_link_t *link = dev_to_instance(p_dev);
633 btuart_info_t *info = link->priv; 630 btuart_info_t *info = link->priv;
634 dev_link_t **linkp;
635
636 /* Locate device structure */
637 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
638 if (*linkp == link)
639 break;
640
641 if (*linkp == NULL)
642 return;
643 631
644 if (link->state & DEV_CONFIG) 632 if (link->state & DEV_CONFIG)
645 btuart_release(link); 633 btuart_release(link);
646 634
647 /* Unlink device structure, free bits */
648 *linkp = link->next;
649
650 kfree(info); 635 kfree(info);
651} 636}
652 637
@@ -870,7 +855,6 @@ static int __init init_btuart_cs(void)
870static void __exit exit_btuart_cs(void) 855static void __exit exit_btuart_cs(void)
871{ 856{
872 pcmcia_unregister_driver(&btuart_driver); 857 pcmcia_unregister_driver(&btuart_driver);
873 BUG_ON(dev_list != NULL);
874} 858}
875 859
876module_init(init_btuart_cs); 860module_init(init_btuart_cs);
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 2874d8722be9..c39d4576cfff 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -96,8 +96,6 @@ static dev_info_t dev_info = "dtl1_cs";
96static dev_link_t *dtl1_attach(void); 96static dev_link_t *dtl1_attach(void);
97static void dtl1_detach(struct pcmcia_device *p_dev); 97static void dtl1_detach(struct pcmcia_device *p_dev);
98 98
99static dev_link_t *dev_list = NULL;
100
101 99
102/* Transmit states */ 100/* Transmit states */
103#define XMIT_SENDING 1 101#define XMIT_SENDING 1
@@ -589,8 +587,7 @@ static dev_link_t *dtl1_attach(void)
589 link->conf.IntType = INT_MEMORY_AND_IO; 587 link->conf.IntType = INT_MEMORY_AND_IO;
590 588
591 /* Register with Card Services */ 589 /* Register with Card Services */
592 link->next = dev_list; 590 link->next = NULL;
593 dev_list = link;
594 client_reg.dev_info = &dev_info; 591 client_reg.dev_info = &dev_info;
595 client_reg.Version = 0x0210; 592 client_reg.Version = 0x0210;
596 client_reg.event_callback_args.client_data = link; 593 client_reg.event_callback_args.client_data = link;
@@ -610,22 +607,10 @@ static void dtl1_detach(struct pcmcia_device *p_dev)
610{ 607{
611 dev_link_t *link = dev_to_instance(p_dev); 608 dev_link_t *link = dev_to_instance(p_dev);
612 dtl1_info_t *info = link->priv; 609 dtl1_info_t *info = link->priv;
613 dev_link_t **linkp;
614
615 /* Locate device structure */
616 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
617 if (*linkp == link)
618 break;
619
620 if (*linkp == NULL)
621 return;
622 610
623 if (link->state & DEV_CONFIG) 611 if (link->state & DEV_CONFIG)
624 dtl1_release(link); 612 dtl1_release(link);
625 613
626 /* Unlink device structure, free bits */
627 *linkp = link->next;
628
629 kfree(info); 614 kfree(info);
630} 615}
631 616
@@ -822,7 +807,6 @@ static int __init init_dtl1_cs(void)
822static void __exit exit_dtl1_cs(void) 807static void __exit exit_dtl1_cs(void)
823{ 808{
824 pcmcia_unregister_driver(&dtl1_driver); 809 pcmcia_unregister_driver(&dtl1_driver);
825 BUG_ON(dev_list != NULL);
826} 810}
827 811
828module_init(init_dtl1_cs); 812module_init(init_dtl1_cs);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 34597144d9c1..dc38b1d0a725 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -492,7 +492,6 @@ static dev_link_t *mgslpc_attach(void);
492static void mgslpc_detach(struct pcmcia_device *p_dev); 492static void mgslpc_detach(struct pcmcia_device *p_dev);
493 493
494static dev_info_t dev_info = "synclink_cs"; 494static dev_info_t dev_info = "synclink_cs";
495static dev_link_t *dev_list = NULL;
496 495
497/* 496/*
498 * 1st function defined in .text section. Calling this function in 497 * 1st function defined in .text section. Calling this function in
@@ -588,8 +587,7 @@ static dev_link_t *mgslpc_attach(void)
588 link->conf.IntType = INT_MEMORY_AND_IO; 587 link->conf.IntType = INT_MEMORY_AND_IO;
589 588
590 /* Register with Card Services */ 589 /* Register with Card Services */
591 link->next = dev_list; 590 link->next = NULL;
592 dev_list = link;
593 591
594 client_reg.dev_info = &dev_info; 592 client_reg.dev_info = &dev_info;
595 client_reg.Version = 0x0210; 593 client_reg.Version = 0x0210;
@@ -741,24 +739,15 @@ static void mgslpc_release(u_long arg)
741static void mgslpc_detach(struct pcmcia_device *p_dev) 739static void mgslpc_detach(struct pcmcia_device *p_dev)
742{ 740{
743 dev_link_t *link = dev_to_instance(p_dev); 741 dev_link_t *link = dev_to_instance(p_dev);
744 dev_link_t **linkp;
745 742
746 if (debug_level >= DEBUG_LEVEL_INFO) 743 if (debug_level >= DEBUG_LEVEL_INFO)
747 printk("mgslpc_detach(0x%p)\n", link); 744 printk("mgslpc_detach(0x%p)\n", link);
748 745
749 /* find device */
750 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
751 if (*linkp == link) break;
752 if (*linkp == NULL)
753 return;
754
755 if (link->state & DEV_CONFIG) { 746 if (link->state & DEV_CONFIG) {
756 ((MGSLPC_INFO *)link->priv)->stop = 1; 747 ((MGSLPC_INFO *)link->priv)->stop = 1;
757 mgslpc_release((u_long)link); 748 mgslpc_release((u_long)link);
758 } 749 }
759 750
760 /* Unlink device structure, and free it */
761 *linkp = link->next;
762 mgslpc_remove_device((MGSLPC_INFO *)link->priv); 751 mgslpc_remove_device((MGSLPC_INFO *)link->priv);
763} 752}
764 753
@@ -3131,7 +3120,6 @@ static void synclink_cs_cleanup(void)
3131 } 3120 }
3132 3121
3133 pcmcia_unregister_driver(&mgslpc_driver); 3122 pcmcia_unregister_driver(&mgslpc_driver);
3134 BUG_ON(dev_list != NULL);
3135} 3123}
3136 3124
3137static int __init synclink_cs_init(void) 3125static int __init synclink_cs_init(void)
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 1fb8976496d9..c83068dd42a0 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -96,7 +96,8 @@ static dev_info_t dev_info = "ide-cs";
96static dev_link_t *ide_attach(void); 96static dev_link_t *ide_attach(void);
97static void ide_detach(struct pcmcia_device *p_dev); 97static void ide_detach(struct pcmcia_device *p_dev);
98 98
99static dev_link_t *dev_list = NULL; 99
100
100 101
101/*====================================================================== 102/*======================================================================
102 103
@@ -130,8 +131,7 @@ static dev_link_t *ide_attach(void)
130 link->conf.IntType = INT_MEMORY_AND_IO; 131 link->conf.IntType = INT_MEMORY_AND_IO;
131 132
132 /* Register with Card Services */ 133 /* Register with Card Services */
133 link->next = dev_list; 134 link->next = NULL;
134 dev_list = link;
135 client_reg.dev_info = &dev_info; 135 client_reg.dev_info = &dev_info;
136 client_reg.Version = 0x0210; 136 client_reg.Version = 0x0210;
137 client_reg.event_callback_args.client_data = link; 137 client_reg.event_callback_args.client_data = link;
@@ -157,23 +157,13 @@ static dev_link_t *ide_attach(void)
157static void ide_detach(struct pcmcia_device *p_dev) 157static void ide_detach(struct pcmcia_device *p_dev)
158{ 158{
159 dev_link_t *link = dev_to_instance(p_dev); 159 dev_link_t *link = dev_to_instance(p_dev);
160 dev_link_t **linkp;
161 160
162 DEBUG(0, "ide_detach(0x%p)\n", link); 161 DEBUG(0, "ide_detach(0x%p)\n", link);
163
164 /* Locate device structure */
165 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
166 if (*linkp == link) break;
167 if (*linkp == NULL)
168 return;
169 162
170 if (link->state & DEV_CONFIG) 163 if (link->state & DEV_CONFIG)
171 ide_release(link); 164 ide_release(link);
172 165
173 /* Unlink, free device structure */
174 *linkp = link->next;
175 kfree(link->priv); 166 kfree(link->priv);
176
177} /* ide_detach */ 167} /* ide_detach */
178 168
179static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) 169static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle)
@@ -507,7 +497,6 @@ static int __init init_ide_cs(void)
507static void __exit exit_ide_cs(void) 497static void __exit exit_ide_cs(void)
508{ 498{
509 pcmcia_unregister_driver(&ide_cs_driver); 499 pcmcia_unregister_driver(&ide_cs_driver);
510 BUG_ON(dev_list != NULL);
511} 500}
512 501
513late_initcall(init_ide_cs); 502late_initcall(init_ide_cs);
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 2d898d3afc97..0a8c1da10b4b 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -83,15 +83,7 @@ static dev_info_t dev_info = "avm_cs";
83 device numbers are used to derive the corresponding array index. 83 device numbers are used to derive the corresponding array index.
84*/ 84*/
85 85
86static dev_link_t *dev_list = NULL;
87
88/* 86/*
89 A dev_link_t structure has fields for most things that are needed
90 to keep track of a socket, but there will usually be some device
91 specific information that also needs to be kept track of. The
92 'priv' pointer in a dev_link_t structure can be used to point to
93 a device-specific private data structure, like this.
94
95 A driver needs to provide a dev_node_t structure for each device 87 A driver needs to provide a dev_node_t structure for each device
96 on a card. In some cases, there is only one device per card (for 88 on a card. In some cases, there is only one device per card (for
97 example, ethernet cards, modems). In other cases, there may be 89 example, ethernet cards, modems). In other cases, there may be
@@ -157,8 +149,7 @@ static dev_link_t *avmcs_attach(void)
157 link->priv = local; 149 link->priv = local;
158 150
159 /* Register with Card Services */ 151 /* Register with Card Services */
160 link->next = dev_list; 152 link->next = NULL;
161 dev_list = link;
162 client_reg.dev_info = &dev_info; 153 client_reg.dev_info = &dev_info;
163 client_reg.Version = 0x0210; 154 client_reg.Version = 0x0210;
164 client_reg.event_callback_args.client_data = link; 155 client_reg.event_callback_args.client_data = link;
@@ -188,19 +179,10 @@ static dev_link_t *avmcs_attach(void)
188static void avmcs_detach(struct pcmcia_device *p_dev) 179static void avmcs_detach(struct pcmcia_device *p_dev)
189{ 180{
190 dev_link_t *link = dev_to_instance(p_dev); 181 dev_link_t *link = dev_to_instance(p_dev);
191 dev_link_t **linkp;
192
193 /* Locate device structure */
194 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
195 if (*linkp == link) break;
196 if (*linkp == NULL)
197 return;
198 182
199 if (link->state & DEV_CONFIG) 183 if (link->state & DEV_CONFIG)
200 avmcs_release(link); 184 avmcs_release(link);
201 185
202 /* Unlink device structure, free pieces */
203 *linkp = link->next;
204 kfree(link->priv); 186 kfree(link->priv);
205 kfree(link); 187 kfree(link);
206} /* avmcs_detach */ 188} /* avmcs_detach */
@@ -494,7 +476,6 @@ static int __init avmcs_init(void)
494static void __exit avmcs_exit(void) 476static void __exit avmcs_exit(void)
495{ 477{
496 pcmcia_unregister_driver(&avmcs_driver); 478 pcmcia_unregister_driver(&avmcs_driver);
497 BUG_ON(dev_list != NULL);
498} 479}
499 480
500module_init(avmcs_init); 481module_init(avmcs_init);
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 6b322e88c6c3..b6ea653f881e 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -99,15 +99,7 @@ static dev_info_t dev_info = "avma1_cs";
99 device numbers are used to derive the corresponding array index. 99 device numbers are used to derive the corresponding array index.
100*/ 100*/
101 101
102static dev_link_t *dev_list = NULL;
103
104/* 102/*
105 A dev_link_t structure has fields for most things that are needed
106 to keep track of a socket, but there will usually be some device
107 specific information that also needs to be kept track of. The
108 'priv' pointer in a dev_link_t structure can be used to point to
109 a device-specific private data structure, like this.
110
111 A driver needs to provide a dev_node_t structure for each device 103 A driver needs to provide a dev_node_t structure for each device
112 on a card. In some cases, there is only one device per card (for 104 on a card. In some cases, there is only one device per card (for
113 example, ethernet cards, modems). In other cases, there may be 105 example, ethernet cards, modems). In other cases, there may be
@@ -179,8 +171,7 @@ static dev_link_t *avma1cs_attach(void)
179 link->conf.Present = PRESENT_OPTION; 171 link->conf.Present = PRESENT_OPTION;
180 172
181 /* Register with Card Services */ 173 /* Register with Card Services */
182 link->next = dev_list; 174 link->next = NULL;
183 dev_list = link;
184 client_reg.dev_info = &dev_info; 175 client_reg.dev_info = &dev_info;
185 client_reg.Version = 0x0210; 176 client_reg.Version = 0x0210;
186 client_reg.event_callback_args.client_data = link; 177 client_reg.event_callback_args.client_data = link;
@@ -206,21 +197,12 @@ static dev_link_t *avma1cs_attach(void)
206static void avma1cs_detach(struct pcmcia_device *p_dev) 197static void avma1cs_detach(struct pcmcia_device *p_dev)
207{ 198{
208 dev_link_t *link = dev_to_instance(p_dev); 199 dev_link_t *link = dev_to_instance(p_dev);
209 dev_link_t **linkp;
210 200
211 DEBUG(0, "avma1cs_detach(0x%p)\n", link); 201 DEBUG(0, "avma1cs_detach(0x%p)\n", link);
212 202
213 /* Locate device structure */
214 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
215 if (*linkp == link) break;
216 if (*linkp == NULL)
217 return;
218
219 if (link->state & DEV_CONFIG) 203 if (link->state & DEV_CONFIG)
220 avma1cs_release(link); 204 avma1cs_release(link);
221 205
222 /* Unlink device structure, free pieces */
223 *linkp = link->next;
224 kfree(link->priv); 206 kfree(link->priv);
225 kfree(link); 207 kfree(link);
226} /* avma1cs_detach */ 208} /* avma1cs_detach */
@@ -508,7 +490,6 @@ static int __init init_avma1_cs(void)
508static void __exit exit_avma1_cs(void) 490static void __exit exit_avma1_cs(void)
509{ 491{
510 pcmcia_unregister_driver(&avma1cs_driver); 492 pcmcia_unregister_driver(&avma1cs_driver);
511 BUG_ON(dev_list != NULL);
512} 493}
513 494
514module_init(init_avma1_cs); 495module_init(init_avma1_cs);
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index 48cc677249f1..a0c5bad7bc6b 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -126,18 +126,7 @@ static dev_info_t dev_info = "elsa_cs";
126 device numbers are used to derive the corresponding array index. 126 device numbers are used to derive the corresponding array index.
127*/ 127*/
128 128
129static dev_link_t *dev_list = NULL;
130
131/* 129/*
132 A dev_link_t structure has fields for most things that are needed
133 to keep track of a socket, but there will usually be some device
134 specific information that also needs to be kept track of. The
135 'priv' pointer in a dev_link_t structure can be used to point to
136 a device-specific private data structure, like this.
137
138 To simplify the data structure handling, we actually include the
139 dev_link_t structure in the device's private data structure.
140
141 A driver needs to provide a dev_node_t structure for each device 130 A driver needs to provide a dev_node_t structure for each device
142 on a card. In some cases, there is only one device per card (for 131 on a card. In some cases, there is only one device per card (for
143 example, ethernet cards, modems). In other cases, there may be 132 example, ethernet cards, modems). In other cases, there may be
@@ -208,8 +197,7 @@ static dev_link_t *elsa_cs_attach(void)
208 link->conf.IntType = INT_MEMORY_AND_IO; 197 link->conf.IntType = INT_MEMORY_AND_IO;
209 198
210 /* Register with Card Services */ 199 /* Register with Card Services */
211 link->next = dev_list; 200 link->next = NULL;
212 dev_list = link;
213 client_reg.dev_info = &dev_info; 201 client_reg.dev_info = &dev_info;
214 client_reg.Version = 0x0210; 202 client_reg.Version = 0x0210;
215 client_reg.event_callback_args.client_data = link; 203 client_reg.event_callback_args.client_data = link;
@@ -235,24 +223,15 @@ static dev_link_t *elsa_cs_attach(void)
235static void elsa_cs_detach(struct pcmcia_device *p_dev) 223static void elsa_cs_detach(struct pcmcia_device *p_dev)
236{ 224{
237 dev_link_t *link = dev_to_instance(p_dev); 225 dev_link_t *link = dev_to_instance(p_dev);
238 dev_link_t **linkp;
239 local_info_t *info = link->priv; 226 local_info_t *info = link->priv;
240 227
241 DEBUG(0, "elsa_cs_detach(0x%p)\n", link); 228 DEBUG(0, "elsa_cs_detach(0x%p)\n", link);
242 229
243 /* Locate device structure */
244 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
245 if (*linkp == link) break;
246 if (*linkp == NULL)
247 return;
248
249 if (link->state & DEV_CONFIG) { 230 if (link->state & DEV_CONFIG) {
250 ((local_info_t*)link->priv)->busy = 1; 231 info->busy = 1;
251 elsa_cs_release(link); 232 elsa_cs_release(link);
252 } 233 }
253 234
254 /* Unlink device structure and free it */
255 *linkp = link->next;
256 kfree(info); 235 kfree(info);
257 236
258} /* elsa_cs_detach */ 237} /* elsa_cs_detach */
@@ -526,7 +505,6 @@ static int __init init_elsa_cs(void)
526static void __exit exit_elsa_cs(void) 505static void __exit exit_elsa_cs(void)
527{ 506{
528 pcmcia_unregister_driver(&elsa_cs_driver); 507 pcmcia_unregister_driver(&elsa_cs_driver);
529 BUG_ON(dev_list != NULL);
530} 508}
531 509
532module_init(init_elsa_cs); 510module_init(init_elsa_cs);
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index d2386f6867b7..814b32a9ef3b 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -134,18 +134,7 @@ static dev_info_t dev_info = "sedlbauer_cs";
134 device numbers are used to derive the corresponding array index. 134 device numbers are used to derive the corresponding array index.
135*/ 135*/
136 136
137static dev_link_t *dev_list = NULL;
138
139/* 137/*
140 A dev_link_t structure has fields for most things that are needed
141 to keep track of a socket, but there will usually be some device
142 specific information that also needs to be kept track of. The
143 'priv' pointer in a dev_link_t structure can be used to point to
144 a device-specific private data structure, like this.
145
146 To simplify the data structure handling, we actually include the
147 dev_link_t structure in the device's private data structure.
148
149 A driver needs to provide a dev_node_t structure for each device 138 A driver needs to provide a dev_node_t structure for each device
150 on a card. In some cases, there is only one device per card (for 139 on a card. In some cases, there is only one device per card (for
151 example, ethernet cards, modems). In other cases, there may be 140 example, ethernet cards, modems). In other cases, there may be
@@ -222,8 +211,7 @@ static dev_link_t *sedlbauer_attach(void)
222 link->conf.IntType = INT_MEMORY_AND_IO; 211 link->conf.IntType = INT_MEMORY_AND_IO;
223 212
224 /* Register with Card Services */ 213 /* Register with Card Services */
225 link->next = dev_list; 214 link->next = NULL;
226 dev_list = link;
227 client_reg.dev_info = &dev_info; 215 client_reg.dev_info = &dev_info;
228 client_reg.Version = 0x0210; 216 client_reg.Version = 0x0210;
229 client_reg.event_callback_args.client_data = link; 217 client_reg.event_callback_args.client_data = link;
@@ -249,23 +237,14 @@ static dev_link_t *sedlbauer_attach(void)
249static void sedlbauer_detach(struct pcmcia_device *p_dev) 237static void sedlbauer_detach(struct pcmcia_device *p_dev)
250{ 238{
251 dev_link_t *link = dev_to_instance(p_dev); 239 dev_link_t *link = dev_to_instance(p_dev);
252 dev_link_t **linkp;
253 240
254 DEBUG(0, "sedlbauer_detach(0x%p)\n", link); 241 DEBUG(0, "sedlbauer_detach(0x%p)\n", link);
255
256 /* Locate device structure */
257 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
258 if (*linkp == link) break;
259 if (*linkp == NULL)
260 return;
261 242
262 if (link->state & DEV_CONFIG) { 243 if (link->state & DEV_CONFIG) {
263 ((local_info_t *)link->priv)->stop = 1; 244 ((local_info_t *)link->priv)->stop = 1;
264 sedlbauer_release(link); 245 sedlbauer_release(link);
265 } 246 }
266 247
267 /* Unlink device structure, and free it */
268 *linkp = link->next;
269 /* This points to the parent local_info_t struct */ 248 /* This points to the parent local_info_t struct */
270 kfree(link->priv); 249 kfree(link->priv);
271} /* sedlbauer_detach */ 250} /* sedlbauer_detach */
@@ -623,7 +602,6 @@ static int __init init_sedlbauer_cs(void)
623static void __exit exit_sedlbauer_cs(void) 602static void __exit exit_sedlbauer_cs(void)
624{ 603{
625 pcmcia_unregister_driver(&sedlbauer_driver); 604 pcmcia_unregister_driver(&sedlbauer_driver);
626 BUG_ON(dev_list != NULL);
627} 605}
628 606
629module_init(init_sedlbauer_cs); 607module_init(init_sedlbauer_cs);
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index cd0f86f0975b..f956fceb9db2 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -107,18 +107,7 @@ static dev_info_t dev_info = "teles_cs";
107 device numbers are used to derive the corresponding array index. 107 device numbers are used to derive the corresponding array index.
108*/ 108*/
109 109
110static dev_link_t *dev_list = NULL;
111
112/* 110/*
113 A dev_link_t structure has fields for most things that are needed
114 to keep track of a socket, but there will usually be some device
115 specific information that also needs to be kept track of. The
116 'priv' pointer in a dev_link_t structure can be used to point to
117 a device-specific private data structure, like this.
118
119 To simplify the data structure handling, we actually include the
120 dev_link_t structure in the device's private data structure.
121
122 A driver needs to provide a dev_node_t structure for each device 111 A driver needs to provide a dev_node_t structure for each device
123 on a card. In some cases, there is only one device per card (for 112 on a card. In some cases, there is only one device per card (for
124 example, ethernet cards, modems). In other cases, there may be 113 example, ethernet cards, modems). In other cases, there may be
@@ -189,8 +178,7 @@ static dev_link_t *teles_attach(void)
189 link->conf.IntType = INT_MEMORY_AND_IO; 178 link->conf.IntType = INT_MEMORY_AND_IO;
190 179
191 /* Register with Card Services */ 180 /* Register with Card Services */
192 link->next = dev_list; 181 link->next = NULL;
193 dev_list = link;
194 client_reg.dev_info = &dev_info; 182 client_reg.dev_info = &dev_info;
195 client_reg.Version = 0x0210; 183 client_reg.Version = 0x0210;
196 client_reg.event_callback_args.client_data = link; 184 client_reg.event_callback_args.client_data = link;
@@ -216,24 +204,15 @@ static dev_link_t *teles_attach(void)
216static void teles_detach(struct pcmcia_device *p_dev) 204static void teles_detach(struct pcmcia_device *p_dev)
217{ 205{
218 dev_link_t *link = dev_to_instance(p_dev); 206 dev_link_t *link = dev_to_instance(p_dev);
219 dev_link_t **linkp;
220 local_info_t *info = link->priv; 207 local_info_t *info = link->priv;
221 208
222 DEBUG(0, "teles_detach(0x%p)\n", link); 209 DEBUG(0, "teles_detach(0x%p)\n", link);
223 210
224 /* Locate device structure */
225 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
226 if (*linkp == link) break;
227 if (*linkp == NULL)
228 return;
229
230 if (link->state & DEV_CONFIG) { 211 if (link->state & DEV_CONFIG) {
231 info->busy = 1; 212 info->busy = 1;
232 teles_cs_release(link); 213 teles_cs_release(link);
233 } 214 }
234 215
235 /* Unlink device structure and free it */
236 *linkp = link->next;
237 kfree(info); 216 kfree(info);
238 217
239} /* teles_detach */ 218} /* teles_detach */
@@ -506,7 +485,6 @@ static int __init init_teles_cs(void)
506static void __exit exit_teles_cs(void) 485static void __exit exit_teles_cs(void)
507{ 486{
508 pcmcia_unregister_driver(&teles_cs_driver); 487 pcmcia_unregister_driver(&teles_cs_driver);
509 BUG_ON(dev_list != NULL);
510} 488}
511 489
512module_init(init_teles_cs); 490module_init(init_teles_cs);
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 3ddcb1bf6824..93c05dfa030d 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -67,7 +67,6 @@ struct pcmciamtd_dev {
67 67
68 68
69static dev_info_t dev_info = "pcmciamtd"; 69static dev_info_t dev_info = "pcmciamtd";
70static dev_link_t *dev_list;
71 70
72/* Module parameters */ 71/* Module parameters */
73 72
@@ -782,8 +781,7 @@ static dev_link_t *pcmciamtd_attach(void)
782 link->conf.Attributes = 0; 781 link->conf.Attributes = 0;
783 link->conf.IntType = INT_MEMORY; 782 link->conf.IntType = INT_MEMORY;
784 783
785 link->next = dev_list; 784 link->next = NULL;
786 dev_list = link;
787 785
788 /* Register with Card Services */ 786 /* Register with Card Services */
789 client_reg.dev_info = &dev_info; 787 client_reg.dev_info = &dev_info;
@@ -865,7 +863,6 @@ static void __exit exit_pcmciamtd(void)
865{ 863{
866 DEBUG(1, DRIVER_DESC " unloading"); 864 DEBUG(1, DRIVER_DESC " unloading");
867 pcmcia_unregister_driver(&pcmciamtd_driver); 865 pcmcia_unregister_driver(&pcmciamtd_driver);
868 BUG_ON(dev_list != NULL);
869} 866}
870 867
871module_init(init_pcmciamtd); 868module_init(init_pcmciamtd);
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 60a3bc2b8fc4..8fcb63698ef1 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -255,8 +255,6 @@ static dev_info_t dev_info = "3c574_cs";
255static dev_link_t *tc574_attach(void); 255static dev_link_t *tc574_attach(void);
256static void tc574_detach(struct pcmcia_device *p_dev); 256static void tc574_detach(struct pcmcia_device *p_dev);
257 257
258static dev_link_t *dev_list;
259
260/* 258/*
261 tc574_attach() creates an "instance" of the driver, allocating 259 tc574_attach() creates an "instance" of the driver, allocating
262 local data structures for one device. The device is registered 260 local data structures for one device. The device is registered
@@ -308,8 +306,7 @@ static dev_link_t *tc574_attach(void)
308#endif 306#endif
309 307
310 /* Register with Card Services */ 308 /* Register with Card Services */
311 link->next = dev_list; 309 link->next = NULL;
312 dev_list = link;
313 client_reg.dev_info = &dev_info; 310 client_reg.dev_info = &dev_info;
314 client_reg.Version = 0x0210; 311 client_reg.Version = 0x0210;
315 client_reg.event_callback_args.client_data = link; 312 client_reg.event_callback_args.client_data = link;
@@ -336,24 +333,15 @@ static void tc574_detach(struct pcmcia_device *p_dev)
336{ 333{
337 dev_link_t *link = dev_to_instance(p_dev); 334 dev_link_t *link = dev_to_instance(p_dev);
338 struct net_device *dev = link->priv; 335 struct net_device *dev = link->priv;
339 dev_link_t **linkp;
340 336
341 DEBUG(0, "3c574_detach(0x%p)\n", link); 337 DEBUG(0, "3c574_detach(0x%p)\n", link);
342 338
343 /* Locate device structure */
344 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
345 if (*linkp == link) break;
346 if (*linkp == NULL)
347 return;
348
349 if (link->dev) 339 if (link->dev)
350 unregister_netdev(dev); 340 unregister_netdev(dev);
351 341
352 if (link->state & DEV_CONFIG) 342 if (link->state & DEV_CONFIG)
353 tc574_release(link); 343 tc574_release(link);
354 344
355 /* Unlink device structure, free bits */
356 *linkp = link->next;
357 free_netdev(dev); 345 free_netdev(dev);
358} /* tc574_detach */ 346} /* tc574_detach */
359 347
@@ -1310,7 +1298,6 @@ static int __init init_tc574(void)
1310static void __exit exit_tc574(void) 1298static void __exit exit_tc574(void)
1311{ 1299{
1312 pcmcia_unregister_driver(&tc574_driver); 1300 pcmcia_unregister_driver(&tc574_driver);
1313 BUG_ON(dev_list != NULL);
1314} 1301}
1315 1302
1316module_init(init_tc574); 1303module_init(init_tc574);
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 09b96c76216e..3516c02b9c89 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -166,8 +166,6 @@ static dev_info_t dev_info = "3c589_cs";
166static dev_link_t *tc589_attach(void); 166static dev_link_t *tc589_attach(void);
167static void tc589_detach(struct pcmcia_device *p_dev); 167static void tc589_detach(struct pcmcia_device *p_dev);
168 168
169static dev_link_t *dev_list;
170
171/*====================================================================== 169/*======================================================================
172 170
173 tc589_attach() creates an "instance" of the driver, allocating 171 tc589_attach() creates an "instance" of the driver, allocating
@@ -222,8 +220,7 @@ static dev_link_t *tc589_attach(void)
222 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 220 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
223 221
224 /* Register with Card Services */ 222 /* Register with Card Services */
225 link->next = dev_list; 223 link->next = NULL;
226 dev_list = link;
227 client_reg.dev_info = &dev_info; 224 client_reg.dev_info = &dev_info;
228 client_reg.Version = 0x0210; 225 client_reg.Version = 0x0210;
229 client_reg.event_callback_args.client_data = link; 226 client_reg.event_callback_args.client_data = link;
@@ -250,15 +247,8 @@ static void tc589_detach(struct pcmcia_device *p_dev)
250{ 247{
251 dev_link_t *link = dev_to_instance(p_dev); 248 dev_link_t *link = dev_to_instance(p_dev);
252 struct net_device *dev = link->priv; 249 struct net_device *dev = link->priv;
253 dev_link_t **linkp; 250
254
255 DEBUG(0, "3c589_detach(0x%p)\n", link); 251 DEBUG(0, "3c589_detach(0x%p)\n", link);
256
257 /* Locate device structure */
258 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
259 if (*linkp == link) break;
260 if (*linkp == NULL)
261 return;
262 252
263 if (link->dev) 253 if (link->dev)
264 unregister_netdev(dev); 254 unregister_netdev(dev);
@@ -266,8 +256,6 @@ static void tc589_detach(struct pcmcia_device *p_dev)
266 if (link->state & DEV_CONFIG) 256 if (link->state & DEV_CONFIG)
267 tc589_release(link); 257 tc589_release(link);
268 258
269 /* Unlink device structure, free bits */
270 *linkp = link->next;
271 free_netdev(dev); 259 free_netdev(dev);
272} /* tc589_detach */ 260} /* tc589_detach */
273 261
@@ -1085,7 +1073,6 @@ static int __init init_tc589(void)
1085static void __exit exit_tc589(void) 1073static void __exit exit_tc589(void)
1086{ 1074{
1087 pcmcia_unregister_driver(&tc589_driver); 1075 pcmcia_unregister_driver(&tc589_driver);
1088 BUG_ON(dev_list != NULL);
1089} 1076}
1090 1077
1091module_init(init_tc589); 1078module_init(init_tc589);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 11f701a8ff02..3d36207d3332 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -111,7 +111,6 @@ static dev_link_t *axnet_attach(void);
111static void axnet_detach(struct pcmcia_device *p_dev); 111static void axnet_detach(struct pcmcia_device *p_dev);
112 112
113static dev_info_t dev_info = "axnet_cs"; 113static dev_info_t dev_info = "axnet_cs";
114static dev_link_t *dev_list;
115 114
116static void axdev_setup(struct net_device *dev); 115static void axdev_setup(struct net_device *dev);
117static void AX88190_init(struct net_device *dev, int startp); 116static void AX88190_init(struct net_device *dev, int startp);
@@ -177,8 +176,7 @@ static dev_link_t *axnet_attach(void)
177 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 176 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
178 177
179 /* Register with Card Services */ 178 /* Register with Card Services */
180 link->next = dev_list; 179 link->next = NULL;
181 dev_list = link;
182 client_reg.dev_info = &dev_info; 180 client_reg.dev_info = &dev_info;
183 client_reg.Version = 0x0210; 181 client_reg.Version = 0x0210;
184 client_reg.event_callback_args.client_data = link; 182 client_reg.event_callback_args.client_data = link;
@@ -205,24 +203,15 @@ static void axnet_detach(struct pcmcia_device *p_dev)
205{ 203{
206 dev_link_t *link = dev_to_instance(p_dev); 204 dev_link_t *link = dev_to_instance(p_dev);
207 struct net_device *dev = link->priv; 205 struct net_device *dev = link->priv;
208 dev_link_t **linkp;
209 206
210 DEBUG(0, "axnet_detach(0x%p)\n", link); 207 DEBUG(0, "axnet_detach(0x%p)\n", link);
211 208
212 /* Locate device structure */
213 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
214 if (*linkp == link) break;
215 if (*linkp == NULL)
216 return;
217
218 if (link->dev) 209 if (link->dev)
219 unregister_netdev(dev); 210 unregister_netdev(dev);
220 211
221 if (link->state & DEV_CONFIG) 212 if (link->state & DEV_CONFIG)
222 axnet_release(link); 213 axnet_release(link);
223 214
224 /* Unlink device structure, free bits */
225 *linkp = link->next;
226 free_netdev(dev); 215 free_netdev(dev);
227} /* axnet_detach */ 216} /* axnet_detach */
228 217
@@ -896,7 +885,6 @@ static int __init init_axnet_cs(void)
896static void __exit exit_axnet_cs(void) 885static void __exit exit_axnet_cs(void)
897{ 886{
898 pcmcia_unregister_driver(&axnet_cs_driver); 887 pcmcia_unregister_driver(&axnet_cs_driver);
899 BUG_ON(dev_list != NULL);
900} 888}
901 889
902module_init(init_axnet_cs); 890module_init(init_axnet_cs);
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 6970888cba10..d48dbd3e153a 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -128,8 +128,6 @@ static dev_info_t dev_info = "com20020_cs";
128static dev_link_t *com20020_attach(void); 128static dev_link_t *com20020_attach(void);
129static void com20020_detach(struct pcmcia_device *p_dev); 129static void com20020_detach(struct pcmcia_device *p_dev);
130 130
131static dev_link_t *dev_list;
132
133/*====================================================================*/ 131/*====================================================================*/
134 132
135typedef struct com20020_dev_t { 133typedef struct com20020_dev_t {
@@ -196,8 +194,7 @@ static dev_link_t *com20020_attach(void)
196 link->priv = info; 194 link->priv = info;
197 195
198 /* Register with Card Services */ 196 /* Register with Card Services */
199 link->next = dev_list; 197 link->next = NULL;
200 dev_list = link;
201 client_reg.dev_info = &dev_info; 198 client_reg.dev_info = &dev_info;
202 client_reg.Version = 0x0210; 199 client_reg.Version = 0x0210;
203 client_reg.event_callback_args.client_data = link; 200 client_reg.event_callback_args.client_data = link;
@@ -230,26 +227,17 @@ static void com20020_detach(struct pcmcia_device *p_dev)
230{ 227{
231 dev_link_t *link = dev_to_instance(p_dev); 228 dev_link_t *link = dev_to_instance(p_dev);
232 struct com20020_dev_t *info = link->priv; 229 struct com20020_dev_t *info = link->priv;
233 dev_link_t **linkp; 230 struct net_device *dev = info->dev;
234 struct net_device *dev; 231
235
236 DEBUG(1,"detach...\n"); 232 DEBUG(1,"detach...\n");
237 233
238 DEBUG(0, "com20020_detach(0x%p)\n", link); 234 DEBUG(0, "com20020_detach(0x%p)\n", link);
239 235
240 /* Locate device structure */
241 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
242 if (*linkp == link) break;
243 if (*linkp == NULL)
244 return;
245
246 dev = info->dev;
247
248 if (link->dev) { 236 if (link->dev) {
249 DEBUG(1,"unregister...\n"); 237 DEBUG(1,"unregister...\n");
250 238
251 unregister_netdev(dev); 239 unregister_netdev(dev);
252 240
253 /* 241 /*
254 * this is necessary because we register our IRQ separately 242 * this is necessary because we register our IRQ separately
255 * from card services. 243 * from card services.
@@ -263,7 +251,6 @@ static void com20020_detach(struct pcmcia_device *p_dev)
263 251
264 /* Unlink device structure, free bits */ 252 /* Unlink device structure, free bits */
265 DEBUG(1,"unlinking...\n"); 253 DEBUG(1,"unlinking...\n");
266 *linkp = link->next;
267 if (link->priv) 254 if (link->priv)
268 { 255 {
269 dev = info->dev; 256 dev = info->dev;
@@ -507,7 +494,6 @@ static int __init init_com20020_cs(void)
507static void __exit exit_com20020_cs(void) 494static void __exit exit_com20020_cs(void)
508{ 495{
509 pcmcia_unregister_driver(&com20020_cs_driver); 496 pcmcia_unregister_driver(&com20020_cs_driver);
510 BUG_ON(dev_list != NULL);
511} 497}
512 498
513module_init(init_com20020_cs); 499module_init(init_com20020_cs);
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 560d4ee22803..dad6393052ff 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -109,7 +109,6 @@ static void fjn_tx_timeout(struct net_device *dev);
109static struct ethtool_ops netdev_ethtool_ops; 109static struct ethtool_ops netdev_ethtool_ops;
110 110
111static dev_info_t dev_info = "fmvj18x_cs"; 111static dev_info_t dev_info = "fmvj18x_cs";
112static dev_link_t *dev_list;
113 112
114/* 113/*
115 card type 114 card type
@@ -283,8 +282,7 @@ static dev_link_t *fmvj18x_attach(void)
283 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 282 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
284 283
285 /* Register with Card Services */ 284 /* Register with Card Services */
286 link->next = dev_list; 285 link->next = NULL;
287 dev_list = link;
288 client_reg.dev_info = &dev_info; 286 client_reg.dev_info = &dev_info;
289 client_reg.Version = 0x0210; 287 client_reg.Version = 0x0210;
290 client_reg.event_callback_args.client_data = link; 288 client_reg.event_callback_args.client_data = link;
@@ -304,15 +302,8 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev)
304{ 302{
305 dev_link_t *link = dev_to_instance(p_dev); 303 dev_link_t *link = dev_to_instance(p_dev);
306 struct net_device *dev = link->priv; 304 struct net_device *dev = link->priv;
307 dev_link_t **linkp; 305
308
309 DEBUG(0, "fmvj18x_detach(0x%p)\n", link); 306 DEBUG(0, "fmvj18x_detach(0x%p)\n", link);
310
311 /* Locate device structure */
312 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
313 if (*linkp == link) break;
314 if (*linkp == NULL)
315 return;
316 307
317 if (link->dev) 308 if (link->dev)
318 unregister_netdev(dev); 309 unregister_netdev(dev);
@@ -320,8 +311,6 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev)
320 if (link->state & DEV_CONFIG) 311 if (link->state & DEV_CONFIG)
321 fmvj18x_release(link); 312 fmvj18x_release(link);
322 313
323 /* Unlink device structure, free pieces */
324 *linkp = link->next;
325 free_netdev(dev); 314 free_netdev(dev);
326} /* fmvj18x_detach */ 315} /* fmvj18x_detach */
327 316
@@ -807,7 +796,6 @@ static int __init init_fmvj18x_cs(void)
807static void __exit exit_fmvj18x_cs(void) 796static void __exit exit_fmvj18x_cs(void)
808{ 797{
809 pcmcia_unregister_driver(&fmvj18x_cs_driver); 798 pcmcia_unregister_driver(&fmvj18x_cs_driver);
810 BUG_ON(dev_list != NULL);
811} 799}
812 800
813module_init(init_fmvj18x_cs); 801module_init(init_fmvj18x_cs);
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 961294983354..90da35d1f4a5 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -116,8 +116,6 @@ static dev_info_t dev_info = "ibmtr_cs";
116static dev_link_t *ibmtr_attach(void); 116static dev_link_t *ibmtr_attach(void);
117static void ibmtr_detach(struct pcmcia_device *p_dev); 117static void ibmtr_detach(struct pcmcia_device *p_dev);
118 118
119static dev_link_t *dev_list;
120
121/*====================================================================*/ 119/*====================================================================*/
122 120
123typedef struct ibmtr_dev_t { 121typedef struct ibmtr_dev_t {
@@ -186,8 +184,7 @@ static dev_link_t *ibmtr_attach(void)
186 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 184 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
187 185
188 /* Register with Card Services */ 186 /* Register with Card Services */
189 link->next = dev_list; 187 link->next = NULL;
190 dev_list = link;
191 client_reg.dev_info = &dev_info; 188 client_reg.dev_info = &dev_info;
192 client_reg.Version = 0x0210; 189 client_reg.Version = 0x0210;
193 client_reg.event_callback_args.client_data = link; 190 client_reg.event_callback_args.client_data = link;
@@ -219,19 +216,10 @@ static void ibmtr_detach(struct pcmcia_device *p_dev)
219{ 216{
220 dev_link_t *link = dev_to_instance(p_dev); 217 dev_link_t *link = dev_to_instance(p_dev);
221 struct ibmtr_dev_t *info = link->priv; 218 struct ibmtr_dev_t *info = link->priv;
222 dev_link_t **linkp; 219 struct net_device *dev = info->dev;
223 struct net_device *dev;
224 220
225 DEBUG(0, "ibmtr_detach(0x%p)\n", link); 221 DEBUG(0, "ibmtr_detach(0x%p)\n", link);
226 222
227 /* Locate device structure */
228 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
229 if (*linkp == link) break;
230 if (*linkp == NULL)
231 return;
232
233 dev = info->dev;
234
235 if (link->dev) 223 if (link->dev)
236 unregister_netdev(dev); 224 unregister_netdev(dev);
237 225
@@ -242,10 +230,8 @@ static void ibmtr_detach(struct pcmcia_device *p_dev)
242 if (link->state & DEV_CONFIG) 230 if (link->state & DEV_CONFIG)
243 ibmtr_release(link); 231 ibmtr_release(link);
244 232
245 /* Unlink device structure, free bits */
246 *linkp = link->next;
247 free_netdev(dev); 233 free_netdev(dev);
248 kfree(info); 234 kfree(info);
249} /* ibmtr_detach */ 235} /* ibmtr_detach */
250 236
251/*====================================================================== 237/*======================================================================
@@ -530,7 +516,6 @@ static int __init init_ibmtr_cs(void)
530static void __exit exit_ibmtr_cs(void) 516static void __exit exit_ibmtr_cs(void)
531{ 517{
532 pcmcia_unregister_driver(&ibmtr_cs_driver); 518 pcmcia_unregister_driver(&ibmtr_cs_driver);
533 BUG_ON(dev_list != NULL);
534} 519}
535 520
536module_init(init_ibmtr_cs); 521module_init(init_ibmtr_cs);
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 011ceb090320..0c9cb9f49a81 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -389,7 +389,6 @@ DRV_NAME " " DRV_VERSION " (Roger C. Pao)";
389#endif 389#endif
390 390
391static dev_info_t dev_info="nmclan_cs"; 391static dev_info_t dev_info="nmclan_cs";
392static dev_link_t *dev_list;
393 392
394static char *if_names[]={ 393static char *if_names[]={
395 "Auto", "10baseT", "BNC", 394 "Auto", "10baseT", "BNC",
@@ -498,8 +497,7 @@ static dev_link_t *nmclan_attach(void)
498#endif 497#endif
499 498
500 /* Register with Card Services */ 499 /* Register with Card Services */
501 link->next = dev_list; 500 link->next = NULL;
502 dev_list = link;
503 client_reg.dev_info = &dev_info; 501 client_reg.dev_info = &dev_info;
504 client_reg.Version = 0x0210; 502 client_reg.Version = 0x0210;
505 client_reg.event_callback_args.client_data = link; 503 client_reg.event_callback_args.client_data = link;
@@ -525,24 +523,15 @@ static void nmclan_detach(struct pcmcia_device *p_dev)
525{ 523{
526 dev_link_t *link = dev_to_instance(p_dev); 524 dev_link_t *link = dev_to_instance(p_dev);
527 struct net_device *dev = link->priv; 525 struct net_device *dev = link->priv;
528 dev_link_t **linkp;
529 526
530 DEBUG(0, "nmclan_detach(0x%p)\n", link); 527 DEBUG(0, "nmclan_detach(0x%p)\n", link);
531 528
532 /* Locate device structure */
533 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
534 if (*linkp == link) break;
535 if (*linkp == NULL)
536 return;
537
538 if (link->dev) 529 if (link->dev)
539 unregister_netdev(dev); 530 unregister_netdev(dev);
540 531
541 if (link->state & DEV_CONFIG) 532 if (link->state & DEV_CONFIG)
542 nmclan_release(link); 533 nmclan_release(link);
543 534
544 /* Unlink device structure, free bits */
545 *linkp = link->next;
546 free_netdev(dev); 535 free_netdev(dev);
547} /* nmclan_detach */ 536} /* nmclan_detach */
548 537
@@ -1700,7 +1689,6 @@ static int __init init_nmclan_cs(void)
1700static void __exit exit_nmclan_cs(void) 1689static void __exit exit_nmclan_cs(void)
1701{ 1690{
1702 pcmcia_unregister_driver(&nmclan_cs_driver); 1691 pcmcia_unregister_driver(&nmclan_cs_driver);
1703 BUG_ON(dev_list != NULL);
1704} 1692}
1705 1693
1706module_init(init_nmclan_cs); 1694module_init(init_nmclan_cs);
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index fb3e411d6daf..b35c951fc6fa 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -124,7 +124,6 @@ static dev_link_t *pcnet_attach(void);
124static void pcnet_detach(struct pcmcia_device *p_dev); 124static void pcnet_detach(struct pcmcia_device *p_dev);
125 125
126static dev_info_t dev_info = "pcnet_cs"; 126static dev_info_t dev_info = "pcnet_cs";
127static dev_link_t *dev_list;
128 127
129/*====================================================================*/ 128/*====================================================================*/
130 129
@@ -272,8 +271,7 @@ static dev_link_t *pcnet_attach(void)
272 dev->set_config = &set_config; 271 dev->set_config = &set_config;
273 272
274 /* Register with Card Services */ 273 /* Register with Card Services */
275 link->next = dev_list; 274 link->next = NULL;
276 dev_list = link;
277 client_reg.dev_info = &dev_info; 275 client_reg.dev_info = &dev_info;
278 client_reg.Version = 0x0210; 276 client_reg.Version = 0x0210;
279 client_reg.event_callback_args.client_data = link; 277 client_reg.event_callback_args.client_data = link;
@@ -300,24 +298,15 @@ static void pcnet_detach(struct pcmcia_device *p_dev)
300{ 298{
301 dev_link_t *link = dev_to_instance(p_dev); 299 dev_link_t *link = dev_to_instance(p_dev);
302 struct net_device *dev = link->priv; 300 struct net_device *dev = link->priv;
303 dev_link_t **linkp;
304 301
305 DEBUG(0, "pcnet_detach(0x%p)\n", link); 302 DEBUG(0, "pcnet_detach(0x%p)\n", link);
306 303
307 /* Locate device structure */
308 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
309 if (*linkp == link) break;
310 if (*linkp == NULL)
311 return;
312
313 if (link->dev) 304 if (link->dev)
314 unregister_netdev(dev); 305 unregister_netdev(dev);
315 306
316 if (link->state & DEV_CONFIG) 307 if (link->state & DEV_CONFIG)
317 pcnet_release(link); 308 pcnet_release(link);
318 309
319 /* Unlink device structure, free bits */
320 *linkp = link->next;
321 free_netdev(dev); 310 free_netdev(dev);
322} /* pcnet_detach */ 311} /* pcnet_detach */
323 312
@@ -1864,7 +1853,6 @@ static void __exit exit_pcnet_cs(void)
1864{ 1853{
1865 DEBUG(0, "pcnet_cs: unloading\n"); 1854 DEBUG(0, "pcnet_cs: unloading\n");
1866 pcmcia_unregister_driver(&pcnet_driver); 1855 pcmcia_unregister_driver(&pcnet_driver);
1867 BUG_ON(dev_list != NULL);
1868} 1856}
1869 1857
1870module_init(init_pcnet_cs); 1858module_init(init_pcnet_cs);
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 6cb5198d6094..9eb5cecfb2f5 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -104,8 +104,6 @@ static const char *version =
104 104
105static dev_info_t dev_info = "smc91c92_cs"; 105static dev_info_t dev_info = "smc91c92_cs";
106 106
107static dev_link_t *dev_list;
108
109struct smc_private { 107struct smc_private {
110 dev_link_t link; 108 dev_link_t link;
111 spinlock_t lock; 109 spinlock_t lock;
@@ -367,8 +365,7 @@ static dev_link_t *smc91c92_attach(void)
367 smc->mii_if.reg_num_mask = 0x1f; 365 smc->mii_if.reg_num_mask = 0x1f;
368 366
369 /* Register with Card Services */ 367 /* Register with Card Services */
370 link->next = dev_list; 368 link->next = NULL;
371 dev_list = link;
372 client_reg.dev_info = &dev_info; 369 client_reg.dev_info = &dev_info;
373 client_reg.Version = 0x0210; 370 client_reg.Version = 0x0210;
374 client_reg.event_callback_args.client_data = link; 371 client_reg.event_callback_args.client_data = link;
@@ -395,24 +392,15 @@ static void smc91c92_detach(struct pcmcia_device *p_dev)
395{ 392{
396 dev_link_t *link = dev_to_instance(p_dev); 393 dev_link_t *link = dev_to_instance(p_dev);
397 struct net_device *dev = link->priv; 394 struct net_device *dev = link->priv;
398 dev_link_t **linkp;
399 395
400 DEBUG(0, "smc91c92_detach(0x%p)\n", link); 396 DEBUG(0, "smc91c92_detach(0x%p)\n", link);
401 397
402 /* Locate device structure */
403 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
404 if (*linkp == link) break;
405 if (*linkp == NULL)
406 return;
407
408 if (link->dev) 398 if (link->dev)
409 unregister_netdev(dev); 399 unregister_netdev(dev);
410 400
411 if (link->state & DEV_CONFIG) 401 if (link->state & DEV_CONFIG)
412 smc91c92_release(link); 402 smc91c92_release(link);
413 403
414 /* Unlink device structure, free bits */
415 *linkp = link->next;
416 free_netdev(dev); 404 free_netdev(dev);
417} /* smc91c92_detach */ 405} /* smc91c92_detach */
418 406
@@ -2377,7 +2365,6 @@ static int __init init_smc91c92_cs(void)
2377static void __exit exit_smc91c92_cs(void) 2365static void __exit exit_smc91c92_cs(void)
2378{ 2366{
2379 pcmcia_unregister_driver(&smc91c92_cs_driver); 2367 pcmcia_unregister_driver(&smc91c92_cs_driver);
2380 BUG_ON(dev_list != NULL);
2381} 2368}
2382 2369
2383module_init(init_smc91c92_cs); 2370module_init(init_smc91c92_cs);
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 804e56771baf..8c8cc40bbb7d 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -331,15 +331,7 @@ static dev_info_t dev_info = "xirc2ps_cs";
331 * device numbers are used to derive the corresponding array index. 331 * device numbers are used to derive the corresponding array index.
332 */ 332 */
333 333
334static dev_link_t *dev_list;
335
336/**************** 334/****************
337 * A dev_link_t structure has fields for most things that are needed
338 * to keep track of a socket, but there will usually be some device
339 * specific information that also needs to be kept track of. The
340 * 'priv' pointer in a dev_link_t structure can be used to point to
341 * a device-specific private data structure, like this.
342 *
343 * A driver needs to provide a dev_node_t structure for each device 335 * A driver needs to provide a dev_node_t structure for each device
344 * on a card. In some cases, there is only one device per card (for 336 * on a card. In some cases, there is only one device per card (for
345 * example, ethernet cards, modems). In other cases, there may be 337 * example, ethernet cards, modems). In other cases, there may be
@@ -615,8 +607,7 @@ xirc2ps_attach(void)
615#endif 607#endif
616 608
617 /* Register with Card Services */ 609 /* Register with Card Services */
618 link->next = dev_list; 610 link->next = NULL;
619 dev_list = link;
620 client_reg.dev_info = &dev_info; 611 client_reg.dev_info = &dev_info;
621 client_reg.Version = 0x0210; 612 client_reg.Version = 0x0210;
622 client_reg.event_callback_args.client_data = link; 613 client_reg.event_callback_args.client_data = link;
@@ -641,27 +632,15 @@ xirc2ps_detach(struct pcmcia_device *p_dev)
641{ 632{
642 dev_link_t *link = dev_to_instance(p_dev); 633 dev_link_t *link = dev_to_instance(p_dev);
643 struct net_device *dev = link->priv; 634 struct net_device *dev = link->priv;
644 dev_link_t **linkp;
645 635
646 DEBUG(0, "detach(0x%p)\n", link); 636 DEBUG(0, "detach(0x%p)\n", link);
647 637
648 /* Locate device structure */
649 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
650 if (*linkp == link)
651 break;
652 if (!*linkp) {
653 DEBUG(0, "detach(0x%p): dev_link lost\n", link);
654 return;
655 }
656
657 if (link->dev) 638 if (link->dev)
658 unregister_netdev(dev); 639 unregister_netdev(dev);
659 640
660 if (link->state & DEV_CONFIG) 641 if (link->state & DEV_CONFIG)
661 xirc2ps_release(link); 642 xirc2ps_release(link);
662 643
663 /* Unlink device structure, free it */
664 *linkp = link->next;
665 free_netdev(dev); 644 free_netdev(dev);
666} /* xirc2ps_detach */ 645} /* xirc2ps_detach */
667 646
@@ -2020,7 +1999,6 @@ static void __exit
2020exit_xirc2ps_cs(void) 1999exit_xirc2ps_cs(void)
2021{ 2000{
2022 pcmcia_unregister_driver(&xirc2ps_cs_driver); 2001 pcmcia_unregister_driver(&xirc2ps_cs_driver);
2023 BUG_ON(dev_list != NULL);
2024} 2002}
2025 2003
2026module_init(init_xirc2ps_cs); 2004module_init(init_xirc2ps_cs);
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 7a28139544c0..88805a4c29f1 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -119,15 +119,7 @@ static dev_info_t dev_info = "airo_cs";
119 device numbers are used to derive the corresponding array index. 119 device numbers are used to derive the corresponding array index.
120*/ 120*/
121 121
122static dev_link_t *dev_list = NULL;
123
124/* 122/*
125 A dev_link_t structure has fields for most things that are needed
126 to keep track of a socket, but there will usually be some device
127 specific information that also needs to be kept track of. The
128 'priv' pointer in a dev_link_t structure can be used to point to
129 a device-specific private data structure, like this.
130
131 A driver needs to provide a dev_node_t structure for each device 123 A driver needs to provide a dev_node_t structure for each device
132 on a card. In some cases, there is only one device per card (for 124 on a card. In some cases, there is only one device per card (for
133 example, ethernet cards, modems). In other cases, there may be 125 example, ethernet cards, modems). In other cases, there may be
@@ -202,8 +194,7 @@ static dev_link_t *airo_attach(void)
202 link->priv = local; 194 link->priv = local;
203 195
204 /* Register with Card Services */ 196 /* Register with Card Services */
205 link->next = dev_list; 197 link->next = NULL;
206 dev_list = link;
207 client_reg.dev_info = &dev_info; 198 client_reg.dev_info = &dev_info;
208 client_reg.Version = 0x0210; 199 client_reg.Version = 0x0210;
209 client_reg.event_callback_args.client_data = link; 200 client_reg.event_callback_args.client_data = link;
@@ -229,29 +220,19 @@ static dev_link_t *airo_attach(void)
229static void airo_detach(struct pcmcia_device *p_dev) 220static void airo_detach(struct pcmcia_device *p_dev)
230{ 221{
231 dev_link_t *link = dev_to_instance(p_dev); 222 dev_link_t *link = dev_to_instance(p_dev);
232 dev_link_t **linkp; 223
233
234 DEBUG(0, "airo_detach(0x%p)\n", link); 224 DEBUG(0, "airo_detach(0x%p)\n", link);
235 225
236 /* Locate device structure */
237 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
238 if (*linkp == link) break;
239 if (*linkp == NULL)
240 return;
241
242 if (link->state & DEV_CONFIG) 226 if (link->state & DEV_CONFIG)
243 airo_release(link); 227 airo_release(link);
244 228
245 if ( ((local_info_t*)link->priv)->eth_dev ) { 229 if ( ((local_info_t*)link->priv)->eth_dev ) {
246 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); 230 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 );
247 } 231 }
248 ((local_info_t*)link->priv)->eth_dev = NULL; 232 ((local_info_t*)link->priv)->eth_dev = NULL;
249 233
250 /* Unlink device structure, free pieces */
251 *linkp = link->next;
252 kfree(link->priv); 234 kfree(link->priv);
253 kfree(link); 235 kfree(link);
254
255} /* airo_detach */ 236} /* airo_detach */
256 237
257/*====================================================================== 238/*======================================================================
@@ -574,7 +555,6 @@ static int airo_cs_init(void)
574static void airo_cs_cleanup(void) 555static void airo_cs_cleanup(void)
575{ 556{
576 pcmcia_unregister_driver(&airo_driver); 557 pcmcia_unregister_driver(&airo_driver);
577 BUG_ON(dev_list != NULL);
578} 558}
579 559
580/* 560/*
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 3ab33dd49ea2..32f009709355 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -130,15 +130,7 @@ static dev_info_t dev_info = "atmel_cs";
130 device numbers are used to derive the corresponding array index. 130 device numbers are used to derive the corresponding array index.
131*/ 131*/
132 132
133static dev_link_t *dev_list = NULL;
134
135/* 133/*
136 A dev_link_t structure has fields for most things that are needed
137 to keep track of a socket, but there will usually be some device
138 specific information that also needs to be kept track of. The
139 'priv' pointer in a dev_link_t structure can be used to point to
140 a device-specific private data structure, like this.
141
142 A driver needs to provide a dev_node_t structure for each device 134 A driver needs to provide a dev_node_t structure for each device
143 on a card. In some cases, there is only one device per card (for 135 on a card. In some cases, there is only one device per card (for
144 example, ethernet cards, modems). In other cases, there may be 136 example, ethernet cards, modems). In other cases, there may be
@@ -213,8 +205,7 @@ static dev_link_t *atmel_attach(void)
213 link->priv = local; 205 link->priv = local;
214 206
215 /* Register with Card Services */ 207 /* Register with Card Services */
216 link->next = dev_list; 208 link->next = NULL;
217 dev_list = link;
218 client_reg.dev_info = &dev_info; 209 client_reg.dev_info = &dev_info;
219 client_reg.Version = 0x0210; 210 client_reg.Version = 0x0210;
220 client_reg.event_callback_args.client_data = link; 211 client_reg.event_callback_args.client_data = link;
@@ -240,21 +231,12 @@ static dev_link_t *atmel_attach(void)
240static void atmel_detach(struct pcmcia_device *p_dev) 231static void atmel_detach(struct pcmcia_device *p_dev)
241{ 232{
242 dev_link_t *link = dev_to_instance(p_dev); 233 dev_link_t *link = dev_to_instance(p_dev);
243 dev_link_t **linkp; 234
244
245 DEBUG(0, "atmel_detach(0x%p)\n", link); 235 DEBUG(0, "atmel_detach(0x%p)\n", link);
246
247 /* Locate device structure */
248 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
249 if (*linkp == link) break;
250 if (*linkp == NULL)
251 return;
252 236
253 if (link->state & DEV_CONFIG) 237 if (link->state & DEV_CONFIG)
254 atmel_release(link); 238 atmel_release(link);
255 239
256 /* Unlink device structure, free pieces */
257 *linkp = link->next;
258 kfree(link->priv); 240 kfree(link->priv);
259 kfree(link); 241 kfree(link);
260} 242}
@@ -596,7 +578,6 @@ static int atmel_cs_init(void)
596static void atmel_cs_cleanup(void) 578static void atmel_cs_cleanup(void)
597{ 579{
598 pcmcia_unregister_driver(&atmel_driver); 580 pcmcia_unregister_driver(&atmel_driver);
599 BUG_ON(dev_list != NULL);
600} 581}
601 582
602/* 583/*
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 866142af7d92..195a5bf3d725 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -25,7 +25,6 @@
25 25
26static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)"; 26static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
27static dev_info_t dev_info = "hostap_cs"; 27static dev_info_t dev_info = "hostap_cs";
28static dev_link_t *dev_list = NULL;
29 28
30MODULE_AUTHOR("Jouni Malinen"); 29MODULE_AUTHOR("Jouni Malinen");
31MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN " 30MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
@@ -520,8 +519,7 @@ static dev_link_t *prism2_attach(void)
520 link->conf.IntType = INT_MEMORY_AND_IO; 519 link->conf.IntType = INT_MEMORY_AND_IO;
521 520
522 /* register with CardServices */ 521 /* register with CardServices */
523 link->next = dev_list; 522 link->next = NULL;
524 dev_list = link;
525 client_reg.dev_info = &dev_info; 523 client_reg.dev_info = &dev_info;
526 client_reg.Version = 0x0210; 524 client_reg.Version = 0x0210;
527 client_reg.event_callback_args.client_data = link; 525 client_reg.event_callback_args.client_data = link;
@@ -538,24 +536,13 @@ static dev_link_t *prism2_attach(void)
538static void prism2_detach(struct pcmcia_device *p_dev) 536static void prism2_detach(struct pcmcia_device *p_dev)
539{ 537{
540 dev_link_t *link = dev_to_instance(p_dev); 538 dev_link_t *link = dev_to_instance(p_dev);
541 dev_link_t **linkp;
542 539
543 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 540 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
544 541
545 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
546 if (*linkp == link)
547 break;
548 if (*linkp == NULL) {
549 printk(KERN_WARNING "%s: Attempt to detach non-existing "
550 "PCMCIA client\n", dev_info);
551 return;
552 }
553
554 if (link->state & DEV_CONFIG) { 542 if (link->state & DEV_CONFIG) {
555 prism2_release((u_long)link); 543 prism2_release((u_long)link);
556 } 544 }
557 545
558 *linkp = link->next;
559 /* release net devices */ 546 /* release net devices */
560 if (link->priv) { 547 if (link->priv) {
561 struct hostap_cs_priv *hw_priv; 548 struct hostap_cs_priv *hw_priv;
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 1770677d9e10..af9a32d8d22d 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -228,17 +228,6 @@ static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev);
228static void set_multicast_list(struct net_device *dev); 228static void set_multicast_list(struct net_device *dev);
229 229
230/* 230/*
231 A linked list of "instances" of the skeleton device. Each actual
232 PCMCIA card corresponds to one device instance, and is described
233 by one dev_link_t structure (defined in ds.h).
234
235 You may not want to use a linked list for this -- for example, the
236 memory card driver uses an array of dev_link_t pointers, where minor
237 device numbers are used to derive the corresponding array index.
238*/
239static dev_link_t *dev_list;
240
241/*
242 A dev_link_t structure has fields for most things that are needed 231 A dev_link_t structure has fields for most things that are needed
243 to keep track of a socket, but there will usually be some device 232 to keep track of a socket, but there will usually be some device
244 specific information that also needs to be kept track of. The 233 specific information that also needs to be kept track of. The
@@ -451,8 +440,7 @@ static dev_link_t *netwave_attach(void)
451 link->irq.Instance = dev; 440 link->irq.Instance = dev;
452 441
453 /* Register with Card Services */ 442 /* Register with Card Services */
454 link->next = dev_list; 443 link->next = NULL;
455 dev_list = link;
456 client_reg.dev_info = &dev_info; 444 client_reg.dev_info = &dev_info;
457 client_reg.Version = 0x0210; 445 client_reg.Version = 0x0210;
458 client_reg.event_callback_args.client_data = link; 446 client_reg.event_callback_args.client_data = link;
@@ -476,37 +464,18 @@ static dev_link_t *netwave_attach(void)
476 */ 464 */
477static void netwave_detach(struct pcmcia_device *p_dev) 465static void netwave_detach(struct pcmcia_device *p_dev)
478{ 466{
479 dev_link_t *link = dev_to_instance(p_dev); 467 dev_link_t *link = dev_to_instance(p_dev);
480 struct net_device *dev = link->priv; 468 struct net_device *dev = link->priv;
481 dev_link_t **linkp;
482 469
483 DEBUG(0, "netwave_detach(0x%p)\n", link); 470 DEBUG(0, "netwave_detach(0x%p)\n", link);
484 471
485 /* 472 if (link->state & DEV_CONFIG)
486 If the device is currently configured and active, we won't 473 netwave_release(link);
487 actually delete it yet. Instead, it is marked so that when 474
488 the release() function is called, that will trigger a proper 475 if (link->dev)
489 detach(). 476 unregister_netdev(dev);
490 */ 477
491 if (link->state & DEV_CONFIG) 478 free_netdev(dev);
492 netwave_release(link);
493
494 /* Locate device structure */
495 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
496 if (*linkp == link) break;
497 if (*linkp == NULL)
498 {
499 DEBUG(1, "netwave_cs: detach fail, '%s' not in list\n",
500 link->dev->dev_name);
501 return;
502 }
503
504 /* Unlink device structure, free pieces */
505 *linkp = link->next;
506 if (link->dev)
507 unregister_netdev(dev);
508 free_netdev(dev);
509
510} /* netwave_detach */ 479} /* netwave_detach */
511 480
512/* 481/*
@@ -1503,7 +1472,6 @@ static int __init init_netwave_cs(void)
1503static void __exit exit_netwave_cs(void) 1472static void __exit exit_netwave_cs(void)
1504{ 1473{
1505 pcmcia_unregister_driver(&netwave_driver); 1474 pcmcia_unregister_driver(&netwave_driver);
1506 BUG_ON(dev_list != NULL);
1507} 1475}
1508 1476
1509module_init(init_netwave_cs); 1477module_init(init_netwave_cs);
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 00679b6c87c1..bfeeef49f0b3 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -69,12 +69,6 @@ struct orinoco_pccard {
69 unsigned long hard_reset_in_progress; 69 unsigned long hard_reset_in_progress;
70}; 70};
71 71
72/*
73 * A linked list of "instances" of the device. Each actual PCMCIA
74 * card corresponds to one device instance, and is described by one
75 * dev_link_t structure (defined in ds.h).
76 */
77static dev_link_t *dev_list; /* = NULL */
78 72
79/********************************************************************/ 73/********************************************************************/
80/* Function prototypes */ 74/* Function prototypes */
@@ -154,9 +148,7 @@ orinoco_cs_attach(void)
154 link->conf.IntType = INT_MEMORY_AND_IO; 148 link->conf.IntType = INT_MEMORY_AND_IO;
155 149
156 /* Register with Card Services */ 150 /* Register with Card Services */
157 /* FIXME: need a lock? */ 151 link->next = NULL;
158 link->next = dev_list;
159 dev_list = link;
160 152
161 client_reg.dev_info = &dev_info; 153 client_reg.dev_info = &dev_info;
162 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 154 client_reg.Version = 0x0210; /* FIXME: what does this mean? */
@@ -181,21 +173,11 @@ orinoco_cs_attach(void)
181static void orinoco_cs_detach(struct pcmcia_device *p_dev) 173static void orinoco_cs_detach(struct pcmcia_device *p_dev)
182{ 174{
183 dev_link_t *link = dev_to_instance(p_dev); 175 dev_link_t *link = dev_to_instance(p_dev);
184 dev_link_t **linkp;
185 struct net_device *dev = link->priv; 176 struct net_device *dev = link->priv;
186 177
187 /* Locate device structure */
188 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
189 if (*linkp == link)
190 break;
191
192 BUG_ON(*linkp == NULL);
193
194 if (link->state & DEV_CONFIG) 178 if (link->state & DEV_CONFIG)
195 orinoco_cs_release(link); 179 orinoco_cs_release(link);
196 180
197 /* Unlink device structure, and free it */
198 *linkp = link->next;
199 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 181 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
200 if (link->dev) { 182 if (link->dev) {
201 DEBUG(0, PFX "About to unregister net device %p\n", 183 DEBUG(0, PFX "About to unregister net device %p\n",
@@ -678,7 +660,6 @@ static void __exit
678exit_orinoco_cs(void) 660exit_orinoco_cs(void)
679{ 661{
680 pcmcia_unregister_driver(&orinoco_driver); 662 pcmcia_unregister_driver(&orinoco_driver);
681 BUG_ON(dev_list != NULL);
682} 663}
683 664
684module_init(init_orinoco_cs); 665module_init(init_orinoco_cs);
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index a2dcab7995c1..1933250dad1a 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -78,13 +78,6 @@ struct orinoco_pccard {
78 dev_node_t node; 78 dev_node_t node;
79}; 79};
80 80
81/*
82 * A linked list of "instances" of the device. Each actual PCMCIA
83 * card corresponds to one device instance, and is described by one
84 * dev_link_t structure (defined in ds.h).
85 */
86static dev_link_t *dev_list; /* = NULL */
87
88/********************************************************************/ 81/********************************************************************/
89/* Function prototypes */ 82/* Function prototypes */
90/********************************************************************/ 83/********************************************************************/
@@ -637,8 +630,7 @@ spectrum_cs_attach(void)
637 630
638 /* Register with Card Services */ 631 /* Register with Card Services */
639 /* FIXME: need a lock? */ 632 /* FIXME: need a lock? */
640 link->next = dev_list; 633 link->next = NULL; /* not needed */
641 dev_list = link;
642 634
643 client_reg.dev_info = &dev_info; 635 client_reg.dev_info = &dev_info;
644 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 636 client_reg.Version = 0x0210; /* FIXME: what does this mean? */
@@ -1049,7 +1041,6 @@ static void __exit
1049exit_spectrum_cs(void) 1041exit_spectrum_cs(void)
1050{ 1042{
1051 pcmcia_unregister_driver(&orinoco_driver); 1043 pcmcia_unregister_driver(&orinoco_driver);
1052 BUG_ON(dev_list != NULL);
1053} 1044}
1054 1045
1055module_init(init_spectrum_cs); 1046module_init(init_spectrum_cs);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 255952d8cea0..196e827fc846 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4627,8 +4627,7 @@ wavelan_attach(void)
4627 link->conf.IntType = INT_MEMORY_AND_IO; 4627 link->conf.IntType = INT_MEMORY_AND_IO;
4628 4628
4629 /* Chain drivers */ 4629 /* Chain drivers */
4630 link->next = dev_list; 4630 link->next = NULL;
4631 dev_list = link;
4632 4631
4633 /* Allocate the generic data structure */ 4632 /* Allocate the generic data structure */
4634 dev = alloc_etherdev(sizeof(net_local)); 4633 dev = alloc_etherdev(sizeof(net_local));
@@ -4731,27 +4730,6 @@ wavelan_detach(struct pcmcia_device *p_dev)
4731 wv_pcmcia_release(link); 4730 wv_pcmcia_release(link);
4732 } 4731 }
4733 4732
4734 /* Remove the interface data from the linked list */
4735 if(dev_list == link)
4736 dev_list = link->next;
4737 else
4738 {
4739 dev_link_t * prev = dev_list;
4740
4741 while((prev != (dev_link_t *) NULL) && (prev->next != link))
4742 prev = prev->next;
4743
4744 if(prev == (dev_link_t *) NULL)
4745 {
4746#ifdef DEBUG_CONFIG_ERRORS
4747 printk(KERN_WARNING "wavelan_detach : Attempting to remove a nonexistent device.\n");
4748#endif
4749 return;
4750 }
4751
4752 prev->next = link->next;
4753 }
4754
4755 /* Free pieces */ 4733 /* Free pieces */
4756 if(link->priv) 4734 if(link->priv)
4757 { 4735 {
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index 3cb34817c039..a1a19177c5cd 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -766,7 +766,6 @@ static int
766/**************************** VARIABLES ****************************/ 766/**************************** VARIABLES ****************************/
767 767
768static dev_info_t dev_info = "wavelan_cs"; 768static dev_info_t dev_info = "wavelan_cs";
769static dev_link_t *dev_list = NULL; /* Linked list of devices */
770 769
771/* 770/*
772 * Parameters that can be set with 'insmod' 771 * Parameters that can be set with 'insmod'
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 063d22de9743..763f91a79085 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -95,7 +95,6 @@ static int parport_event(event_t event, int priority,
95 event_callback_args_t *args); 95 event_callback_args_t *args);
96 96
97static dev_info_t dev_info = "parport_cs"; 97static dev_info_t dev_info = "parport_cs";
98static dev_link_t *dev_list = NULL;
99 98
100/*====================================================================== 99/*======================================================================
101 100
@@ -129,8 +128,7 @@ static dev_link_t *parport_attach(void)
129 link->conf.IntType = INT_MEMORY_AND_IO; 128 link->conf.IntType = INT_MEMORY_AND_IO;
130 129
131 /* Register with Card Services */ 130 /* Register with Card Services */
132 link->next = dev_list; 131 link->next = NULL;
133 dev_list = link;
134 client_reg.dev_info = &dev_info; 132 client_reg.dev_info = &dev_info;
135 client_reg.Version = 0x0210; 133 client_reg.Version = 0x0210;
136 client_reg.event_callback_args.client_data = link; 134 client_reg.event_callback_args.client_data = link;
@@ -156,21 +154,12 @@ static dev_link_t *parport_attach(void)
156static void parport_detach(struct pcmcia_device *p_dev) 154static void parport_detach(struct pcmcia_device *p_dev)
157{ 155{
158 dev_link_t *link = dev_to_instance(p_dev); 156 dev_link_t *link = dev_to_instance(p_dev);
159 dev_link_t **linkp;
160 157
161 DEBUG(0, "parport_detach(0x%p)\n", link); 158 DEBUG(0, "parport_detach(0x%p)\n", link);
162 159
163 /* Locate device structure */
164 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
165 if (*linkp == link) break;
166 if (*linkp == NULL)
167 return;
168
169 if (link->state & DEV_CONFIG) 160 if (link->state & DEV_CONFIG)
170 parport_cs_release(link); 161 parport_cs_release(link);
171 162
172 /* Unlink, free device structure */
173 *linkp = link->next;
174 kfree(link->priv); 163 kfree(link->priv);
175} /* parport_detach */ 164} /* parport_detach */
176 165
@@ -391,7 +380,6 @@ static int __init init_parport_cs(void)
391static void __exit exit_parport_cs(void) 380static void __exit exit_parport_cs(void)
392{ 381{
393 pcmcia_unregister_driver(&parport_cs_driver); 382 pcmcia_unregister_driver(&parport_cs_driver);
394 BUG_ON(dev_list != NULL);
395} 383}
396 384
397module_init(init_parport_cs); 385module_init(init_parport_cs);
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 5842c938fff5..538fedb97924 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -87,8 +87,6 @@ static dev_link_t *fdomain_attach(void);
87static void fdomain_detach(struct pcmcia_device *p_dev); 87static void fdomain_detach(struct pcmcia_device *p_dev);
88 88
89 89
90static dev_link_t *dev_list = NULL;
91
92static dev_info_t dev_info = "fdomain_cs"; 90static dev_info_t dev_info = "fdomain_cs";
93 91
94static dev_link_t *fdomain_attach(void) 92static dev_link_t *fdomain_attach(void)
@@ -116,8 +114,7 @@ static dev_link_t *fdomain_attach(void)
116 link->conf.Present = PRESENT_OPTION; 114 link->conf.Present = PRESENT_OPTION;
117 115
118 /* Register with Card Services */ 116 /* Register with Card Services */
119 link->next = dev_list; 117 link->next = NULL;
120 dev_list = link;
121 client_reg.dev_info = &dev_info; 118 client_reg.dev_info = &dev_info;
122 client_reg.Version = 0x0210; 119 client_reg.Version = 0x0210;
123 client_reg.event_callback_args.client_data = link; 120 client_reg.event_callback_args.client_data = link;
@@ -135,24 +132,14 @@ static dev_link_t *fdomain_attach(void)
135 132
136static void fdomain_detach(struct pcmcia_device *p_dev) 133static void fdomain_detach(struct pcmcia_device *p_dev)
137{ 134{
138 dev_link_t *link = dev_to_instance(p_dev); 135 dev_link_t *link = dev_to_instance(p_dev);
139 dev_link_t **linkp;
140 136
141 DEBUG(0, "fdomain_detach(0x%p)\n", link); 137 DEBUG(0, "fdomain_detach(0x%p)\n", link);
142 138
143 /* Locate device structure */ 139 if (link->state & DEV_CONFIG)
144 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 140 fdomain_release(link);
145 if (*linkp == link) break; 141
146 if (*linkp == NULL) 142 kfree(link->priv);
147 return;
148
149 if (link->state & DEV_CONFIG)
150 fdomain_release(link);
151
152 /* Unlink device structure, free bits */
153 *linkp = link->next;
154 kfree(link->priv);
155
156} /* fdomain_detach */ 143} /* fdomain_detach */
157 144
158/*====================================================================*/ 145/*====================================================================*/
@@ -324,7 +311,6 @@ static int __init init_fdomain_cs(void)
324static void __exit exit_fdomain_cs(void) 311static void __exit exit_fdomain_cs(void)
325{ 312{
326 pcmcia_unregister_driver(&fdomain_cs_driver); 313 pcmcia_unregister_driver(&fdomain_cs_driver);
327 BUG_ON(dev_list != NULL);
328} 314}
329 315
330module_init(init_fdomain_cs); 316module_init(init_fdomain_cs);
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index e40a8c22aa9d..e48e9fb3c58c 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -104,7 +104,6 @@ static struct scsi_host_template nsp_driver_template = {
104#endif 104#endif
105}; 105};
106 106
107static dev_link_t *dev_list = NULL;
108static dev_info_t dev_info = {"nsp_cs"}; 107static dev_info_t dev_info = {"nsp_cs"};
109 108
110static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ 109static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
@@ -1638,8 +1637,7 @@ static dev_link_t *nsp_cs_attach(void)
1638 1637
1639 1638
1640 /* Register with Card Services */ 1639 /* Register with Card Services */
1641 link->next = dev_list; 1640 link->next = NULL;
1642 dev_list = link;
1643 client_reg.dev_info = &dev_info; 1641 client_reg.dev_info = &dev_info;
1644 client_reg.Version = 0x0210; 1642 client_reg.Version = 0x0210;
1645 client_reg.event_callback_args.client_data = link; 1643 client_reg.event_callback_args.client_data = link;
@@ -1665,30 +1663,16 @@ static dev_link_t *nsp_cs_attach(void)
1665static void nsp_cs_detach(struct pcmcia_device *p_dev) 1663static void nsp_cs_detach(struct pcmcia_device *p_dev)
1666{ 1664{
1667 dev_link_t *link = dev_to_instance(p_dev); 1665 dev_link_t *link = dev_to_instance(p_dev);
1668 dev_link_t **linkp;
1669 1666
1670 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); 1667 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link);
1671 1668
1672 /* Locate device structure */
1673 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) {
1674 if (*linkp == link) {
1675 break;
1676 }
1677 }
1678 if (*linkp == NULL) {
1679 return;
1680 }
1681
1682 if (link->state & DEV_CONFIG) { 1669 if (link->state & DEV_CONFIG) {
1683 ((scsi_info_t *)link->priv)->stop = 1; 1670 ((scsi_info_t *)link->priv)->stop = 1;
1684 nsp_cs_release(link); 1671 nsp_cs_release(link);
1685 } 1672 }
1686 1673
1687 /* Unlink device structure, free bits */
1688 *linkp = link->next;
1689 kfree(link->priv); 1674 kfree(link->priv);
1690 link->priv = NULL; 1675 link->priv = NULL;
1691
1692} /* nsp_cs_detach */ 1676} /* nsp_cs_detach */
1693 1677
1694 1678
@@ -2168,7 +2152,6 @@ static void __exit nsp_cs_exit(void)
2168 2152
2169#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) 2153#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68))
2170 pcmcia_unregister_driver(&nsp_driver); 2154 pcmcia_unregister_driver(&nsp_driver);
2171 BUG_ON(dev_list != NULL);
2172#else 2155#else
2173 unregister_pcmcia_driver(&dev_info); 2156 unregister_pcmcia_driver(&dev_info);
2174 /* XXX: this really needs to move into generic code.. */ 2157 /* XXX: this really needs to move into generic code.. */
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 8351dc234ffb..e10281a6e5f9 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -104,8 +104,6 @@ static dev_link_t *qlogic_attach(void);
104static void qlogic_detach(struct pcmcia_device *p_dev); 104static void qlogic_detach(struct pcmcia_device *p_dev);
105 105
106 106
107static dev_link_t *dev_list = NULL;
108
109static dev_info_t dev_info = "qlogic_cs"; 107static dev_info_t dev_info = "qlogic_cs";
110 108
111static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, 109static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
@@ -190,8 +188,7 @@ static dev_link_t *qlogic_attach(void)
190 link->conf.Present = PRESENT_OPTION; 188 link->conf.Present = PRESENT_OPTION;
191 189
192 /* Register with Card Services */ 190 /* Register with Card Services */
193 link->next = dev_list; 191 link->next = NULL;
194 dev_list = link;
195 client_reg.dev_info = &dev_info; 192 client_reg.dev_info = &dev_info;
196 client_reg.Version = 0x0210; 193 client_reg.Version = 0x0210;
197 client_reg.event_callback_args.client_data = link; 194 client_reg.event_callback_args.client_data = link;
@@ -210,22 +207,12 @@ static dev_link_t *qlogic_attach(void)
210static void qlogic_detach(struct pcmcia_device *p_dev) 207static void qlogic_detach(struct pcmcia_device *p_dev)
211{ 208{
212 dev_link_t *link = dev_to_instance(p_dev); 209 dev_link_t *link = dev_to_instance(p_dev);
213 dev_link_t **linkp;
214 210
215 DEBUG(0, "qlogic_detach(0x%p)\n", link); 211 DEBUG(0, "qlogic_detach(0x%p)\n", link);
216 212
217 /* Locate device structure */
218 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
219 if (*linkp == link)
220 break;
221 if (*linkp == NULL)
222 return;
223
224 if (link->state & DEV_CONFIG) 213 if (link->state & DEV_CONFIG)
225 qlogic_release(link); 214 qlogic_release(link);
226 215
227 /* Unlink device structure, free bits */
228 *linkp = link->next;
229 kfree(link->priv); 216 kfree(link->priv);
230 217
231} /* qlogic_detach */ 218} /* qlogic_detach */
@@ -439,7 +426,6 @@ static int __init init_qlogic_cs(void)
439static void __exit exit_qlogic_cs(void) 426static void __exit exit_qlogic_cs(void)
440{ 427{
441 pcmcia_unregister_driver(&qlogic_cs_driver); 428 pcmcia_unregister_driver(&qlogic_cs_driver);
442 BUG_ON(dev_list != NULL);
443} 429}
444 430
445MODULE_AUTHOR("Tom Zerucha, Michael Griffith"); 431MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index a0f8e2691f9c..87d50b33475e 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -232,7 +232,6 @@ enum Phase {
232* Global (within this module) variables other than 232* Global (within this module) variables other than
233* sym53c500_driver_template (the scsi_host_template). 233* sym53c500_driver_template (the scsi_host_template).
234*/ 234*/
235static dev_link_t *dev_list;
236static dev_info_t dev_info = "sym53c500_cs"; 235static dev_info_t dev_info = "sym53c500_cs";
237 236
238/* ================================================================== */ 237/* ================================================================== */
@@ -930,22 +929,12 @@ static void
930SYM53C500_detach(struct pcmcia_device *p_dev) 929SYM53C500_detach(struct pcmcia_device *p_dev)
931{ 930{
932 dev_link_t *link = dev_to_instance(p_dev); 931 dev_link_t *link = dev_to_instance(p_dev);
933 dev_link_t **linkp;
934 932
935 DEBUG(0, "SYM53C500_detach(0x%p)\n", link); 933 DEBUG(0, "SYM53C500_detach(0x%p)\n", link);
936 934
937 /* Locate device structure */
938 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
939 if (*linkp == link)
940 break;
941 if (*linkp == NULL)
942 return;
943
944 if (link->state & DEV_CONFIG) 935 if (link->state & DEV_CONFIG)
945 SYM53C500_release(link); 936 SYM53C500_release(link);
946 937
947 /* Unlink device structure, free bits. */
948 *linkp = link->next;
949 kfree(link->priv); 938 kfree(link->priv);
950 link->priv = NULL; 939 link->priv = NULL;
951} /* SYM53C500_detach */ 940} /* SYM53C500_detach */
@@ -978,8 +967,7 @@ SYM53C500_attach(void)
978 link->conf.Present = PRESENT_OPTION; 967 link->conf.Present = PRESENT_OPTION;
979 968
980 /* Register with Card Services */ 969 /* Register with Card Services */
981 link->next = dev_list; 970 link->next = NULL;
982 dev_list = link;
983 client_reg.dev_info = &dev_info; 971 client_reg.dev_info = &dev_info;
984 client_reg.Version = 0x0210; 972 client_reg.Version = 0x0210;
985 client_reg.event_callback_args.client_data = link; 973 client_reg.event_callback_args.client_data = link;
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index a95366366504..6e7a1a0ae015 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -122,8 +122,6 @@ static dev_info_t dev_info = "serial_cs";
122static dev_link_t *serial_attach(void); 122static dev_link_t *serial_attach(void);
123static void serial_detach(struct pcmcia_device *p_dev); 123static void serial_detach(struct pcmcia_device *p_dev);
124 124
125static dev_link_t *dev_list = NULL;
126
127/*====================================================================== 125/*======================================================================
128 126
129 After a card is removed, serial_remove() will unregister 127 After a card is removed, serial_remove() will unregister
@@ -234,8 +232,7 @@ static dev_link_t *serial_attach(void)
234 link->conf.IntType = INT_MEMORY_AND_IO; 232 link->conf.IntType = INT_MEMORY_AND_IO;
235 233
236 /* Register with Card Services */ 234 /* Register with Card Services */
237 link->next = dev_list; 235 link->next = NULL; /* not needed */
238 dev_list = link;
239 client_reg.dev_info = &dev_info; 236 client_reg.dev_info = &dev_info;
240 client_reg.Version = 0x0210; 237 client_reg.Version = 0x0210;
241 client_reg.event_callback_args.client_data = link; 238 client_reg.event_callback_args.client_data = link;
@@ -262,17 +259,9 @@ static void serial_detach(struct pcmcia_device *p_dev)
262{ 259{
263 dev_link_t *link = dev_to_instance(p_dev); 260 dev_link_t *link = dev_to_instance(p_dev);
264 struct serial_info *info = link->priv; 261 struct serial_info *info = link->priv;
265 dev_link_t **linkp;
266 262
267 DEBUG(0, "serial_detach(0x%p)\n", link); 263 DEBUG(0, "serial_detach(0x%p)\n", link);
268 264
269 /* Locate device structure */
270 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
271 if (*linkp == link)
272 break;
273 if (*linkp == NULL)
274 return;
275
276 /* 265 /*
277 * Ensure any outstanding scheduled tasks are completed. 266 * Ensure any outstanding scheduled tasks are completed.
278 */ 267 */
@@ -283,8 +272,7 @@ static void serial_detach(struct pcmcia_device *p_dev)
283 */ 272 */
284 serial_remove(link); 273 serial_remove(link);
285 274
286 /* Unlink device structure, free bits */ 275 /* free bits */
287 *linkp = link->next;
288 kfree(info); 276 kfree(info);
289} 277}
290 278
@@ -871,7 +859,6 @@ static int __init init_serial_cs(void)
871static void __exit exit_serial_cs(void) 859static void __exit exit_serial_cs(void)
872{ 860{
873 pcmcia_unregister_driver(&serial_cs_driver); 861 pcmcia_unregister_driver(&serial_cs_driver);
874 BUG_ON(dev_list != NULL);
875} 862}
876 863
877module_init(init_serial_cs); 864module_init(init_serial_cs);
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index c58140dc7a73..6b992985d782 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -40,7 +40,6 @@ static void ixj_config(dev_link_t * link);
40static void ixj_cs_release(dev_link_t * link); 40static void ixj_cs_release(dev_link_t * link);
41static int ixj_event(event_t event, int priority, event_callback_args_t * args); 41static int ixj_event(event_t event, int priority, event_callback_args_t * args);
42static dev_info_t dev_info = "ixj_cs"; 42static dev_info_t dev_info = "ixj_cs";
43static dev_link_t *dev_list = NULL;
44 43
45static dev_link_t *ixj_attach(void) 44static dev_link_t *ixj_attach(void)
46{ 45{
@@ -65,8 +64,7 @@ static dev_link_t *ixj_attach(void)
65 } 64 }
66 memset(link->priv, 0, sizeof(struct ixj_info_t)); 65 memset(link->priv, 0, sizeof(struct ixj_info_t));
67 /* Register with Card Services */ 66 /* Register with Card Services */
68 link->next = dev_list; 67 link->next = NULL;
69 dev_list = link;
70 client_reg.dev_info = &dev_info; 68 client_reg.dev_info = &dev_info;
71 client_reg.Version = 0x0210; 69 client_reg.Version = 0x0210;
72 client_reg.event_callback_args.client_data = link; 70 client_reg.event_callback_args.client_data = link;
@@ -82,20 +80,13 @@ static dev_link_t *ixj_attach(void)
82static void ixj_detach(struct pcmcia_device *p_dev) 80static void ixj_detach(struct pcmcia_device *p_dev)
83{ 81{
84 dev_link_t *link = dev_to_instance(p_dev); 82 dev_link_t *link = dev_to_instance(p_dev);
85 dev_link_t **linkp;
86 83
87 DEBUG(0, "ixj_detach(0x%p)\n", link); 84 DEBUG(0, "ixj_detach(0x%p)\n", link);
88 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 85
89 if (*linkp == link)
90 break;
91 if (*linkp == NULL)
92 return;
93 link->state &= ~DEV_RELEASE_PENDING; 86 link->state &= ~DEV_RELEASE_PENDING;
94 if (link->state & DEV_CONFIG) 87 if (link->state & DEV_CONFIG)
95 ixj_cs_release(link); 88 ixj_cs_release(link);
96 89
97 /* Unlink device structure, free bits */
98 *linkp = link->next;
99 kfree(link->priv); 90 kfree(link->priv);
100 kfree(link); 91 kfree(link);
101} 92}
@@ -314,7 +305,6 @@ static int __init ixj_pcmcia_init(void)
314static void ixj_pcmcia_exit(void) 305static void ixj_pcmcia_exit(void)
315{ 306{
316 pcmcia_unregister_driver(&ixj_driver); 307 pcmcia_unregister_driver(&ixj_driver);
317 BUG_ON(dev_list != NULL);
318} 308}
319 309
320module_init(ixj_pcmcia_init); 310module_init(ixj_pcmcia_init);
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index ed3e7014dbbc..439709670d0b 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -66,8 +66,6 @@ module_param(pc_debug, int, 0644);
66 66
67static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; 67static const char driver_name[DEV_NAME_LEN] = "sl811_cs";
68 68
69static dev_link_t *dev_list = NULL;
70
71typedef struct local_info_t { 69typedef struct local_info_t {
72 dev_link_t link; 70 dev_link_t link;
73 dev_node_t node; 71 dev_node_t node;
@@ -143,24 +141,13 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq)
143static void sl811_cs_detach(struct pcmcia_device *p_dev) 141static void sl811_cs_detach(struct pcmcia_device *p_dev)
144{ 142{
145 dev_link_t *link = dev_to_instance(p_dev); 143 dev_link_t *link = dev_to_instance(p_dev);
146 dev_link_t **linkp;
147 144
148 DBG(0, "sl811_cs_detach(0x%p)\n", link); 145 DBG(0, "sl811_cs_detach(0x%p)\n", link);
149 146
150 /* Locate device structure */
151 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) {
152 if (*linkp == link)
153 break;
154 }
155 if (*linkp == NULL)
156 return;
157
158 link->state &= ~DEV_PRESENT; 147 link->state &= ~DEV_PRESENT;
159 if (link->state & DEV_CONFIG) 148 if (link->state & DEV_CONFIG)
160 sl811_cs_release(link); 149 sl811_cs_release(link);
161 150
162 /* Unlink device structure, and free it */
163 *linkp = link->next;
164 /* This points to the parent local_info_t struct */ 151 /* This points to the parent local_info_t struct */
165 kfree(link->priv); 152 kfree(link->priv);
166} 153}
@@ -378,8 +365,7 @@ static dev_link_t *sl811_cs_attach(void)
378 link->conf.IntType = INT_MEMORY_AND_IO; 365 link->conf.IntType = INT_MEMORY_AND_IO;
379 366
380 /* Register with Card Services */ 367 /* Register with Card Services */
381 link->next = dev_list; 368 link->next = NULL;
382 dev_list = link;
383 client_reg.dev_info = (dev_info_t *) &driver_name; 369 client_reg.dev_info = (dev_info_t *) &driver_name;
384 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; 370 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
385 client_reg.Version = 0x0210; 371 client_reg.Version = 0x0210;