aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax
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/isdn/hisax
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/isdn/hisax')
-rw-r--r--drivers/isdn/hisax/avma1_cs.c39
-rw-r--r--drivers/isdn/hisax/elsa_cs.c26
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c38
-rw-r--r--drivers/isdn/hisax/teles_cs.c26
4 files changed, 29 insertions, 100 deletions
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 433cec4269a3..6b322e88c6c3 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -79,7 +79,7 @@ static int avma1cs_event(event_t event, int priority,
79*/ 79*/
80 80
81static dev_link_t *avma1cs_attach(void); 81static dev_link_t *avma1cs_attach(void);
82static void avma1cs_detach(dev_link_t *); 82static void avma1cs_detach(struct pcmcia_device *p_dev);
83 83
84/* 84/*
85 The dev_info variable is the "key" that is used to match up this 85 The dev_info variable is the "key" that is used to match up this
@@ -187,7 +187,7 @@ static dev_link_t *avma1cs_attach(void)
187 ret = pcmcia_register_client(&link->handle, &client_reg); 187 ret = pcmcia_register_client(&link->handle, &client_reg);
188 if (ret != 0) { 188 if (ret != 0) {
189 cs_error(link->handle, RegisterClient, ret); 189 cs_error(link->handle, RegisterClient, ret);
190 avma1cs_detach(link); 190 avma1cs_detach(link->handle);
191 return NULL; 191 return NULL;
192 } 192 }
193 193
@@ -203,42 +203,26 @@ static dev_link_t *avma1cs_attach(void)
203 203
204======================================================================*/ 204======================================================================*/
205 205
206static void avma1cs_detach(dev_link_t *link) 206static void avma1cs_detach(struct pcmcia_device *p_dev)
207{ 207{
208 dev_link_t *link = dev_to_instance(p_dev);
208 dev_link_t **linkp; 209 dev_link_t **linkp;
209 210
210 DEBUG(0, "avma1cs_detach(0x%p)\n", link); 211 DEBUG(0, "avma1cs_detach(0x%p)\n", link);
211 212
212 /* Locate device structure */ 213 /* Locate device structure */
213 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 214 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
214 if (*linkp == link) break; 215 if (*linkp == link) break;
215 if (*linkp == NULL) 216 if (*linkp == NULL)
216 return; 217 return;
217 218
218 /* 219 if (link->state & DEV_CONFIG)
219 If the device is currently configured and active, we won't 220 avma1cs_release(link);
220 actually delete it yet. Instead, it is marked so that when
221 the release() function is called, that will trigger a proper
222 detach().
223 */
224 if (link->state & DEV_CONFIG) {
225#ifdef PCMCIA_DEBUG
226 printk(KERN_DEBUG "avma1_cs: detach postponed, '%s' "
227 "still locked\n", link->dev->dev_name);
228#endif
229 link->state |= DEV_STALE_LINK;
230 return;
231 }
232 221
233 /* Break the link with Card Services */
234 if (link->handle)
235 pcmcia_deregister_client(link->handle);
236
237 /* Unlink device structure, free pieces */ 222 /* Unlink device structure, free pieces */
238 *linkp = link->next; 223 *linkp = link->next;
239 kfree(link->priv); 224 kfree(link->priv);
240 kfree(link); 225 kfree(link);
241
242} /* avma1cs_detach */ 226} /* avma1cs_detach */
243 227
244/*====================================================================== 228/*======================================================================
@@ -440,9 +424,6 @@ static void avma1cs_release(dev_link_t *link)
440 pcmcia_release_io(link->handle, &link->io); 424 pcmcia_release_io(link->handle, &link->io);
441 pcmcia_release_irq(link->handle, &link->irq); 425 pcmcia_release_irq(link->handle, &link->irq);
442 link->state &= ~DEV_CONFIG; 426 link->state &= ~DEV_CONFIG;
443
444 if (link->state & DEV_STALE_LINK)
445 avma1cs_detach(link);
446} /* avma1cs_release */ 427} /* avma1cs_release */
447 428
448static int avma1cs_suspend(struct pcmcia_device *dev) 429static int avma1cs_suspend(struct pcmcia_device *dev)
@@ -489,10 +470,6 @@ static int avma1cs_event(event_t event, int priority,
489 DEBUG(1, "avma1cs_event(0x%06x)\n", event); 470 DEBUG(1, "avma1cs_event(0x%06x)\n", event);
490 471
491 switch (event) { 472 switch (event) {
492 case CS_EVENT_CARD_REMOVAL:
493 if (link->state & DEV_CONFIG)
494 avma1cs_release(link);
495 break;
496 case CS_EVENT_CARD_INSERTION: 473 case CS_EVENT_CARD_INSERTION:
497 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 474 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
498 avma1cs_config(link); 475 avma1cs_config(link);
@@ -515,7 +492,7 @@ static struct pcmcia_driver avma1cs_driver = {
515 }, 492 },
516 .attach = avma1cs_attach, 493 .attach = avma1cs_attach,
517 .event = avma1cs_event, 494 .event = avma1cs_event,
518 .detach = avma1cs_detach, 495 .remove = avma1cs_detach,
519 .id_table = avma1cs_ids, 496 .id_table = avma1cs_ids,
520 .suspend = avma1cs_suspend, 497 .suspend = avma1cs_suspend,
521 .resume = avma1cs_resume, 498 .resume = avma1cs_resume,
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index 0cbe04593d87..48cc677249f1 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -106,7 +106,7 @@ static int elsa_cs_event(event_t event, int priority,
106*/ 106*/
107 107
108static dev_link_t *elsa_cs_attach(void); 108static dev_link_t *elsa_cs_attach(void);
109static void elsa_cs_detach(dev_link_t *); 109static void elsa_cs_detach(struct pcmcia_device *p_dev);
110 110
111/* 111/*
112 The dev_info variable is the "key" that is used to match up this 112 The dev_info variable is the "key" that is used to match up this
@@ -216,7 +216,7 @@ static dev_link_t *elsa_cs_attach(void)
216 ret = pcmcia_register_client(&link->handle, &client_reg); 216 ret = pcmcia_register_client(&link->handle, &client_reg);
217 if (ret != CS_SUCCESS) { 217 if (ret != CS_SUCCESS) {
218 cs_error(link->handle, RegisterClient, ret); 218 cs_error(link->handle, RegisterClient, ret);
219 elsa_cs_detach(link); 219 elsa_cs_detach(link->handle);
220 return NULL; 220 return NULL;
221 } 221 }
222 222
@@ -232,11 +232,11 @@ static dev_link_t *elsa_cs_attach(void)
232 232
233======================================================================*/ 233======================================================================*/
234 234
235static void elsa_cs_detach(dev_link_t *link) 235static void elsa_cs_detach(struct pcmcia_device *p_dev)
236{ 236{
237 dev_link_t *link = dev_to_instance(p_dev);
237 dev_link_t **linkp; 238 dev_link_t **linkp;
238 local_info_t *info = link->priv; 239 local_info_t *info = link->priv;
239 int ret;
240 240
241 DEBUG(0, "elsa_cs_detach(0x%p)\n", link); 241 DEBUG(0, "elsa_cs_detach(0x%p)\n", link);
242 242
@@ -246,14 +246,9 @@ static void elsa_cs_detach(dev_link_t *link)
246 if (*linkp == NULL) 246 if (*linkp == NULL)
247 return; 247 return;
248 248
249 if (link->state & DEV_CONFIG) 249 if (link->state & DEV_CONFIG) {
250 ((local_info_t*)link->priv)->busy = 1;
250 elsa_cs_release(link); 251 elsa_cs_release(link);
251
252 /* Break the link with Card Services */
253 if (link->handle) {
254 ret = pcmcia_deregister_client(link->handle);
255 if (ret != CS_SUCCESS)
256 cs_error(link->handle, DeregisterClient, ret);
257 } 252 }
258 253
259 /* Unlink device structure and free it */ 254 /* Unlink device structure and free it */
@@ -495,13 +490,6 @@ static int elsa_cs_event(event_t event, int priority,
495 DEBUG(1, "elsa_cs_event(%d)\n", event); 490 DEBUG(1, "elsa_cs_event(%d)\n", event);
496 491
497 switch (event) { 492 switch (event) {
498 case CS_EVENT_CARD_REMOVAL:
499 link->state &= ~DEV_PRESENT;
500 if (link->state & DEV_CONFIG) {
501 ((local_info_t*)link->priv)->busy = 1;
502 elsa_cs_release(link);
503 }
504 break;
505 case CS_EVENT_CARD_INSERTION: 493 case CS_EVENT_CARD_INSERTION:
506 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 494 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
507 elsa_cs_config(link); 495 elsa_cs_config(link);
@@ -524,7 +512,7 @@ static struct pcmcia_driver elsa_cs_driver = {
524 }, 512 },
525 .attach = elsa_cs_attach, 513 .attach = elsa_cs_attach,
526 .event = elsa_cs_event, 514 .event = elsa_cs_event,
527 .detach = elsa_cs_detach, 515 .remove = elsa_cs_detach,
528 .id_table = elsa_ids, 516 .id_table = elsa_ids,
529 .suspend = elsa_suspend, 517 .suspend = elsa_suspend,
530 .resume = elsa_resume, 518 .resume = elsa_resume,
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 27dce7c7b760..d2386f6867b7 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -107,7 +107,7 @@ static int sedlbauer_event(event_t event, int priority,
107*/ 107*/
108 108
109static dev_link_t *sedlbauer_attach(void); 109static dev_link_t *sedlbauer_attach(void);
110static void sedlbauer_detach(dev_link_t *); 110static void sedlbauer_detach(struct pcmcia_device *p_dev);
111 111
112/* 112/*
113 You'll also need to prototype all the functions that will actually 113 You'll also need to prototype all the functions that will actually
@@ -230,7 +230,7 @@ static dev_link_t *sedlbauer_attach(void)
230 ret = pcmcia_register_client(&link->handle, &client_reg); 230 ret = pcmcia_register_client(&link->handle, &client_reg);
231 if (ret != CS_SUCCESS) { 231 if (ret != CS_SUCCESS) {
232 cs_error(link->handle, RegisterClient, ret); 232 cs_error(link->handle, RegisterClient, ret);
233 sedlbauer_detach(link); 233 sedlbauer_detach(link->handle);
234 return NULL; 234 return NULL;
235 } 235 }
236 236
@@ -246,8 +246,9 @@ static dev_link_t *sedlbauer_attach(void)
246 246
247======================================================================*/ 247======================================================================*/
248 248
249static void sedlbauer_detach(dev_link_t *link) 249static void sedlbauer_detach(struct pcmcia_device *p_dev)
250{ 250{
251 dev_link_t *link = dev_to_instance(p_dev);
251 dev_link_t **linkp; 252 dev_link_t **linkp;
252 253
253 DEBUG(0, "sedlbauer_detach(0x%p)\n", link); 254 DEBUG(0, "sedlbauer_detach(0x%p)\n", link);
@@ -258,25 +259,11 @@ static void sedlbauer_detach(dev_link_t *link)
258 if (*linkp == NULL) 259 if (*linkp == NULL)
259 return; 260 return;
260 261
261 /*
262 If the device is currently configured and active, we won't
263 actually delete it yet. Instead, it is marked so that when
264 the release() function is called, that will trigger a proper
265 detach().
266 */
267 if (link->state & DEV_CONFIG) { 262 if (link->state & DEV_CONFIG) {
268#ifdef PCMCIA_DEBUG 263 ((local_info_t *)link->priv)->stop = 1;
269 printk(KERN_DEBUG "sedlbauer_cs: detach postponed, '%s' " 264 sedlbauer_release(link);
270 "still locked\n", link->dev->dev_name);
271#endif
272 link->state |= DEV_STALE_LINK;
273 return;
274 } 265 }
275 266
276 /* Break the link with Card Services */
277 if (link->handle)
278 pcmcia_deregister_client(link->handle);
279
280 /* Unlink device structure, and free it */ 267 /* Unlink device structure, and free it */
281 *linkp = link->next; 268 *linkp = link->next;
282 /* This points to the parent local_info_t struct */ 269 /* This points to the parent local_info_t struct */
@@ -547,10 +534,6 @@ static void sedlbauer_release(dev_link_t *link)
547 if (link->irq.AssignedIRQ) 534 if (link->irq.AssignedIRQ)
548 pcmcia_release_irq(link->handle, &link->irq); 535 pcmcia_release_irq(link->handle, &link->irq);
549 link->state &= ~DEV_CONFIG; 536 link->state &= ~DEV_CONFIG;
550
551 if (link->state & DEV_STALE_LINK)
552 sedlbauer_detach(link);
553
554} /* sedlbauer_release */ 537} /* sedlbauer_release */
555 538
556static int sedlbauer_suspend(struct pcmcia_device *p_dev) 539static int sedlbauer_suspend(struct pcmcia_device *p_dev)
@@ -599,13 +582,6 @@ static int sedlbauer_event(event_t event, int priority,
599 DEBUG(1, "sedlbauer_event(0x%06x)\n", event); 582 DEBUG(1, "sedlbauer_event(0x%06x)\n", event);
600 583
601 switch (event) { 584 switch (event) {
602 case CS_EVENT_CARD_REMOVAL:
603 link->state &= ~DEV_PRESENT;
604 if (link->state & DEV_CONFIG) {
605 ((local_info_t *)link->priv)->stop = 1;
606 sedlbauer_release(link);
607 }
608 break;
609 case CS_EVENT_CARD_INSERTION: 585 case CS_EVENT_CARD_INSERTION:
610 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 586 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
611 sedlbauer_config(link); 587 sedlbauer_config(link);
@@ -633,7 +609,7 @@ static struct pcmcia_driver sedlbauer_driver = {
633 }, 609 },
634 .attach = sedlbauer_attach, 610 .attach = sedlbauer_attach,
635 .event = sedlbauer_event, 611 .event = sedlbauer_event,
636 .detach = sedlbauer_detach, 612 .remove = sedlbauer_detach,
637 .id_table = sedlbauer_ids, 613 .id_table = sedlbauer_ids,
638 .suspend = sedlbauer_suspend, 614 .suspend = sedlbauer_suspend,
639 .resume = sedlbauer_resume, 615 .resume = sedlbauer_resume,
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index 70213bc1d30c..cd0f86f0975b 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -87,7 +87,7 @@ static int teles_cs_event(event_t event, int priority,
87*/ 87*/
88 88
89static dev_link_t *teles_attach(void); 89static dev_link_t *teles_attach(void);
90static void teles_detach(dev_link_t *); 90static void teles_detach(struct pcmcia_device *p_dev);
91 91
92/* 92/*
93 The dev_info variable is the "key" that is used to match up this 93 The dev_info variable is the "key" that is used to match up this
@@ -197,7 +197,7 @@ static dev_link_t *teles_attach(void)
197 ret = pcmcia_register_client(&link->handle, &client_reg); 197 ret = pcmcia_register_client(&link->handle, &client_reg);
198 if (ret != CS_SUCCESS) { 198 if (ret != CS_SUCCESS) {
199 cs_error(link->handle, RegisterClient, ret); 199 cs_error(link->handle, RegisterClient, ret);
200 teles_detach(link); 200 teles_detach(link->handle);
201 return NULL; 201 return NULL;
202 } 202 }
203 203
@@ -213,11 +213,11 @@ static dev_link_t *teles_attach(void)
213 213
214======================================================================*/ 214======================================================================*/
215 215
216static void teles_detach(dev_link_t *link) 216static void teles_detach(struct pcmcia_device *p_dev)
217{ 217{
218 dev_link_t *link = dev_to_instance(p_dev);
218 dev_link_t **linkp; 219 dev_link_t **linkp;
219 local_info_t *info = link->priv; 220 local_info_t *info = link->priv;
220 int ret;
221 221
222 DEBUG(0, "teles_detach(0x%p)\n", link); 222 DEBUG(0, "teles_detach(0x%p)\n", link);
223 223
@@ -227,14 +227,9 @@ static void teles_detach(dev_link_t *link)
227 if (*linkp == NULL) 227 if (*linkp == NULL)
228 return; 228 return;
229 229
230 if (link->state & DEV_CONFIG) 230 if (link->state & DEV_CONFIG) {
231 info->busy = 1;
231 teles_cs_release(link); 232 teles_cs_release(link);
232
233 /* Break the link with Card Services */
234 if (link->handle) {
235 ret = pcmcia_deregister_client(link->handle);
236 if (ret != CS_SUCCESS)
237 cs_error(link->handle, DeregisterClient, ret);
238 } 233 }
239 234
240 /* Unlink device structure and free it */ 235 /* Unlink device structure and free it */
@@ -476,13 +471,6 @@ static int teles_cs_event(event_t event, int priority,
476 DEBUG(1, "teles_cs_event(%d)\n", event); 471 DEBUG(1, "teles_cs_event(%d)\n", event);
477 472
478 switch (event) { 473 switch (event) {
479 case CS_EVENT_CARD_REMOVAL:
480 link->state &= ~DEV_PRESENT;
481 if (link->state & DEV_CONFIG) {
482 ((local_info_t*)link->priv)->busy = 1;
483 teles_cs_release(link);
484 }
485 break;
486 case CS_EVENT_CARD_INSERTION: 474 case CS_EVENT_CARD_INSERTION:
487 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 475 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
488 teles_cs_config(link); 476 teles_cs_config(link);
@@ -504,7 +492,7 @@ static struct pcmcia_driver teles_cs_driver = {
504 }, 492 },
505 .attach = teles_attach, 493 .attach = teles_attach,
506 .event = teles_cs_event, 494 .event = teles_cs_event,
507 .detach = teles_detach, 495 .remove = teles_detach,
508 .id_table = teles_ids, 496 .id_table = teles_ids,
509 .suspend = teles_suspend, 497 .suspend = teles_suspend,
510 .resume = teles_resume, 498 .resume = teles_resume,