aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hardware/avm/avm_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hardware/avm/avm_cs.c')
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 6d9816e10ecb..2d898d3afc97 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -63,7 +63,7 @@ static int avmcs_event(event_t event, int priority,
63*/ 63*/
64 64
65static dev_link_t *avmcs_attach(void); 65static dev_link_t *avmcs_attach(void);
66static void avmcs_detach(dev_link_t *); 66static void avmcs_detach(struct pcmcia_device *p_dev);
67 67
68/* 68/*
69 The dev_info variable is the "key" that is used to match up this 69 The dev_info variable is the "key" that is used to match up this
@@ -165,7 +165,7 @@ static dev_link_t *avmcs_attach(void)
165 ret = pcmcia_register_client(&link->handle, &client_reg); 165 ret = pcmcia_register_client(&link->handle, &client_reg);
166 if (ret != 0) { 166 if (ret != 0) {
167 cs_error(link->handle, RegisterClient, ret); 167 cs_error(link->handle, RegisterClient, ret);
168 avmcs_detach(link); 168 avmcs_detach(link->handle);
169 goto err; 169 goto err;
170 } 170 }
171 return link; 171 return link;
@@ -185,8 +185,9 @@ static dev_link_t *avmcs_attach(void)
185 185
186======================================================================*/ 186======================================================================*/
187 187
188static void avmcs_detach(dev_link_t *link) 188static void avmcs_detach(struct pcmcia_device *p_dev)
189{ 189{
190 dev_link_t *link = dev_to_instance(p_dev);
190 dev_link_t **linkp; 191 dev_link_t **linkp;
191 192
192 /* Locate device structure */ 193 /* Locate device structure */
@@ -195,21 +196,9 @@ static void avmcs_detach(dev_link_t *link)
195 if (*linkp == NULL) 196 if (*linkp == NULL)
196 return; 197 return;
197 198
198 /* 199 if (link->state & DEV_CONFIG)
199 If the device is currently configured and active, we won't 200 avmcs_release(link);
200 actually delete it yet. Instead, it is marked so that when
201 the release() function is called, that will trigger a proper
202 detach().
203 */
204 if (link->state & DEV_CONFIG) {
205 link->state |= DEV_STALE_LINK;
206 return;
207 }
208 201
209 /* Break the link with Card Services */
210 if (link->handle)
211 pcmcia_deregister_client(link->handle);
212
213 /* Unlink device structure, free pieces */ 202 /* Unlink device structure, free pieces */
214 *linkp = link->next; 203 *linkp = link->next;
215 kfree(link->priv); 204 kfree(link->priv);
@@ -424,10 +413,6 @@ static void avmcs_release(dev_link_t *link)
424 pcmcia_release_io(link->handle, &link->io); 413 pcmcia_release_io(link->handle, &link->io);
425 pcmcia_release_irq(link->handle, &link->irq); 414 pcmcia_release_irq(link->handle, &link->irq);
426 link->state &= ~DEV_CONFIG; 415 link->state &= ~DEV_CONFIG;
427
428 if (link->state & DEV_STALE_LINK)
429 avmcs_detach(link);
430
431} /* avmcs_release */ 416} /* avmcs_release */
432 417
433static int avmcs_suspend(struct pcmcia_device *dev) 418static int avmcs_suspend(struct pcmcia_device *dev)
@@ -472,11 +457,6 @@ static int avmcs_event(event_t event, int priority,
472 dev_link_t *link = args->client_data; 457 dev_link_t *link = args->client_data;
473 458
474 switch (event) { 459 switch (event) {
475 case CS_EVENT_CARD_REMOVAL:
476 link->state &= ~DEV_PRESENT;
477 if (link->state & DEV_CONFIG)
478 avmcs_release(link);
479 break;
480 case CS_EVENT_CARD_INSERTION: 460 case CS_EVENT_CARD_INSERTION:
481 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 461 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
482 avmcs_config(link); 462 avmcs_config(link);
@@ -500,7 +480,7 @@ static struct pcmcia_driver avmcs_driver = {
500 }, 480 },
501 .attach = avmcs_attach, 481 .attach = avmcs_attach,
502 .event = avmcs_event, 482 .event = avmcs_event,
503 .detach = avmcs_detach, 483 .remove = avmcs_detach,
504 .id_table = avmcs_ids, 484 .id_table = avmcs_ids,
505 .suspend= avmcs_suspend, 485 .suspend= avmcs_suspend,
506 .resume = avmcs_resume, 486 .resume = avmcs_resume,