aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:23:14 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 18:03:10 -0500
commitcc3b4866bee996c922e875b8c8efe9f0d8803aae (patch)
tree6632837b6986f33566f75ed971cecbdc210e3201 /drivers/net/pcmcia
parent8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 (diff)
[PATCH] pcmcia: unify detach, REMOVAL_EVENT handlers into one remove callback
Unify the "detach" and REMOVAL_EVENT handlers to one "remove" function. Old functionality is preserved, for the moment. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/pcmcia')
-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
10 files changed, 66 insertions, 163 deletions
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 80414a77fe7..60a3bc2b8fc 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 bbda681ac10..09b96c76216 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 6c6b2526565..11f701a8ff0 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 68612222de6..6970888cba1 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 388ecade13d..560d4ee2280 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 3a7218e51b7..96129498335 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 fa4921f8b9f..011ceb09032 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 7db4d6f3db4..fb3e411d6da 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 7c61ec90c2c..6cb5198d609 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 917e50ac37f..804e56771ba 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,