From cc3b4866bee996c922e875b8c8efe9f0d8803aae Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:23:14 +0100 Subject: [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 --- drivers/net/pcmcia/pcnet_cs.c | 48 ++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'drivers/net/pcmcia/pcnet_cs.c') diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 7db4d6f3db4..fb3e411d6da 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -121,7 +121,7 @@ static int setup_dma_config(dev_link_t *link, int start_pg, int stop_pg); static dev_link_t *pcnet_attach(void); -static void pcnet_detach(dev_link_t *); +static void pcnet_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "pcnet_cs"; static dev_link_t *dev_list; @@ -280,7 +280,7 @@ static dev_link_t *pcnet_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - pcnet_detach(link); + pcnet_detach(link->handle); return NULL; } @@ -296,31 +296,29 @@ static dev_link_t *pcnet_attach(void) ======================================================================*/ -static void pcnet_detach(dev_link_t *link) +static void pcnet_detach(struct pcmcia_device *p_dev) { - struct net_device *dev = link->priv; - dev_link_t **linkp; - - DEBUG(0, "pcnet_detach(0x%p)\n", link); + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + dev_link_t **linkp; - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; + DEBUG(0, "pcnet_detach(0x%p)\n", link); - if (link->dev) - unregister_netdev(dev); + /* Locate device structure */ + for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) + if (*linkp == link) break; + if (*linkp == NULL) + return; - if (link->state & DEV_CONFIG) - pcnet_release(link); + if (link->dev) + unregister_netdev(dev); - if (link->handle) - pcmcia_deregister_client(link->handle); + if (link->state & DEV_CONFIG) + pcnet_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; - free_netdev(dev); + /* Unlink device structure, free bits */ + *linkp = link->next; + free_netdev(dev); } /* pcnet_detach */ /*====================================================================== @@ -817,16 +815,10 @@ static int pcnet_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(2, "pcnet_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; pcnet_config(link); @@ -1856,7 +1848,7 @@ static struct pcmcia_driver pcnet_driver = { }, .attach = pcnet_attach, .event = pcnet_event, - .detach = pcnet_detach, + .remove = pcnet_detach, .owner = THIS_MODULE, .id_table = pcnet_ids, .suspend = pcnet_suspend, -- cgit v1.2.3-70-g09d2