aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/avma1_cs.c
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/avma1_cs.c
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/avma1_cs.c')
-rw-r--r--drivers/isdn/hisax/avma1_cs.c39
1 files changed, 8 insertions, 31 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,