aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/spectrum_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/net/wireless/spectrum_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/net/wireless/spectrum_cs.c')
-rw-r--r--drivers/net/wireless/spectrum_cs.c37
1 files changed, 5 insertions, 32 deletions
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 3938a5735659..a2dcab7995c1 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -90,7 +90,7 @@ static dev_link_t *dev_list; /* = NULL */
90/********************************************************************/ 90/********************************************************************/
91 91
92static void spectrum_cs_release(dev_link_t *link); 92static void spectrum_cs_release(dev_link_t *link);
93static void spectrum_cs_detach(dev_link_t *link); 93static void spectrum_cs_detach(struct pcmcia_device *p_dev);
94 94
95/********************************************************************/ 95/********************************************************************/
96/* Firmware downloader */ 96/* Firmware downloader */
@@ -647,7 +647,7 @@ spectrum_cs_attach(void)
647 ret = pcmcia_register_client(&link->handle, &client_reg); 647 ret = pcmcia_register_client(&link->handle, &client_reg);
648 if (ret != CS_SUCCESS) { 648 if (ret != CS_SUCCESS) {
649 cs_error(link->handle, RegisterClient, ret); 649 cs_error(link->handle, RegisterClient, ret);
650 spectrum_cs_detach(link); 650 spectrum_cs_detach(link->handle);
651 return NULL; 651 return NULL;
652 } 652 }
653 653
@@ -660,27 +660,14 @@ spectrum_cs_attach(void)
660 * are freed. Otherwise, the structures will be freed when the device 660 * are freed. Otherwise, the structures will be freed when the device
661 * is released. 661 * is released.
662 */ 662 */
663static void spectrum_cs_detach(dev_link_t *link) 663static void spectrum_cs_detach(struct pcmcia_device *p_dev)
664{ 664{
665 dev_link_t **linkp; 665 dev_link_t *link = dev_to_instance(p_dev);
666 struct net_device *dev = link->priv; 666 struct net_device *dev = link->priv;
667 667
668 /* Locate device structure */
669 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
670 if (*linkp == link)
671 break;
672
673 BUG_ON(*linkp == NULL);
674
675 if (link->state & DEV_CONFIG) 668 if (link->state & DEV_CONFIG)
676 spectrum_cs_release(link); 669 spectrum_cs_release(link);
677 670
678 /* Break the link with Card Services */
679 if (link->handle)
680 pcmcia_deregister_client(link->handle);
681
682 /* Unlink device structure, and free it */
683 *linkp = link->next;
684 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 671 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
685 if (link->dev) { 672 if (link->dev) {
686 DEBUG(0, PFX "About to unregister net device %p\n", 673 DEBUG(0, PFX "About to unregister net device %p\n",
@@ -1007,22 +994,8 @@ spectrum_cs_event(event_t event, int priority,
1007 event_callback_args_t * args) 994 event_callback_args_t * args)
1008{ 995{
1009 dev_link_t *link = args->client_data; 996 dev_link_t *link = args->client_data;
1010 struct net_device *dev = link->priv;
1011 struct orinoco_private *priv = netdev_priv(dev);
1012 997
1013 switch (event) { 998 switch (event) {
1014 case CS_EVENT_CARD_REMOVAL:
1015 link->state &= ~DEV_PRESENT;
1016 if (link->state & DEV_CONFIG) {
1017 unsigned long flags;
1018
1019 spin_lock_irqsave(&priv->lock, flags);
1020 netif_device_detach(dev);
1021 priv->hw_unavailable++;
1022 spin_unlock_irqrestore(&priv->lock, flags);
1023 }
1024 break;
1025
1026 case CS_EVENT_CARD_INSERTION: 999 case CS_EVENT_CARD_INSERTION:
1027 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1000 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1028 spectrum_cs_config(link); 1001 spectrum_cs_config(link);
@@ -1057,7 +1030,7 @@ static struct pcmcia_driver orinoco_driver = {
1057 .name = DRIVER_NAME, 1030 .name = DRIVER_NAME,
1058 }, 1031 },
1059 .attach = spectrum_cs_attach, 1032 .attach = spectrum_cs_attach,
1060 .detach = spectrum_cs_detach, 1033 .remove = spectrum_cs_detach,
1061 .suspend = spectrum_cs_suspend, 1034 .suspend = spectrum_cs_suspend,
1062 .resume = spectrum_cs_resume, 1035 .resume = spectrum_cs_resume,
1063 .event = spectrum_cs_event, 1036 .event = spectrum_cs_event,