aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/pcmcia/3c574_cs.c18
-rw-r--r--drivers/net/pcmcia/3c589_cs.c20
-rw-r--r--drivers/net/pcmcia/axnet_cs.c18
-rw-r--r--drivers/net/pcmcia/com20020_cs.c19
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c19
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c23
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c18
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c48
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c18
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c28
-rw-r--r--drivers/net/wireless/airo_cs.c31
-rw-r--r--drivers/net/wireless/atmel_cs.c25
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c28
-rw-r--r--drivers/net/wireless/netwave_cs.c31
-rw-r--r--drivers/net/wireless/orinoco_cs.c30
-rw-r--r--drivers/net/wireless/ray_cs.c43
-rw-r--r--drivers/net/wireless/spectrum_cs.c37
-rw-r--r--drivers/net/wireless/wavelan_cs.c31
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h2
-rw-r--r--drivers/net/wireless/wl3501_cs.c32
20 files changed, 138 insertions, 381 deletions
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 80414a77fe75..60a3bc2b8fc4 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -253,7 +253,7 @@ static void set_rx_mode(struct net_device *dev);
253static dev_info_t dev_info = "3c574_cs"; 253static dev_info_t dev_info = "3c574_cs";
254 254
255static dev_link_t *tc574_attach(void); 255static dev_link_t *tc574_attach(void);
256static void tc574_detach(dev_link_t *); 256static void tc574_detach(struct pcmcia_device *p_dev);
257 257
258static dev_link_t *dev_list; 258static dev_link_t *dev_list;
259 259
@@ -316,7 +316,7 @@ static dev_link_t *tc574_attach(void)
316 ret = pcmcia_register_client(&link->handle, &client_reg); 316 ret = pcmcia_register_client(&link->handle, &client_reg);
317 if (ret != 0) { 317 if (ret != 0) {
318 cs_error(link->handle, RegisterClient, ret); 318 cs_error(link->handle, RegisterClient, ret);
319 tc574_detach(link); 319 tc574_detach(link->handle);
320 return NULL; 320 return NULL;
321 } 321 }
322 322
@@ -332,8 +332,9 @@ static dev_link_t *tc574_attach(void)
332 332
333*/ 333*/
334 334
335static void tc574_detach(dev_link_t *link) 335static void tc574_detach(struct pcmcia_device *p_dev)
336{ 336{
337 dev_link_t *link = dev_to_instance(p_dev);
337 struct net_device *dev = link->priv; 338 struct net_device *dev = link->priv;
338 dev_link_t **linkp; 339 dev_link_t **linkp;
339 340
@@ -351,9 +352,6 @@ static void tc574_detach(dev_link_t *link)
351 if (link->state & DEV_CONFIG) 352 if (link->state & DEV_CONFIG)
352 tc574_release(link); 353 tc574_release(link);
353 354
354 if (link->handle)
355 pcmcia_deregister_client(link->handle);
356
357 /* Unlink device structure, free bits */ 355 /* Unlink device structure, free bits */
358 *linkp = link->next; 356 *linkp = link->next;
359 free_netdev(dev); 357 free_netdev(dev);
@@ -590,16 +588,10 @@ static int tc574_event(event_t event, int priority,
590 event_callback_args_t *args) 588 event_callback_args_t *args)
591{ 589{
592 dev_link_t *link = args->client_data; 590 dev_link_t *link = args->client_data;
593 struct net_device *dev = link->priv;
594 591
595 DEBUG(1, "3c574_event(0x%06x)\n", event); 592 DEBUG(1, "3c574_event(0x%06x)\n", event);
596 593
597 switch (event) { 594 switch (event) {
598 case CS_EVENT_CARD_REMOVAL:
599 link->state &= ~DEV_PRESENT;
600 if (link->state & DEV_CONFIG)
601 netif_device_detach(dev);
602 break;
603 case CS_EVENT_CARD_INSERTION: 595 case CS_EVENT_CARD_INSERTION:
604 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 596 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
605 tc574_config(link); 597 tc574_config(link);
@@ -1304,7 +1296,7 @@ static struct pcmcia_driver tc574_driver = {
1304 }, 1296 },
1305 .attach = tc574_attach, 1297 .attach = tc574_attach,
1306 .event = tc574_event, 1298 .event = tc574_event,
1307 .detach = tc574_detach, 1299 .remove = tc574_detach,
1308 .id_table = tc574_ids, 1300 .id_table = tc574_ids,
1309 .suspend = tc574_suspend, 1301 .suspend = tc574_suspend,
1310 .resume = tc574_resume, 1302 .resume = tc574_resume,
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index bbda681ac102..09b96c76216e 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -164,7 +164,7 @@ static struct ethtool_ops netdev_ethtool_ops;
164static dev_info_t dev_info = "3c589_cs"; 164static dev_info_t dev_info = "3c589_cs";
165 165
166static dev_link_t *tc589_attach(void); 166static dev_link_t *tc589_attach(void);
167static void tc589_detach(dev_link_t *); 167static void tc589_detach(struct pcmcia_device *p_dev);
168 168
169static dev_link_t *dev_list; 169static dev_link_t *dev_list;
170 170
@@ -230,7 +230,7 @@ static dev_link_t *tc589_attach(void)
230 ret = pcmcia_register_client(&link->handle, &client_reg); 230 ret = pcmcia_register_client(&link->handle, &client_reg);
231 if (ret != 0) { 231 if (ret != 0) {
232 cs_error(link->handle, RegisterClient, ret); 232 cs_error(link->handle, RegisterClient, ret);
233 tc589_detach(link); 233 tc589_detach(link->handle);
234 return NULL; 234 return NULL;
235 } 235 }
236 236
@@ -246,8 +246,9 @@ static dev_link_t *tc589_attach(void)
246 246
247======================================================================*/ 247======================================================================*/
248 248
249static void tc589_detach(dev_link_t *link) 249static void tc589_detach(struct pcmcia_device *p_dev)
250{ 250{
251 dev_link_t *link = dev_to_instance(p_dev);
251 struct net_device *dev = link->priv; 252 struct net_device *dev = link->priv;
252 dev_link_t **linkp; 253 dev_link_t **linkp;
253 254
@@ -264,10 +265,7 @@ static void tc589_detach(dev_link_t *link)
264 265
265 if (link->state & DEV_CONFIG) 266 if (link->state & DEV_CONFIG)
266 tc589_release(link); 267 tc589_release(link);
267 268
268 if (link->handle)
269 pcmcia_deregister_client(link->handle);
270
271 /* Unlink device structure, free bits */ 269 /* Unlink device structure, free bits */
272 *linkp = link->next; 270 *linkp = link->next;
273 free_netdev(dev); 271 free_netdev(dev);
@@ -466,16 +464,10 @@ static int tc589_event(event_t event, int priority,
466 event_callback_args_t *args) 464 event_callback_args_t *args)
467{ 465{
468 dev_link_t *link = args->client_data; 466 dev_link_t *link = args->client_data;
469 struct net_device *dev = link->priv;
470 467
471 DEBUG(1, "3c589_event(0x%06x)\n", event); 468 DEBUG(1, "3c589_event(0x%06x)\n", event);
472 469
473 switch (event) { 470 switch (event) {
474 case CS_EVENT_CARD_REMOVAL:
475 link->state &= ~DEV_PRESENT;
476 if (link->state & DEV_CONFIG)
477 netif_device_detach(dev);
478 break;
479 case CS_EVENT_CARD_INSERTION: 471 case CS_EVENT_CARD_INSERTION:
480 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 472 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
481 tc589_config(link); 473 tc589_config(link);
@@ -1079,7 +1071,7 @@ static struct pcmcia_driver tc589_driver = {
1079 }, 1071 },
1080 .attach = tc589_attach, 1072 .attach = tc589_attach,
1081 .event = tc589_event, 1073 .event = tc589_event,
1082 .detach = tc589_detach, 1074 .remove = tc589_detach,
1083 .id_table = tc589_ids, 1075 .id_table = tc589_ids,
1084 .suspend = tc589_suspend, 1076 .suspend = tc589_suspend,
1085 .resume = tc589_resume, 1077 .resume = tc589_resume,
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 6c6b25265659..11f701a8ff02 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -108,7 +108,7 @@ static void block_output(struct net_device *dev, int count,
108 const u_char *buf, const int start_page); 108 const u_char *buf, const int start_page);
109 109
110static dev_link_t *axnet_attach(void); 110static dev_link_t *axnet_attach(void);
111static void axnet_detach(dev_link_t *); 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; 114static dev_link_t *dev_list;
@@ -185,7 +185,7 @@ static dev_link_t *axnet_attach(void)
185 ret = pcmcia_register_client(&link->handle, &client_reg); 185 ret = pcmcia_register_client(&link->handle, &client_reg);
186 if (ret != CS_SUCCESS) { 186 if (ret != CS_SUCCESS) {
187 cs_error(link->handle, RegisterClient, ret); 187 cs_error(link->handle, RegisterClient, ret);
188 axnet_detach(link); 188 axnet_detach(link->handle);
189 return NULL; 189 return NULL;
190 } 190 }
191 191
@@ -201,8 +201,9 @@ static dev_link_t *axnet_attach(void)
201 201
202======================================================================*/ 202======================================================================*/
203 203
204static void axnet_detach(dev_link_t *link) 204static void axnet_detach(struct pcmcia_device *p_dev)
205{ 205{
206 dev_link_t *link = dev_to_instance(p_dev);
206 struct net_device *dev = link->priv; 207 struct net_device *dev = link->priv;
207 dev_link_t **linkp; 208 dev_link_t **linkp;
208 209
@@ -220,9 +221,6 @@ static void axnet_detach(dev_link_t *link)
220 if (link->state & DEV_CONFIG) 221 if (link->state & DEV_CONFIG)
221 axnet_release(link); 222 axnet_release(link);
222 223
223 if (link->handle)
224 pcmcia_deregister_client(link->handle);
225
226 /* Unlink device structure, free bits */ 224 /* Unlink device structure, free bits */
227 *linkp = link->next; 225 *linkp = link->next;
228 free_netdev(dev); 226 free_netdev(dev);
@@ -537,16 +535,10 @@ static int axnet_event(event_t event, int priority,
537 event_callback_args_t *args) 535 event_callback_args_t *args)
538{ 536{
539 dev_link_t *link = args->client_data; 537 dev_link_t *link = args->client_data;
540 struct net_device *dev = link->priv;
541 538
542 DEBUG(2, "axnet_event(0x%06x)\n", event); 539 DEBUG(2, "axnet_event(0x%06x)\n", event);
543 540
544 switch (event) { 541 switch (event) {
545 case CS_EVENT_CARD_REMOVAL:
546 link->state &= ~DEV_PRESENT;
547 if (link->state & DEV_CONFIG)
548 netif_device_detach(dev);
549 break;
550 case CS_EVENT_CARD_INSERTION: 542 case CS_EVENT_CARD_INSERTION:
551 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 543 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
552 axnet_config(link); 544 axnet_config(link);
@@ -890,7 +882,7 @@ static struct pcmcia_driver axnet_cs_driver = {
890 }, 882 },
891 .attach = axnet_attach, 883 .attach = axnet_attach,
892 .event = axnet_event, 884 .event = axnet_event,
893 .detach = axnet_detach, 885 .remove = axnet_detach,
894 .id_table = axnet_ids, 886 .id_table = axnet_ids,
895 .suspend = axnet_suspend, 887 .suspend = axnet_suspend,
896 .resume = axnet_resume, 888 .resume = axnet_resume,
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 68612222de6e..6970888cba10 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -126,7 +126,7 @@ static int com20020_event(event_t event, int priority,
126static dev_info_t dev_info = "com20020_cs"; 126static dev_info_t dev_info = "com20020_cs";
127 127
128static dev_link_t *com20020_attach(void); 128static dev_link_t *com20020_attach(void);
129static void com20020_detach(dev_link_t *); 129static void com20020_detach(struct pcmcia_device *p_dev);
130 130
131static dev_link_t *dev_list; 131static dev_link_t *dev_list;
132 132
@@ -204,7 +204,7 @@ static dev_link_t *com20020_attach(void)
204 ret = pcmcia_register_client(&link->handle, &client_reg); 204 ret = pcmcia_register_client(&link->handle, &client_reg);
205 if (ret != 0) { 205 if (ret != 0) {
206 cs_error(link->handle, RegisterClient, ret); 206 cs_error(link->handle, RegisterClient, ret);
207 com20020_detach(link); 207 com20020_detach(link->handle);
208 return NULL; 208 return NULL;
209 } 209 }
210 210
@@ -226,8 +226,9 @@ fail_alloc_info:
226 226
227======================================================================*/ 227======================================================================*/
228 228
229static void com20020_detach(dev_link_t *link) 229static void com20020_detach(struct pcmcia_device *p_dev)
230{ 230{
231 dev_link_t *link = dev_to_instance(p_dev);
231 struct com20020_dev_t *info = link->priv; 232 struct com20020_dev_t *info = link->priv;
232 dev_link_t **linkp; 233 dev_link_t **linkp;
233 struct net_device *dev; 234 struct net_device *dev;
@@ -260,9 +261,6 @@ static void com20020_detach(dev_link_t *link)
260 if (link->state & DEV_CONFIG) 261 if (link->state & DEV_CONFIG)
261 com20020_release(link); 262 com20020_release(link);
262 263
263 if (link->handle)
264 pcmcia_deregister_client(link->handle);
265
266 /* Unlink device structure, free bits */ 264 /* Unlink device structure, free bits */
267 DEBUG(1,"unlinking...\n"); 265 DEBUG(1,"unlinking...\n");
268 *linkp = link->next; 266 *linkp = link->next;
@@ -470,17 +468,10 @@ static int com20020_event(event_t event, int priority,
470 event_callback_args_t *args) 468 event_callback_args_t *args)
471{ 469{
472 dev_link_t *link = args->client_data; 470 dev_link_t *link = args->client_data;
473 com20020_dev_t *info = link->priv;
474 struct net_device *dev = info->dev;
475 471
476 DEBUG(1, "com20020_event(0x%06x)\n", event); 472 DEBUG(1, "com20020_event(0x%06x)\n", event);
477 473
478 switch (event) { 474 switch (event) {
479 case CS_EVENT_CARD_REMOVAL:
480 link->state &= ~DEV_PRESENT;
481 if (link->state & DEV_CONFIG)
482 netif_device_detach(dev);
483 break;
484 case CS_EVENT_CARD_INSERTION: 475 case CS_EVENT_CARD_INSERTION:
485 link->state |= DEV_PRESENT; 476 link->state |= DEV_PRESENT;
486 com20020_config(link); 477 com20020_config(link);
@@ -502,7 +493,7 @@ static struct pcmcia_driver com20020_cs_driver = {
502 }, 493 },
503 .attach = com20020_attach, 494 .attach = com20020_attach,
504 .event = com20020_event, 495 .event = com20020_event,
505 .detach = com20020_detach, 496 .remove = com20020_detach,
506 .id_table = com20020_ids, 497 .id_table = com20020_ids,
507 .suspend = com20020_suspend, 498 .suspend = com20020_suspend,
508 .resume = com20020_resume, 499 .resume = com20020_resume,
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 388ecade13de..560d4ee22803 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -91,7 +91,7 @@ static void fmvj18x_release(dev_link_t *link);
91static int fmvj18x_event(event_t event, int priority, 91static int fmvj18x_event(event_t event, int priority,
92 event_callback_args_t *args); 92 event_callback_args_t *args);
93static dev_link_t *fmvj18x_attach(void); 93static dev_link_t *fmvj18x_attach(void);
94static void fmvj18x_detach(dev_link_t *); 94static void fmvj18x_detach(struct pcmcia_device *p_dev);
95 95
96/* 96/*
97 LAN controller(MBH86960A) specific routines 97 LAN controller(MBH86960A) specific routines
@@ -291,7 +291,7 @@ static dev_link_t *fmvj18x_attach(void)
291 ret = pcmcia_register_client(&link->handle, &client_reg); 291 ret = pcmcia_register_client(&link->handle, &client_reg);
292 if (ret != 0) { 292 if (ret != 0) {
293 cs_error(link->handle, RegisterClient, ret); 293 cs_error(link->handle, RegisterClient, ret);
294 fmvj18x_detach(link); 294 fmvj18x_detach(link->handle);
295 return NULL; 295 return NULL;
296 } 296 }
297 297
@@ -300,8 +300,9 @@ static dev_link_t *fmvj18x_attach(void)
300 300
301/*====================================================================*/ 301/*====================================================================*/
302 302
303static void fmvj18x_detach(dev_link_t *link) 303static void fmvj18x_detach(struct pcmcia_device *p_dev)
304{ 304{
305 dev_link_t *link = dev_to_instance(p_dev);
305 struct net_device *dev = link->priv; 306 struct net_device *dev = link->priv;
306 dev_link_t **linkp; 307 dev_link_t **linkp;
307 308
@@ -319,10 +320,6 @@ static void fmvj18x_detach(dev_link_t *link)
319 if (link->state & DEV_CONFIG) 320 if (link->state & DEV_CONFIG)
320 fmvj18x_release(link); 321 fmvj18x_release(link);
321 322
322 /* Break the link with Card Services */
323 if (link->handle)
324 pcmcia_deregister_client(link->handle);
325
326 /* Unlink device structure, free pieces */ 323 /* Unlink device structure, free pieces */
327 *linkp = link->next; 324 *linkp = link->next;
328 free_netdev(dev); 325 free_netdev(dev);
@@ -752,16 +749,10 @@ static int fmvj18x_event(event_t event, int priority,
752 event_callback_args_t *args) 749 event_callback_args_t *args)
753{ 750{
754 dev_link_t *link = args->client_data; 751 dev_link_t *link = args->client_data;
755 struct net_device *dev = link->priv;
756 752
757 DEBUG(1, "fmvj18x_event(0x%06x)\n", event); 753 DEBUG(1, "fmvj18x_event(0x%06x)\n", event);
758 754
759 switch (event) { 755 switch (event) {
760 case CS_EVENT_CARD_REMOVAL:
761 link->state &= ~DEV_PRESENT;
762 if (link->state & DEV_CONFIG)
763 netif_device_detach(dev);
764 break;
765 case CS_EVENT_CARD_INSERTION: 756 case CS_EVENT_CARD_INSERTION:
766 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 757 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
767 fmvj18x_config(link); 758 fmvj18x_config(link);
@@ -802,7 +793,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = {
802 }, 793 },
803 .attach = fmvj18x_attach, 794 .attach = fmvj18x_attach,
804 .event = fmvj18x_event, 795 .event = fmvj18x_event,
805 .detach = fmvj18x_detach, 796 .remove = fmvj18x_detach,
806 .id_table = fmvj18x_ids, 797 .id_table = fmvj18x_ids,
807 .suspend = fmvj18x_suspend, 798 .suspend = fmvj18x_suspend,
808 .resume = fmvj18x_resume, 799 .resume = fmvj18x_resume,
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 3a7218e51b73..961294983354 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -114,7 +114,7 @@ static int ibmtr_event(event_t event, int priority,
114static dev_info_t dev_info = "ibmtr_cs"; 114static dev_info_t dev_info = "ibmtr_cs";
115 115
116static dev_link_t *ibmtr_attach(void); 116static dev_link_t *ibmtr_attach(void);
117static void ibmtr_detach(dev_link_t *); 117static void ibmtr_detach(struct pcmcia_device *p_dev);
118 118
119static dev_link_t *dev_list; 119static dev_link_t *dev_list;
120 120
@@ -201,7 +201,7 @@ out:
201 return link; 201 return link;
202 202
203out_detach: 203out_detach:
204 ibmtr_detach(link); 204 ibmtr_detach(link->handle);
205 link = NULL; 205 link = NULL;
206 goto out; 206 goto out;
207} /* ibmtr_attach */ 207} /* ibmtr_attach */
@@ -215,8 +215,9 @@ out_detach:
215 215
216======================================================================*/ 216======================================================================*/
217 217
218static void ibmtr_detach(dev_link_t *link) 218static void ibmtr_detach(struct pcmcia_device *p_dev)
219{ 219{
220 dev_link_t *link = dev_to_instance(p_dev);
220 struct ibmtr_dev_t *info = link->priv; 221 struct ibmtr_dev_t *info = link->priv;
221 dev_link_t **linkp; 222 dev_link_t **linkp;
222 struct net_device *dev; 223 struct net_device *dev;
@@ -241,9 +242,6 @@ static void ibmtr_detach(dev_link_t *link)
241 if (link->state & DEV_CONFIG) 242 if (link->state & DEV_CONFIG)
242 ibmtr_release(link); 243 ibmtr_release(link);
243 244
244 if (link->handle)
245 pcmcia_deregister_client(link->handle);
246
247 /* Unlink device structure, free bits */ 245 /* Unlink device structure, free bits */
248 *linkp = link->next; 246 *linkp = link->next;
249 free_netdev(dev); 247 free_netdev(dev);
@@ -449,21 +447,10 @@ static int ibmtr_event(event_t event, int priority,
449 event_callback_args_t *args) 447 event_callback_args_t *args)
450{ 448{
451 dev_link_t *link = args->client_data; 449 dev_link_t *link = args->client_data;
452 ibmtr_dev_t *info = link->priv;
453 struct net_device *dev = info->dev;
454 450
455 DEBUG(1, "ibmtr_event(0x%06x)\n", event); 451 DEBUG(1, "ibmtr_event(0x%06x)\n", event);
456 452
457 switch (event) { 453 switch (event) {
458 case CS_EVENT_CARD_REMOVAL:
459 link->state &= ~DEV_PRESENT;
460 if (link->state & DEV_CONFIG) {
461 /* set flag to bypass normal interrupt code */
462 struct tok_info *priv = netdev_priv(dev);
463 priv->sram_phys |= 1;
464 netif_device_detach(dev);
465 }
466 break;
467 case CS_EVENT_CARD_INSERTION: 454 case CS_EVENT_CARD_INSERTION:
468 link->state |= DEV_PRESENT; 455 link->state |= DEV_PRESENT;
469 ibmtr_config(link); 456 ibmtr_config(link);
@@ -529,7 +516,7 @@ static struct pcmcia_driver ibmtr_cs_driver = {
529 }, 516 },
530 .attach = ibmtr_attach, 517 .attach = ibmtr_attach,
531 .event = ibmtr_event, 518 .event = ibmtr_event,
532 .detach = ibmtr_detach, 519 .remove = ibmtr_detach,
533 .id_table = ibmtr_ids, 520 .id_table = ibmtr_ids,
534 .suspend = ibmtr_suspend, 521 .suspend = ibmtr_suspend,
535 .resume = ibmtr_resume, 522 .resume = ibmtr_resume,
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index fa4921f8b9fc..011ceb090320 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -440,7 +440,7 @@ static struct ethtool_ops netdev_ethtool_ops;
440 440
441 441
442static dev_link_t *nmclan_attach(void); 442static dev_link_t *nmclan_attach(void);
443static void nmclan_detach(dev_link_t *); 443static void nmclan_detach(struct pcmcia_device *p_dev);
444 444
445/* ---------------------------------------------------------------------------- 445/* ----------------------------------------------------------------------------
446nmclan_attach 446nmclan_attach
@@ -506,7 +506,7 @@ static dev_link_t *nmclan_attach(void)
506 ret = pcmcia_register_client(&link->handle, &client_reg); 506 ret = pcmcia_register_client(&link->handle, &client_reg);
507 if (ret != 0) { 507 if (ret != 0) {
508 cs_error(link->handle, RegisterClient, ret); 508 cs_error(link->handle, RegisterClient, ret);
509 nmclan_detach(link); 509 nmclan_detach(link->handle);
510 return NULL; 510 return NULL;
511 } 511 }
512 512
@@ -521,8 +521,9 @@ nmclan_detach
521 when the device is released. 521 when the device is released.
522---------------------------------------------------------------------------- */ 522---------------------------------------------------------------------------- */
523 523
524static void nmclan_detach(dev_link_t *link) 524static void nmclan_detach(struct pcmcia_device *p_dev)
525{ 525{
526 dev_link_t *link = dev_to_instance(p_dev);
526 struct net_device *dev = link->priv; 527 struct net_device *dev = link->priv;
527 dev_link_t **linkp; 528 dev_link_t **linkp;
528 529
@@ -540,9 +541,6 @@ static void nmclan_detach(dev_link_t *link)
540 if (link->state & DEV_CONFIG) 541 if (link->state & DEV_CONFIG)
541 nmclan_release(link); 542 nmclan_release(link);
542 543
543 if (link->handle)
544 pcmcia_deregister_client(link->handle);
545
546 /* Unlink device structure, free bits */ 544 /* Unlink device structure, free bits */
547 *linkp = link->next; 545 *linkp = link->next;
548 free_netdev(dev); 546 free_netdev(dev);
@@ -845,16 +843,10 @@ static int nmclan_event(event_t event, int priority,
845 event_callback_args_t *args) 843 event_callback_args_t *args)
846{ 844{
847 dev_link_t *link = args->client_data; 845 dev_link_t *link = args->client_data;
848 struct net_device *dev = link->priv;
849 846
850 DEBUG(1, "nmclan_event(0x%06x)\n", event); 847 DEBUG(1, "nmclan_event(0x%06x)\n", event);
851 848
852 switch (event) { 849 switch (event) {
853 case CS_EVENT_CARD_REMOVAL:
854 link->state &= ~DEV_PRESENT;
855 if (link->state & DEV_CONFIG)
856 netif_device_detach(dev);
857 break;
858 case CS_EVENT_CARD_INSERTION: 850 case CS_EVENT_CARD_INSERTION:
859 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 851 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
860 nmclan_config(link); 852 nmclan_config(link);
@@ -1694,7 +1686,7 @@ static struct pcmcia_driver nmclan_cs_driver = {
1694 }, 1686 },
1695 .attach = nmclan_attach, 1687 .attach = nmclan_attach,
1696 .event = nmclan_event, 1688 .event = nmclan_event,
1697 .detach = nmclan_detach, 1689 .remove = nmclan_detach,
1698 .id_table = nmclan_ids, 1690 .id_table = nmclan_ids,
1699 .suspend = nmclan_suspend, 1691 .suspend = nmclan_suspend,
1700 .resume = nmclan_resume, 1692 .resume = nmclan_resume,
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 7db4d6f3db45..fb3e411d6daf 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -121,7 +121,7 @@ static int setup_dma_config(dev_link_t *link, int start_pg,
121 int stop_pg); 121 int stop_pg);
122 122
123static dev_link_t *pcnet_attach(void); 123static dev_link_t *pcnet_attach(void);
124static void pcnet_detach(dev_link_t *); 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; 127static dev_link_t *dev_list;
@@ -280,7 +280,7 @@ static dev_link_t *pcnet_attach(void)
280 ret = pcmcia_register_client(&link->handle, &client_reg); 280 ret = pcmcia_register_client(&link->handle, &client_reg);
281 if (ret != CS_SUCCESS) { 281 if (ret != CS_SUCCESS) {
282 cs_error(link->handle, RegisterClient, ret); 282 cs_error(link->handle, RegisterClient, ret);
283 pcnet_detach(link); 283 pcnet_detach(link->handle);
284 return NULL; 284 return NULL;
285 } 285 }
286 286
@@ -296,31 +296,29 @@ static dev_link_t *pcnet_attach(void)
296 296
297======================================================================*/ 297======================================================================*/
298 298
299static void pcnet_detach(dev_link_t *link) 299static void pcnet_detach(struct pcmcia_device *p_dev)
300{ 300{
301 struct net_device *dev = link->priv; 301 dev_link_t *link = dev_to_instance(p_dev);
302 dev_link_t **linkp; 302 struct net_device *dev = link->priv;
303 303 dev_link_t **linkp;
304 DEBUG(0, "pcnet_detach(0x%p)\n", link);
305 304
306 /* Locate device structure */ 305 DEBUG(0, "pcnet_detach(0x%p)\n", link);
307 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
308 if (*linkp == link) break;
309 if (*linkp == NULL)
310 return;
311 306
312 if (link->dev) 307 /* Locate device structure */
313 unregister_netdev(dev); 308 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
309 if (*linkp == link) break;
310 if (*linkp == NULL)
311 return;
314 312
315 if (link->state & DEV_CONFIG) 313 if (link->dev)
316 pcnet_release(link); 314 unregister_netdev(dev);
317 315
318 if (link->handle) 316 if (link->state & DEV_CONFIG)
319 pcmcia_deregister_client(link->handle); 317 pcnet_release(link);
320 318
321 /* Unlink device structure, free bits */ 319 /* Unlink device structure, free bits */
322 *linkp = link->next; 320 *linkp = link->next;
323 free_netdev(dev); 321 free_netdev(dev);
324} /* pcnet_detach */ 322} /* pcnet_detach */
325 323
326/*====================================================================== 324/*======================================================================
@@ -817,16 +815,10 @@ static int pcnet_event(event_t event, int priority,
817 event_callback_args_t *args) 815 event_callback_args_t *args)
818{ 816{
819 dev_link_t *link = args->client_data; 817 dev_link_t *link = args->client_data;
820 struct net_device *dev = link->priv;
821 818
822 DEBUG(2, "pcnet_event(0x%06x)\n", event); 819 DEBUG(2, "pcnet_event(0x%06x)\n", event);
823 820
824 switch (event) { 821 switch (event) {
825 case CS_EVENT_CARD_REMOVAL:
826 link->state &= ~DEV_PRESENT;
827 if (link->state & DEV_CONFIG)
828 netif_device_detach(dev);
829 break;
830 case CS_EVENT_CARD_INSERTION: 822 case CS_EVENT_CARD_INSERTION:
831 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 823 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
832 pcnet_config(link); 824 pcnet_config(link);
@@ -1856,7 +1848,7 @@ static struct pcmcia_driver pcnet_driver = {
1856 }, 1848 },
1857 .attach = pcnet_attach, 1849 .attach = pcnet_attach,
1858 .event = pcnet_event, 1850 .event = pcnet_event,
1859 .detach = pcnet_detach, 1851 .remove = pcnet_detach,
1860 .owner = THIS_MODULE, 1852 .owner = THIS_MODULE,
1861 .id_table = pcnet_ids, 1853 .id_table = pcnet_ids,
1862 .suspend = pcnet_suspend, 1854 .suspend = pcnet_suspend,
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 7c61ec90c2c3..6cb5198d6094 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -282,7 +282,7 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002,
282/*====================================================================*/ 282/*====================================================================*/
283 283
284static dev_link_t *smc91c92_attach(void); 284static dev_link_t *smc91c92_attach(void);
285static void smc91c92_detach(dev_link_t *); 285static void smc91c92_detach(struct pcmcia_device *p_dev);
286static void smc91c92_config(dev_link_t *link); 286static void smc91c92_config(dev_link_t *link);
287static void smc91c92_release(dev_link_t *link); 287static void smc91c92_release(dev_link_t *link);
288static int smc91c92_event(event_t event, int priority, 288static int smc91c92_event(event_t event, int priority,
@@ -375,7 +375,7 @@ static dev_link_t *smc91c92_attach(void)
375 ret = pcmcia_register_client(&link->handle, &client_reg); 375 ret = pcmcia_register_client(&link->handle, &client_reg);
376 if (ret != 0) { 376 if (ret != 0) {
377 cs_error(link->handle, RegisterClient, ret); 377 cs_error(link->handle, RegisterClient, ret);
378 smc91c92_detach(link); 378 smc91c92_detach(link->handle);
379 return NULL; 379 return NULL;
380 } 380 }
381 381
@@ -391,8 +391,9 @@ static dev_link_t *smc91c92_attach(void)
391 391
392======================================================================*/ 392======================================================================*/
393 393
394static void smc91c92_detach(dev_link_t *link) 394static void smc91c92_detach(struct pcmcia_device *p_dev)
395{ 395{
396 dev_link_t *link = dev_to_instance(p_dev);
396 struct net_device *dev = link->priv; 397 struct net_device *dev = link->priv;
397 dev_link_t **linkp; 398 dev_link_t **linkp;
398 399
@@ -410,9 +411,6 @@ static void smc91c92_detach(dev_link_t *link)
410 if (link->state & DEV_CONFIG) 411 if (link->state & DEV_CONFIG)
411 smc91c92_release(link); 412 smc91c92_release(link);
412 413
413 if (link->handle)
414 pcmcia_deregister_client(link->handle);
415
416 /* Unlink device structure, free bits */ 414 /* Unlink device structure, free bits */
417 *linkp = link->next; 415 *linkp = link->next;
418 free_netdev(dev); 416 free_netdev(dev);
@@ -1237,16 +1235,10 @@ static int smc91c92_event(event_t event, int priority,
1237 event_callback_args_t *args) 1235 event_callback_args_t *args)
1238{ 1236{
1239 dev_link_t *link = args->client_data; 1237 dev_link_t *link = args->client_data;
1240 struct net_device *dev = link->priv;
1241 1238
1242 DEBUG(1, "smc91c92_event(0x%06x)\n", event); 1239 DEBUG(1, "smc91c92_event(0x%06x)\n", event);
1243 1240
1244 switch (event) { 1241 switch (event) {
1245 case CS_EVENT_CARD_REMOVAL:
1246 link->state &= ~DEV_PRESENT;
1247 if (link->state & DEV_CONFIG)
1248 netif_device_detach(dev);
1249 break;
1250 case CS_EVENT_CARD_INSERTION: 1242 case CS_EVENT_CARD_INSERTION:
1251 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1243 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1252 smc91c92_config(link); 1244 smc91c92_config(link);
@@ -2371,7 +2363,7 @@ static struct pcmcia_driver smc91c92_cs_driver = {
2371 }, 2363 },
2372 .attach = smc91c92_attach, 2364 .attach = smc91c92_attach,
2373 .event = smc91c92_event, 2365 .event = smc91c92_event,
2374 .detach = smc91c92_detach, 2366 .remove = smc91c92_detach,
2375 .id_table = smc91c92_ids, 2367 .id_table = smc91c92_ids,
2376 .suspend = smc91c92_suspend, 2368 .suspend = smc91c92_suspend,
2377 .resume = smc91c92_resume, 2369 .resume = smc91c92_resume,
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 917e50ac37f3..804e56771baf 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -302,7 +302,7 @@ static int xirc2ps_event(event_t event, int priority,
302 */ 302 */
303 303
304static dev_link_t *xirc2ps_attach(void); 304static dev_link_t *xirc2ps_attach(void);
305static void xirc2ps_detach(dev_link_t *); 305static void xirc2ps_detach(struct pcmcia_device *p_dev);
306 306
307/**************** 307/****************
308 * You'll also need to prototype all the functions that will actually 308 * You'll also need to prototype all the functions that will actually
@@ -622,7 +622,7 @@ xirc2ps_attach(void)
622 client_reg.event_callback_args.client_data = link; 622 client_reg.event_callback_args.client_data = link;
623 if ((err = pcmcia_register_client(&link->handle, &client_reg))) { 623 if ((err = pcmcia_register_client(&link->handle, &client_reg))) {
624 cs_error(link->handle, RegisterClient, err); 624 cs_error(link->handle, RegisterClient, err);
625 xirc2ps_detach(link); 625 xirc2ps_detach(link->handle);
626 return NULL; 626 return NULL;
627 } 627 }
628 628
@@ -637,8 +637,9 @@ xirc2ps_attach(void)
637 */ 637 */
638 638
639static void 639static void
640xirc2ps_detach(dev_link_t * link) 640xirc2ps_detach(struct pcmcia_device *p_dev)
641{ 641{
642 dev_link_t *link = dev_to_instance(p_dev);
642 struct net_device *dev = link->priv; 643 struct net_device *dev = link->priv;
643 dev_link_t **linkp; 644 dev_link_t **linkp;
644 645
@@ -656,19 +657,9 @@ xirc2ps_detach(dev_link_t * link)
656 if (link->dev) 657 if (link->dev)
657 unregister_netdev(dev); 658 unregister_netdev(dev);
658 659
659 /*
660 * If the device is currently configured and active, we won't
661 * actually delete it yet. Instead, it is marked so that when
662 * the release() function is called, that will trigger a proper
663 * detach().
664 */
665 if (link->state & DEV_CONFIG) 660 if (link->state & DEV_CONFIG)
666 xirc2ps_release(link); 661 xirc2ps_release(link);
667 662
668 /* Break the link with Card Services */
669 if (link->handle)
670 pcmcia_deregister_client(link->handle);
671
672 /* Unlink device structure, free it */ 663 /* Unlink device structure, free it */
673 *linkp = link->next; 664 *linkp = link->next;
674 free_netdev(dev); 665 free_netdev(dev);
@@ -1209,19 +1200,10 @@ xirc2ps_event(event_t event, int priority,
1209 event_callback_args_t * args) 1200 event_callback_args_t * args)
1210{ 1201{
1211 dev_link_t *link = args->client_data; 1202 dev_link_t *link = args->client_data;
1212 struct net_device *dev = link->priv;
1213 1203
1214 DEBUG(0, "event(%d)\n", (int)event); 1204 DEBUG(0, "event(%d)\n", (int)event);
1215 1205
1216 switch (event) { 1206 switch (event) {
1217 case CS_EVENT_REGISTRATION_COMPLETE:
1218 DEBUG(0, "registration complete\n");
1219 break;
1220 case CS_EVENT_CARD_REMOVAL:
1221 link->state &= ~DEV_PRESENT;
1222 if (link->state & DEV_CONFIG)
1223 netif_device_detach(dev);
1224 break;
1225 case CS_EVENT_CARD_INSERTION: 1207 case CS_EVENT_CARD_INSERTION:
1226 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1208 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1227 xirc2ps_config(link); 1209 xirc2ps_config(link);
@@ -2022,7 +2004,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = {
2022 }, 2004 },
2023 .attach = xirc2ps_attach, 2005 .attach = xirc2ps_attach,
2024 .event = xirc2ps_event, 2006 .event = xirc2ps_event,
2025 .detach = xirc2ps_detach, 2007 .remove = xirc2ps_detach,
2026 .id_table = xirc2ps_ids, 2008 .id_table = xirc2ps_ids,
2027 .suspend = xirc2ps_suspend, 2009 .suspend = xirc2ps_suspend,
2028 .resume = xirc2ps_resume, 2010 .resume = xirc2ps_resume,
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 80c9de749b52..7a28139544c0 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -92,7 +92,7 @@ static int airo_event(event_t event, int priority,
92*/ 92*/
93 93
94static dev_link_t *airo_attach(void); 94static dev_link_t *airo_attach(void);
95static void airo_detach(dev_link_t *); 95static void airo_detach(struct pcmcia_device *p_dev);
96 96
97/* 97/*
98 You'll also need to prototype all the functions that will actually 98 You'll also need to prototype all the functions that will actually
@@ -210,7 +210,7 @@ static dev_link_t *airo_attach(void)
210 ret = pcmcia_register_client(&link->handle, &client_reg); 210 ret = pcmcia_register_client(&link->handle, &client_reg);
211 if (ret != 0) { 211 if (ret != 0) {
212 cs_error(link->handle, RegisterClient, ret); 212 cs_error(link->handle, RegisterClient, ret);
213 airo_detach(link); 213 airo_detach(link->handle);
214 return NULL; 214 return NULL;
215 } 215 }
216 216
@@ -226,8 +226,9 @@ static dev_link_t *airo_attach(void)
226 226
227 ======================================================================*/ 227 ======================================================================*/
228 228
229static void airo_detach(dev_link_t *link) 229static void airo_detach(struct pcmcia_device *p_dev)
230{ 230{
231 dev_link_t *link = dev_to_instance(p_dev);
231 dev_link_t **linkp; 232 dev_link_t **linkp;
232 233
233 DEBUG(0, "airo_detach(0x%p)\n", link); 234 DEBUG(0, "airo_detach(0x%p)\n", link);
@@ -244,14 +245,8 @@ static void airo_detach(dev_link_t *link)
244 if ( ((local_info_t*)link->priv)->eth_dev ) { 245 if ( ((local_info_t*)link->priv)->eth_dev ) {
245 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); 246 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 );
246 } 247 }
247 ((local_info_t*)link->priv)->eth_dev = NULL; 248 ((local_info_t*)link->priv)->eth_dev = NULL;
248 249
249 /* Break the link with Card Services */
250 if (link->handle)
251 pcmcia_deregister_client(link->handle);
252
253
254
255 /* Unlink device structure, free pieces */ 250 /* Unlink device structure, free pieces */
256 *linkp = link->next; 251 *linkp = link->next;
257 kfree(link->priv); 252 kfree(link->priv);
@@ -537,18 +532,10 @@ static int airo_event(event_t event, int priority,
537 event_callback_args_t *args) 532 event_callback_args_t *args)
538{ 533{
539 dev_link_t *link = args->client_data; 534 dev_link_t *link = args->client_data;
540 local_info_t *local = link->priv; 535
541
542 DEBUG(1, "airo_event(0x%06x)\n", event); 536 DEBUG(1, "airo_event(0x%06x)\n", event);
543 537
544 switch (event) { 538 switch (event) {
545 case CS_EVENT_CARD_REMOVAL:
546 link->state &= ~DEV_PRESENT;
547 if (link->state & DEV_CONFIG) {
548 netif_device_detach(local->eth_dev);
549 airo_release(link);
550 }
551 break;
552 case CS_EVENT_CARD_INSERTION: 539 case CS_EVENT_CARD_INSERTION:
553 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 540 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
554 airo_config(link); 541 airo_config(link);
@@ -573,7 +560,7 @@ static struct pcmcia_driver airo_driver = {
573 }, 560 },
574 .attach = airo_attach, 561 .attach = airo_attach,
575 .event = airo_event, 562 .event = airo_event,
576 .detach = airo_detach, 563 .remove = airo_detach,
577 .id_table = airo_ids, 564 .id_table = airo_ids,
578 .suspend = airo_suspend, 565 .suspend = airo_suspend,
579 .resume = airo_resume, 566 .resume = airo_resume,
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 598a9cd0f83e..3ab33dd49ea2 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -103,7 +103,7 @@ static int atmel_event(event_t event, int priority,
103*/ 103*/
104 104
105static dev_link_t *atmel_attach(void); 105static dev_link_t *atmel_attach(void);
106static void atmel_detach(dev_link_t *); 106static void atmel_detach(struct pcmcia_device *p_dev);
107 107
108/* 108/*
109 You'll also need to prototype all the functions that will actually 109 You'll also need to prototype all the functions that will actually
@@ -221,7 +221,7 @@ static dev_link_t *atmel_attach(void)
221 ret = pcmcia_register_client(&link->handle, &client_reg); 221 ret = pcmcia_register_client(&link->handle, &client_reg);
222 if (ret != 0) { 222 if (ret != 0) {
223 cs_error(link->handle, RegisterClient, ret); 223 cs_error(link->handle, RegisterClient, ret);
224 atmel_detach(link); 224 atmel_detach(link->handle);
225 return NULL; 225 return NULL;
226 } 226 }
227 227
@@ -237,8 +237,9 @@ static dev_link_t *atmel_attach(void)
237 237
238 ======================================================================*/ 238 ======================================================================*/
239 239
240static void atmel_detach(dev_link_t *link) 240static void atmel_detach(struct pcmcia_device *p_dev)
241{ 241{
242 dev_link_t *link = dev_to_instance(p_dev);
242 dev_link_t **linkp; 243 dev_link_t **linkp;
243 244
244 DEBUG(0, "atmel_detach(0x%p)\n", link); 245 DEBUG(0, "atmel_detach(0x%p)\n", link);
@@ -252,10 +253,6 @@ static void atmel_detach(dev_link_t *link)
252 if (link->state & DEV_CONFIG) 253 if (link->state & DEV_CONFIG)
253 atmel_release(link); 254 atmel_release(link);
254 255
255 /* Break the link with Card Services */
256 if (link->handle)
257 pcmcia_deregister_client(link->handle);
258
259 /* Unlink device structure, free pieces */ 256 /* Unlink device structure, free pieces */
260 *linkp = link->next; 257 *linkp = link->next;
261 kfree(link->priv); 258 kfree(link->priv);
@@ -522,18 +519,10 @@ static int atmel_event(event_t event, int priority,
522 event_callback_args_t *args) 519 event_callback_args_t *args)
523{ 520{
524 dev_link_t *link = args->client_data; 521 dev_link_t *link = args->client_data;
525 local_info_t *local = link->priv; 522
526
527 DEBUG(1, "atmel_event(0x%06x)\n", event); 523 DEBUG(1, "atmel_event(0x%06x)\n", event);
528 524
529 switch (event) { 525 switch (event) {
530 case CS_EVENT_CARD_REMOVAL:
531 link->state &= ~DEV_PRESENT;
532 if (link->state & DEV_CONFIG) {
533 netif_device_detach(local->eth_dev);
534 atmel_release(link);
535 }
536 break;
537 case CS_EVENT_CARD_INSERTION: 526 case CS_EVENT_CARD_INSERTION:
538 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 527 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
539 atmel_config(link); 528 atmel_config(link);
@@ -593,7 +582,7 @@ static struct pcmcia_driver atmel_driver = {
593 }, 582 },
594 .attach = atmel_attach, 583 .attach = atmel_attach,
595 .event = atmel_event, 584 .event = atmel_event,
596 .detach = atmel_detach, 585 .remove = atmel_detach,
597 .id_table = atmel_ids, 586 .id_table = atmel_ids,
598 .suspend = atmel_suspend, 587 .suspend = atmel_suspend,
599 .resume = atmel_resume, 588 .resume = atmel_resume,
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index ba4a7da98ccd..866142af7d92 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -203,7 +203,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
203 203
204 204
205 205
206static void prism2_detach(dev_link_t *link); 206static void prism2_detach(struct pcmcia_device *p_dev);
207static void prism2_release(u_long arg); 207static void prism2_release(u_long arg);
208static int prism2_event(event_t event, int priority, 208static int prism2_event(event_t event, int priority,
209 event_callback_args_t *args); 209 event_callback_args_t *args);
@@ -528,15 +528,16 @@ static dev_link_t *prism2_attach(void)
528 ret = pcmcia_register_client(&link->handle, &client_reg); 528 ret = pcmcia_register_client(&link->handle, &client_reg);
529 if (ret != CS_SUCCESS) { 529 if (ret != CS_SUCCESS) {
530 cs_error(link->handle, RegisterClient, ret); 530 cs_error(link->handle, RegisterClient, ret);
531 prism2_detach(link); 531 prism2_detach(link->handle);
532 return NULL; 532 return NULL;
533 } 533 }
534 return link; 534 return link;
535} 535}
536 536
537 537
538static void prism2_detach(dev_link_t *link) 538static void prism2_detach(struct pcmcia_device *p_dev)
539{ 539{
540 dev_link_t *link = dev_to_instance(p_dev);
540 dev_link_t **linkp; 541 dev_link_t **linkp;
541 542
542 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 543 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
@@ -554,14 +555,6 @@ static void prism2_detach(dev_link_t *link)
554 prism2_release((u_long)link); 555 prism2_release((u_long)link);
555 } 556 }
556 557
557 if (link->handle) {
558 int res = pcmcia_deregister_client(link->handle);
559 if (res) {
560 printk("CardService(DeregisterClient) => %d\n", res);
561 cs_error(link->handle, DeregisterClient, res);
562 }
563 }
564
565 *linkp = link->next; 558 *linkp = link->next;
566 /* release net devices */ 559 /* release net devices */
567 if (link->priv) { 560 if (link->priv) {
@@ -902,7 +895,6 @@ static int prism2_event(event_t event, int priority,
902 event_callback_args_t *args) 895 event_callback_args_t *args)
903{ 896{
904 dev_link_t *link = args->client_data; 897 dev_link_t *link = args->client_data;
905 struct net_device *dev = (struct net_device *) link->priv;
906 898
907 switch (event) { 899 switch (event) {
908 case CS_EVENT_CARD_INSERTION: 900 case CS_EVENT_CARD_INSERTION:
@@ -913,16 +905,6 @@ static int prism2_event(event_t event, int priority,
913 } 905 }
914 break; 906 break;
915 907
916 case CS_EVENT_CARD_REMOVAL:
917 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info);
918 link->state &= ~DEV_PRESENT;
919 if (link->state & DEV_CONFIG) {
920 netif_stop_queue(dev);
921 netif_device_detach(dev);
922 prism2_release((u_long) link);
923 }
924 break;
925
926 default: 908 default:
927 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", 909 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n",
928 dev_info, event); 910 dev_info, event);
@@ -991,7 +973,7 @@ static struct pcmcia_driver hostap_driver = {
991 .name = "hostap_cs", 973 .name = "hostap_cs",
992 }, 974 },
993 .attach = prism2_attach, 975 .attach = prism2_attach,
994 .detach = prism2_detach, 976 .remove = prism2_detach,
995 .owner = THIS_MODULE, 977 .owner = THIS_MODULE,
996 .event = prism2_event, 978 .event = prism2_event,
997 .id_table = hostap_cs_ids, 979 .id_table = hostap_cs_ids,
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 7ab2d70ffddf..1770677d9e10 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -200,7 +200,7 @@ static int netwave_event(event_t event, int priority,
200static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card 200static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card
201 insertion */ 201 insertion */
202static dev_link_t *netwave_attach(void); /* Create instance */ 202static dev_link_t *netwave_attach(void); /* Create instance */
203static void netwave_detach(dev_link_t *); /* Destroy instance */ 203static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
204 204
205/* Hardware configuration */ 205/* Hardware configuration */
206static void netwave_doreset(kio_addr_t iobase, u_char __iomem *ramBase); 206static void netwave_doreset(kio_addr_t iobase, u_char __iomem *ramBase);
@@ -459,7 +459,7 @@ static dev_link_t *netwave_attach(void)
459 ret = pcmcia_register_client(&link->handle, &client_reg); 459 ret = pcmcia_register_client(&link->handle, &client_reg);
460 if (ret != 0) { 460 if (ret != 0) {
461 cs_error(link->handle, RegisterClient, ret); 461 cs_error(link->handle, RegisterClient, ret);
462 netwave_detach(link); 462 netwave_detach(link->handle);
463 return NULL; 463 return NULL;
464 } 464 }
465 465
@@ -474,8 +474,9 @@ static dev_link_t *netwave_attach(void)
474 * structures are freed. Otherwise, the structures will be freed 474 * structures are freed. Otherwise, the structures will be freed
475 * when the device is released. 475 * when the device is released.
476 */ 476 */
477static void netwave_detach(dev_link_t *link) 477static void netwave_detach(struct pcmcia_device *p_dev)
478{ 478{
479 dev_link_t *link = dev_to_instance(p_dev);
479 struct net_device *dev = link->priv; 480 struct net_device *dev = link->priv;
480 dev_link_t **linkp; 481 dev_link_t **linkp;
481 482
@@ -489,11 +490,7 @@ static void netwave_detach(dev_link_t *link)
489 */ 490 */
490 if (link->state & DEV_CONFIG) 491 if (link->state & DEV_CONFIG)
491 netwave_release(link); 492 netwave_release(link);
492 493
493 /* Break the link with Card Services */
494 if (link->handle)
495 pcmcia_deregister_client(link->handle);
496
497 /* Locate device structure */ 494 /* Locate device structure */
498 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 495 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
499 if (*linkp == link) break; 496 if (*linkp == link) break;
@@ -986,22 +983,10 @@ static int netwave_event(event_t event, int priority,
986 event_callback_args_t *args) 983 event_callback_args_t *args)
987{ 984{
988 dev_link_t *link = args->client_data; 985 dev_link_t *link = args->client_data;
989 struct net_device *dev = link->priv; 986
990
991 DEBUG(1, "netwave_event(0x%06x)\n", event); 987 DEBUG(1, "netwave_event(0x%06x)\n", event);
992
993 switch (event) {
994 case CS_EVENT_REGISTRATION_COMPLETE:
995 DEBUG(0, "netwave_cs: registration complete\n");
996 break;
997 988
998 case CS_EVENT_CARD_REMOVAL: 989 switch (event) {
999 link->state &= ~DEV_PRESENT;
1000 if (link->state & DEV_CONFIG) {
1001 netif_device_detach(dev);
1002 netwave_release(link);
1003 }
1004 break;
1005 case CS_EVENT_CARD_INSERTION: 990 case CS_EVENT_CARD_INSERTION:
1006 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 991 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1007 netwave_pcmcia_config( link); 992 netwave_pcmcia_config( link);
@@ -1504,7 +1489,7 @@ static struct pcmcia_driver netwave_driver = {
1504 }, 1489 },
1505 .attach = netwave_attach, 1490 .attach = netwave_attach,
1506 .event = netwave_event, 1491 .event = netwave_event,
1507 .detach = netwave_detach, 1492 .remove = netwave_detach,
1508 .id_table = netwave_ids, 1493 .id_table = netwave_ids,
1509 .suspend = netwave_suspend, 1494 .suspend = netwave_suspend,
1510 .resume = netwave_resume, 1495 .resume = netwave_resume,
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 1d66050e3d6a..00679b6c87c1 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -81,7 +81,7 @@ static dev_link_t *dev_list; /* = NULL */
81/********************************************************************/ 81/********************************************************************/
82 82
83static void orinoco_cs_release(dev_link_t *link); 83static void orinoco_cs_release(dev_link_t *link);
84static void orinoco_cs_detach(dev_link_t *link); 84static void orinoco_cs_detach(struct pcmcia_device *p_dev);
85 85
86/********************************************************************/ 86/********************************************************************/
87/* Device methods */ 87/* Device methods */
@@ -165,7 +165,7 @@ orinoco_cs_attach(void)
165 ret = pcmcia_register_client(&link->handle, &client_reg); 165 ret = pcmcia_register_client(&link->handle, &client_reg);
166 if (ret != CS_SUCCESS) { 166 if (ret != CS_SUCCESS) {
167 cs_error(link->handle, RegisterClient, ret); 167 cs_error(link->handle, RegisterClient, ret);
168 orinoco_cs_detach(link); 168 orinoco_cs_detach(link->handle);
169 return NULL; 169 return NULL;
170 } 170 }
171 171
@@ -178,8 +178,9 @@ orinoco_cs_attach(void)
178 * are freed. Otherwise, the structures will be freed when the device 178 * are freed. Otherwise, the structures will be freed when the device
179 * is released. 179 * is released.
180 */ 180 */
181static void orinoco_cs_detach(dev_link_t *link) 181static void orinoco_cs_detach(struct pcmcia_device *p_dev)
182{ 182{
183 dev_link_t *link = dev_to_instance(p_dev);
183 dev_link_t **linkp; 184 dev_link_t **linkp;
184 struct net_device *dev = link->priv; 185 struct net_device *dev = link->priv;
185 186
@@ -193,10 +194,6 @@ static void orinoco_cs_detach(dev_link_t *link)
193 if (link->state & DEV_CONFIG) 194 if (link->state & DEV_CONFIG)
194 orinoco_cs_release(link); 195 orinoco_cs_release(link);
195 196
196 /* Break the link with Card Services */
197 if (link->handle)
198 pcmcia_deregister_client(link->handle);
199
200 /* Unlink device structure, and free it */ 197 /* Unlink device structure, and free it */
201 *linkp = link->next; 198 *linkp = link->next;
202 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 199 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
@@ -551,30 +548,15 @@ orinoco_cs_event(event_t event, int priority,
551 event_callback_args_t * args) 548 event_callback_args_t * args)
552{ 549{
553 dev_link_t *link = args->client_data; 550 dev_link_t *link = args->client_data;
554 struct net_device *dev = link->priv;
555 struct orinoco_private *priv = netdev_priv(dev);
556 int err = 0;
557 551
558 switch (event) { 552 switch (event) {
559 case CS_EVENT_CARD_REMOVAL:
560 link->state &= ~DEV_PRESENT;
561 if (link->state & DEV_CONFIG) {
562 unsigned long flags;
563
564 spin_lock_irqsave(&priv->lock, flags);
565 netif_device_detach(dev);
566 priv->hw_unavailable++;
567 spin_unlock_irqrestore(&priv->lock, flags);
568 }
569 break;
570
571 case CS_EVENT_CARD_INSERTION: 553 case CS_EVENT_CARD_INSERTION:
572 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 554 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
573 orinoco_cs_config(link); 555 orinoco_cs_config(link);
574 break; 556 break;
575 } 557 }
576 558
577 return err; 559 return 0;
578} /* orinoco_cs_event */ 560} /* orinoco_cs_event */
579 561
580/********************************************************************/ 562/********************************************************************/
@@ -677,7 +659,7 @@ static struct pcmcia_driver orinoco_driver = {
677 .name = DRIVER_NAME, 659 .name = DRIVER_NAME,
678 }, 660 },
679 .attach = orinoco_cs_attach, 661 .attach = orinoco_cs_attach,
680 .detach = orinoco_cs_detach, 662 .remove = orinoco_cs_detach,
681 .event = orinoco_cs_event, 663 .event = orinoco_cs_event,
682 .id_table = orinoco_cs_ids, 664 .id_table = orinoco_cs_ids,
683 .suspend = orinoco_cs_suspend, 665 .suspend = orinoco_cs_suspend,
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index c2cb6c8e6d7c..33a89e292126 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -94,7 +94,7 @@ static void ray_config(dev_link_t *link);
94static void ray_release(dev_link_t *link); 94static void ray_release(dev_link_t *link);
95static int ray_event(event_t event, int priority, event_callback_args_t *args); 95static int ray_event(event_t event, int priority, event_callback_args_t *args);
96static dev_link_t *ray_attach(void); 96static dev_link_t *ray_attach(void);
97static void ray_detach(dev_link_t *); 97static void ray_detach(struct pcmcia_device *p_dev);
98 98
99/***** Prototypes indicated by device structure ******************************/ 99/***** Prototypes indicated by device structure ******************************/
100static int ray_dev_close(struct net_device *dev); 100static int ray_dev_close(struct net_device *dev);
@@ -402,7 +402,7 @@ static dev_link_t *ray_attach(void)
402 if (ret != 0) { 402 if (ret != 0) {
403 printk("ray_cs ray_attach RegisterClient unhappy - detaching\n"); 403 printk("ray_cs ray_attach RegisterClient unhappy - detaching\n");
404 cs_error(link->handle, RegisterClient, ret); 404 cs_error(link->handle, RegisterClient, ret);
405 ray_detach(link); 405 ray_detach(link->handle);
406 return NULL; 406 return NULL;
407 } 407 }
408 DEBUG(2,"ray_cs ray_attach ending\n"); 408 DEBUG(2,"ray_cs ray_attach ending\n");
@@ -418,9 +418,12 @@ fail_alloc_dev:
418 structures are freed. Otherwise, the structures will be freed 418 structures are freed. Otherwise, the structures will be freed
419 when the device is released. 419 when the device is released.
420=============================================================================*/ 420=============================================================================*/
421static void ray_detach(dev_link_t *link) 421static void ray_detach(struct pcmcia_device *p_dev)
422{ 422{
423 dev_link_t *link = dev_to_instance(p_dev);
423 dev_link_t **linkp; 424 dev_link_t **linkp;
425 struct net_device *dev;
426 ray_dev_t *local;
424 427
425 DEBUG(1, "ray_detach(0x%p)\n", link); 428 DEBUG(1, "ray_detach(0x%p)\n", link);
426 429
@@ -430,22 +433,18 @@ static void ray_detach(dev_link_t *link)
430 if (*linkp == NULL) 433 if (*linkp == NULL)
431 return; 434 return;
432 435
433 /* If the device is currently configured and active, we won't 436 dev = link->priv;
434 actually delete it yet. Instead, it is marked so that when 437
435 the release() function is called, that will trigger a proper 438 if (link->state & DEV_CONFIG) {
436 detach(). 439 ray_release(link);
437 */ 440
438 if (link->state & DEV_CONFIG) 441 local = (ray_dev_t *)dev->priv;
439 ray_release(link); 442 del_timer(&local->timer);
443 }
440 444
441 /* Break the link with Card Services */
442 if (link->handle)
443 pcmcia_deregister_client(link->handle);
444
445 /* Unlink device structure, free pieces */ 445 /* Unlink device structure, free pieces */
446 *linkp = link->next; 446 *linkp = link->next;
447 if (link->priv) { 447 if (link->priv) {
448 struct net_device *dev = link->priv;
449 if (link->dev) unregister_netdev(dev); 448 if (link->dev) unregister_netdev(dev);
450 free_netdev(dev); 449 free_netdev(dev);
451 } 450 }
@@ -940,19 +939,9 @@ static int ray_event(event_t event, int priority,
940 event_callback_args_t *args) 939 event_callback_args_t *args)
941{ 940{
942 dev_link_t *link = args->client_data; 941 dev_link_t *link = args->client_data;
943 struct net_device *dev = link->priv;
944 ray_dev_t *local = (ray_dev_t *)dev->priv;
945 DEBUG(1, "ray_event(0x%06x)\n", event); 942 DEBUG(1, "ray_event(0x%06x)\n", event);
946 943
947 switch (event) { 944 switch (event) {
948 case CS_EVENT_CARD_REMOVAL:
949 link->state &= ~DEV_PRESENT;
950 netif_device_detach(dev);
951 if (link->state & DEV_CONFIG) {
952 ray_release(link);
953 del_timer(&local->timer);
954 }
955 break;
956 case CS_EVENT_CARD_INSERTION: 945 case CS_EVENT_CARD_INSERTION:
957 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 946 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
958 ray_config(link); 947 ray_config(link);
@@ -2958,7 +2947,7 @@ static struct pcmcia_driver ray_driver = {
2958 }, 2947 },
2959 .attach = ray_attach, 2948 .attach = ray_attach,
2960 .event = ray_event, 2949 .event = ray_event,
2961 .detach = ray_detach, 2950 .remove = ray_detach,
2962 .id_table = ray_ids, 2951 .id_table = ray_ids,
2963 .suspend = ray_suspend, 2952 .suspend = ray_suspend,
2964 .resume = ray_resume, 2953 .resume = ray_resume,
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 3938a5735659..a2dcab7995c1 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -90,7 +90,7 @@ static dev_link_t *dev_list; /* = NULL */
90/********************************************************************/ 90/********************************************************************/
91 91
92static void spectrum_cs_release(dev_link_t *link); 92static void spectrum_cs_release(dev_link_t *link);
93static void spectrum_cs_detach(dev_link_t *link); 93static void spectrum_cs_detach(struct pcmcia_device *p_dev);
94 94
95/********************************************************************/ 95/********************************************************************/
96/* Firmware downloader */ 96/* Firmware downloader */
@@ -647,7 +647,7 @@ spectrum_cs_attach(void)
647 ret = pcmcia_register_client(&link->handle, &client_reg); 647 ret = pcmcia_register_client(&link->handle, &client_reg);
648 if (ret != CS_SUCCESS) { 648 if (ret != CS_SUCCESS) {
649 cs_error(link->handle, RegisterClient, ret); 649 cs_error(link->handle, RegisterClient, ret);
650 spectrum_cs_detach(link); 650 spectrum_cs_detach(link->handle);
651 return NULL; 651 return NULL;
652 } 652 }
653 653
@@ -660,27 +660,14 @@ spectrum_cs_attach(void)
660 * are freed. Otherwise, the structures will be freed when the device 660 * are freed. Otherwise, the structures will be freed when the device
661 * is released. 661 * is released.
662 */ 662 */
663static void spectrum_cs_detach(dev_link_t *link) 663static void spectrum_cs_detach(struct pcmcia_device *p_dev)
664{ 664{
665 dev_link_t **linkp; 665 dev_link_t *link = dev_to_instance(p_dev);
666 struct net_device *dev = link->priv; 666 struct net_device *dev = link->priv;
667 667
668 /* Locate device structure */
669 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
670 if (*linkp == link)
671 break;
672
673 BUG_ON(*linkp == NULL);
674
675 if (link->state & DEV_CONFIG) 668 if (link->state & DEV_CONFIG)
676 spectrum_cs_release(link); 669 spectrum_cs_release(link);
677 670
678 /* Break the link with Card Services */
679 if (link->handle)
680 pcmcia_deregister_client(link->handle);
681
682 /* Unlink device structure, and free it */
683 *linkp = link->next;
684 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 671 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
685 if (link->dev) { 672 if (link->dev) {
686 DEBUG(0, PFX "About to unregister net device %p\n", 673 DEBUG(0, PFX "About to unregister net device %p\n",
@@ -1007,22 +994,8 @@ spectrum_cs_event(event_t event, int priority,
1007 event_callback_args_t * args) 994 event_callback_args_t * args)
1008{ 995{
1009 dev_link_t *link = args->client_data; 996 dev_link_t *link = args->client_data;
1010 struct net_device *dev = link->priv;
1011 struct orinoco_private *priv = netdev_priv(dev);
1012 997
1013 switch (event) { 998 switch (event) {
1014 case CS_EVENT_CARD_REMOVAL:
1015 link->state &= ~DEV_PRESENT;
1016 if (link->state & DEV_CONFIG) {
1017 unsigned long flags;
1018
1019 spin_lock_irqsave(&priv->lock, flags);
1020 netif_device_detach(dev);
1021 priv->hw_unavailable++;
1022 spin_unlock_irqrestore(&priv->lock, flags);
1023 }
1024 break;
1025
1026 case CS_EVENT_CARD_INSERTION: 999 case CS_EVENT_CARD_INSERTION:
1027 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1000 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1028 spectrum_cs_config(link); 1001 spectrum_cs_config(link);
@@ -1057,7 +1030,7 @@ static struct pcmcia_driver orinoco_driver = {
1057 .name = DRIVER_NAME, 1030 .name = DRIVER_NAME,
1058 }, 1031 },
1059 .attach = spectrum_cs_attach, 1032 .attach = spectrum_cs_attach,
1060 .detach = spectrum_cs_detach, 1033 .remove = spectrum_cs_detach,
1061 .suspend = spectrum_cs_suspend, 1034 .suspend = spectrum_cs_suspend,
1062 .resume = spectrum_cs_resume, 1035 .resume = spectrum_cs_resume,
1063 .event = spectrum_cs_event, 1036 .event = spectrum_cs_event,
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 3e3532830c26..255952d8cea0 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4692,7 +4692,7 @@ wavelan_attach(void)
4692 if(ret != 0) 4692 if(ret != 0)
4693 { 4693 {
4694 cs_error(link->handle, RegisterClient, ret); 4694 cs_error(link->handle, RegisterClient, ret);
4695 wavelan_detach(link); 4695 wavelan_detach(link->handle);
4696 return NULL; 4696 return NULL;
4697 } 4697 }
4698 4698
@@ -4711,8 +4711,10 @@ wavelan_attach(void)
4711 * is released. 4711 * is released.
4712 */ 4712 */
4713static void 4713static void
4714wavelan_detach(dev_link_t * link) 4714wavelan_detach(struct pcmcia_device *p_dev)
4715{ 4715{
4716 dev_link_t *link = dev_to_instance(p_dev);
4717
4716#ifdef DEBUG_CALLBACK_TRACE 4718#ifdef DEBUG_CALLBACK_TRACE
4717 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); 4719 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link);
4718#endif 4720#endif
@@ -4729,10 +4731,6 @@ wavelan_detach(dev_link_t * link)
4729 wv_pcmcia_release(link); 4731 wv_pcmcia_release(link);
4730 } 4732 }
4731 4733
4732 /* Break the link with Card Services */
4733 if(link->handle)
4734 pcmcia_deregister_client(link->handle);
4735
4736 /* Remove the interface data from the linked list */ 4734 /* Remove the interface data from the linked list */
4737 if(dev_list == link) 4735 if(dev_list == link)
4738 dev_list = link->next; 4736 dev_list = link->next;
@@ -4854,25 +4852,6 @@ wavelan_event(event_t event, /* The event received */
4854 4852
4855 switch(event) 4853 switch(event)
4856 { 4854 {
4857 case CS_EVENT_REGISTRATION_COMPLETE:
4858#ifdef DEBUG_CONFIG_INFO
4859 printk(KERN_DEBUG "wavelan_cs: registration complete\n");
4860#endif
4861 break;
4862
4863 case CS_EVENT_CARD_REMOVAL:
4864 /* Oups ! The card is no more there */
4865 link->state &= ~DEV_PRESENT;
4866 if(link->state & DEV_CONFIG)
4867 {
4868 /* Accept no more transmissions */
4869 netif_device_detach(dev);
4870
4871 /* Release the card */
4872 wv_pcmcia_release(link);
4873 }
4874 break;
4875
4876 case CS_EVENT_CARD_INSERTION: 4855 case CS_EVENT_CARD_INSERTION:
4877 /* Reset and configure the card */ 4856 /* Reset and configure the card */
4878 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 4857 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
@@ -4906,7 +4885,7 @@ static struct pcmcia_driver wavelan_driver = {
4906 }, 4885 },
4907 .attach = wavelan_attach, 4886 .attach = wavelan_attach,
4908 .event = wavelan_event, 4887 .event = wavelan_event,
4909 .detach = wavelan_detach, 4888 .remove = wavelan_detach,
4910 .id_table = wavelan_ids, 4889 .id_table = wavelan_ids,
4911 .suspend = wavelan_suspend, 4890 .suspend = wavelan_suspend,
4912 .resume = wavelan_resume, 4891 .resume = wavelan_resume,
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index 724a715089c9..3cb34817c039 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -757,7 +757,7 @@ static int
757static dev_link_t * 757static dev_link_t *
758 wavelan_attach(void); /* Create a new device */ 758 wavelan_attach(void); /* Create a new device */
759static void 759static void
760 wavelan_detach(dev_link_t *); /* Destroy a removed device */ 760 wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */
761static int 761static int
762 wavelan_event(event_t, /* Manage pcmcia events */ 762 wavelan_event(event_t, /* Manage pcmcia events */
763 int, 763 int,
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 75114318457e..21e498fe7b14 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1498,9 +1498,11 @@ static struct ethtool_ops ops = {
1498 * Services. If it has been released, all local data structures are freed. 1498 * Services. If it has been released, all local data structures are freed.
1499 * Otherwise, the structures will be freed when the device is released. 1499 * Otherwise, the structures will be freed when the device is released.
1500 */ 1500 */
1501static void wl3501_detach(dev_link_t *link) 1501static void wl3501_detach(struct pcmcia_device *p_dev)
1502{ 1502{
1503 dev_link_t *link = dev_to_instance(p_dev);
1503 dev_link_t **linkp; 1504 dev_link_t **linkp;
1505 struct net_device *dev = link->priv;
1504 1506
1505 /* Locate device structure */ 1507 /* Locate device structure */
1506 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next) 1508 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
@@ -1514,16 +1516,12 @@ static void wl3501_detach(dev_link_t *link)
1514 * function is called, that will trigger a proper detach(). */ 1516 * function is called, that will trigger a proper detach(). */
1515 1517
1516 if (link->state & DEV_CONFIG) { 1518 if (link->state & DEV_CONFIG) {
1517#ifdef PCMCIA_DEBUG 1519 while (link->open > 0)
1518 printk(KERN_DEBUG "wl3501_cs: detach postponed, '%s' " 1520 wl3501_close(dev);
1519 "still locked\n", link->dev->dev_name);
1520#endif
1521 goto out;
1522 }
1523 1521
1524 /* Break the link with Card Services */ 1522 netif_device_detach(dev);
1525 if (link->handle) 1523 wl3501_release(link);
1526 pcmcia_deregister_client(link->handle); 1524 }
1527 1525
1528 /* Unlink device structure, free pieces */ 1526 /* Unlink device structure, free pieces */
1529 *linkp = link->next; 1527 *linkp = link->next;
@@ -2012,7 +2010,7 @@ static dev_link_t *wl3501_attach(void)
2012 ret = pcmcia_register_client(&link->handle, &client_reg); 2010 ret = pcmcia_register_client(&link->handle, &client_reg);
2013 if (ret) { 2011 if (ret) {
2014 cs_error(link->handle, RegisterClient, ret); 2012 cs_error(link->handle, RegisterClient, ret);
2015 wl3501_detach(link); 2013 wl3501_detach(link->handle);
2016 link = NULL; 2014 link = NULL;
2017 } 2015 }
2018out: 2016out:
@@ -2225,18 +2223,8 @@ static int wl3501_resume(struct pcmcia_device *p_dev)
2225static int wl3501_event(event_t event, int pri, event_callback_args_t *args) 2223static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2226{ 2224{
2227 dev_link_t *link = args->client_data; 2225 dev_link_t *link = args->client_data;
2228 struct net_device *dev = link->priv;
2229 2226
2230 switch (event) { 2227 switch (event) {
2231 case CS_EVENT_CARD_REMOVAL:
2232 link->state &= ~DEV_PRESENT;
2233 if (link->state & DEV_CONFIG) {
2234 while (link->open > 0)
2235 wl3501_close(dev);
2236 netif_device_detach(dev);
2237 wl3501_release(link);
2238 }
2239 break;
2240 case CS_EVENT_CARD_INSERTION: 2228 case CS_EVENT_CARD_INSERTION:
2241 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 2229 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2242 wl3501_config(link); 2230 wl3501_config(link);
@@ -2258,7 +2246,7 @@ static struct pcmcia_driver wl3501_driver = {
2258 }, 2246 },
2259 .attach = wl3501_attach, 2247 .attach = wl3501_attach,
2260 .event = wl3501_event, 2248 .event = wl3501_event,
2261 .detach = wl3501_detach, 2249 .remove = wl3501_detach,
2262 .id_table = wl3501_ids, 2250 .id_table = wl3501_ids,
2263 .suspend = wl3501_suspend, 2251 .suspend = wl3501_suspend,
2264 .resume = wl3501_resume, 2252 .resume = wl3501_resume,