diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 21:23:14 +0100 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-06 00:03:10 +0100 |
commit | cc3b4866bee996c922e875b8c8efe9f0d8803aae (patch) | |
tree | 6632837b6986f33566f75ed971cecbdc210e3201 /drivers/isdn/hisax | |
parent | 8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 (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.c | 39 | ||||
-rw-r--r-- | drivers/isdn/hisax/elsa_cs.c | 26 | ||||
-rw-r--r-- | drivers/isdn/hisax/sedlbauer_cs.c | 38 | ||||
-rw-r--r-- | drivers/isdn/hisax/teles_cs.c | 26 |
4 files changed, 29 insertions, 100 deletions
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 433cec4269a..6b322e88c6c 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, */ static dev_link_t *avma1cs_attach(void); -static void avma1cs_detach(dev_link_t *); +static void avma1cs_detach(struct pcmcia_device *p_dev); /* 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) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - avma1cs_detach(link); + avma1cs_detach(link->handle); return NULL; } @@ -203,42 +203,26 @@ static dev_link_t *avma1cs_attach(void) ======================================================================*/ -static void avma1cs_detach(dev_link_t *link) +static void avma1cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "avma1cs_detach(0x%p)\n", link); - + /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; if (*linkp == NULL) return; - /* - If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ - if (link->state & DEV_CONFIG) { -#ifdef PCMCIA_DEBUG - printk(KERN_DEBUG "avma1_cs: detach postponed, '%s' " - "still locked\n", link->dev->dev_name); -#endif - link->state |= DEV_STALE_LINK; - return; - } + if (link->state & DEV_CONFIG) + avma1cs_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; kfree(link->priv); kfree(link); - } /* avma1cs_detach */ /*====================================================================== @@ -440,9 +424,6 @@ static void avma1cs_release(dev_link_t *link) pcmcia_release_io(link->handle, &link->io); pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; - - if (link->state & DEV_STALE_LINK) - avma1cs_detach(link); } /* avma1cs_release */ static int avma1cs_suspend(struct pcmcia_device *dev) @@ -489,10 +470,6 @@ static int avma1cs_event(event_t event, int priority, DEBUG(1, "avma1cs_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - if (link->state & DEV_CONFIG) - avma1cs_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; avma1cs_config(link); @@ -515,7 +492,7 @@ static struct pcmcia_driver avma1cs_driver = { }, .attach = avma1cs_attach, .event = avma1cs_event, - .detach = avma1cs_detach, + .remove = avma1cs_detach, .id_table = avma1cs_ids, .suspend = avma1cs_suspend, .resume = avma1cs_resume, diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index 0cbe04593d8..48cc677249f 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, */ static dev_link_t *elsa_cs_attach(void); -static void elsa_cs_detach(dev_link_t *); +static void elsa_cs_detach(struct pcmcia_device *p_dev); /* 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) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - elsa_cs_detach(link); + elsa_cs_detach(link->handle); return NULL; } @@ -232,11 +232,11 @@ static dev_link_t *elsa_cs_attach(void) ======================================================================*/ -static void elsa_cs_detach(dev_link_t *link) +static void elsa_cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; local_info_t *info = link->priv; - int ret; DEBUG(0, "elsa_cs_detach(0x%p)\n", link); @@ -246,14 +246,9 @@ static void elsa_cs_detach(dev_link_t *link) if (*linkp == NULL) return; - if (link->state & DEV_CONFIG) + if (link->state & DEV_CONFIG) { + ((local_info_t*)link->priv)->busy = 1; elsa_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); } /* Unlink device structure and free it */ @@ -495,13 +490,6 @@ static int elsa_cs_event(event_t event, int priority, DEBUG(1, "elsa_cs_event(%d)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((local_info_t*)link->priv)->busy = 1; - elsa_cs_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; elsa_cs_config(link); @@ -524,7 +512,7 @@ static struct pcmcia_driver elsa_cs_driver = { }, .attach = elsa_cs_attach, .event = elsa_cs_event, - .detach = elsa_cs_detach, + .remove = elsa_cs_detach, .id_table = elsa_ids, .suspend = elsa_suspend, .resume = elsa_resume, diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 27dce7c7b76..d2386f6867b 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, */ static dev_link_t *sedlbauer_attach(void); -static void sedlbauer_detach(dev_link_t *); +static void sedlbauer_detach(struct pcmcia_device *p_dev); /* You'll also need to prototype all the functions that will actually @@ -230,7 +230,7 @@ static dev_link_t *sedlbauer_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - sedlbauer_detach(link); + sedlbauer_detach(link->handle); return NULL; } @@ -246,8 +246,9 @@ static dev_link_t *sedlbauer_attach(void) ======================================================================*/ -static void sedlbauer_detach(dev_link_t *link) +static void sedlbauer_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "sedlbauer_detach(0x%p)\n", link); @@ -258,25 +259,11 @@ static void sedlbauer_detach(dev_link_t *link) if (*linkp == NULL) return; - /* - If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ if (link->state & DEV_CONFIG) { -#ifdef PCMCIA_DEBUG - printk(KERN_DEBUG "sedlbauer_cs: detach postponed, '%s' " - "still locked\n", link->dev->dev_name); -#endif - link->state |= DEV_STALE_LINK; - return; + ((local_info_t *)link->priv)->stop = 1; + sedlbauer_release(link); } - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, and free it */ *linkp = link->next; /* This points to the parent local_info_t struct */ @@ -547,10 +534,6 @@ static void sedlbauer_release(dev_link_t *link) if (link->irq.AssignedIRQ) pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; - - if (link->state & DEV_STALE_LINK) - sedlbauer_detach(link); - } /* sedlbauer_release */ static int sedlbauer_suspend(struct pcmcia_device *p_dev) @@ -599,13 +582,6 @@ static int sedlbauer_event(event_t event, int priority, DEBUG(1, "sedlbauer_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((local_info_t *)link->priv)->stop = 1; - sedlbauer_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; sedlbauer_config(link); @@ -633,7 +609,7 @@ static struct pcmcia_driver sedlbauer_driver = { }, .attach = sedlbauer_attach, .event = sedlbauer_event, - .detach = sedlbauer_detach, + .remove = sedlbauer_detach, .id_table = sedlbauer_ids, .suspend = sedlbauer_suspend, .resume = sedlbauer_resume, diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index 70213bc1d30..cd0f86f0975 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, */ static dev_link_t *teles_attach(void); -static void teles_detach(dev_link_t *); +static void teles_detach(struct pcmcia_device *p_dev); /* 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) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - teles_detach(link); + teles_detach(link->handle); return NULL; } @@ -213,11 +213,11 @@ static dev_link_t *teles_attach(void) ======================================================================*/ -static void teles_detach(dev_link_t *link) +static void teles_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; local_info_t *info = link->priv; - int ret; DEBUG(0, "teles_detach(0x%p)\n", link); @@ -227,14 +227,9 @@ static void teles_detach(dev_link_t *link) if (*linkp == NULL) return; - if (link->state & DEV_CONFIG) + if (link->state & DEV_CONFIG) { + info->busy = 1; teles_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); } /* Unlink device structure and free it */ @@ -476,13 +471,6 @@ static int teles_cs_event(event_t event, int priority, DEBUG(1, "teles_cs_event(%d)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((local_info_t*)link->priv)->busy = 1; - teles_cs_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; teles_cs_config(link); @@ -504,7 +492,7 @@ static struct pcmcia_driver teles_cs_driver = { }, .attach = teles_attach, .event = teles_cs_event, - .detach = teles_detach, + .remove = teles_detach, .id_table = teles_ids, .suspend = teles_suspend, .resume = teles_resume, |