From 9d66b5e47f09a13f16438b79d9471226342d9a31 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 6 Sep 2003 22:52:15 +0100 Subject: [PATCH] [PCMCIA] kill flush_stale_links following Dave's guide it's replaced by calling foo_detach in foo_release if the links is stale. Note that I killed DEV_STALE_LINK aswell as DEV_STALE_CONFIG isn't ever cleared so we don't need two flags. Also some dead codepathes related to DEV_STALE_* are killed. --- drivers/net/pcmcia/3c574_cs.c | 19 +++-------- drivers/net/pcmcia/3c589_cs.c | 29 +++-------------- drivers/net/pcmcia/axnet_cs.c | 27 +++------------- drivers/net/pcmcia/com20020_cs.c | 27 +++------------- drivers/net/pcmcia/fmvj18x_cs.c | 29 +++-------------- drivers/net/pcmcia/ibmtr_cs.c | 27 +++------------- drivers/net/pcmcia/nmclan_cs.c | 24 +++----------- drivers/net/pcmcia/pcnet_cs.c | 27 +++------------- drivers/net/pcmcia/smc91c92_cs.c | 27 +++------------- drivers/net/pcmcia/xirc2ps_cs.c | 35 +-------------------- drivers/net/wireless/airo_cs.c | 31 ++++-------------- drivers/net/wireless/atmel_cs.c | 39 +++-------------------- drivers/net/wireless/netwave_cs.c | 38 +++------------------- drivers/net/wireless/orinoco_cs.c | 28 +---------------- drivers/net/wireless/ray_cs.c | 29 ++++------------- drivers/net/wireless/wavelan_cs.c | 49 ++--------------------------- drivers/net/wireless/wavelan_cs.p.h | 3 +- drivers/net/wireless/wl3501_cs.c | 21 +------------ 18 files changed, 66 insertions(+), 443 deletions(-) diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 2b892fbd49ae9..756ce28013760 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -263,16 +263,6 @@ static void tc574_detach(dev_link_t *); static dev_link_t *dev_list; -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - tc574_detach(link); - } -} - /* tc574_attach() creates an "instance" of the driver, allocating local data structures for one device. The device is registered @@ -288,7 +278,6 @@ static dev_link_t *tc574_attach(void) int i, ret; DEBUG(0, "3c574_attach()\n"); - flush_stale_links(); /* Create the PC card device object. */ dev = alloc_etherdev(sizeof(struct el3_private)); @@ -375,10 +364,8 @@ static void tc574_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { tc574_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -583,7 +570,9 @@ static void tc574_release(dev_link_t *link) link->state &= ~DEV_CONFIG; -} /* tc574_release */ + if (link->state & DEV_STALE_CONFIG) + tc574_detach(link); +} /* The card status event handler. Mostly, this schedules other diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 880913bea3446..d41f48ce8b334 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -174,24 +174,6 @@ static void tc589_detach(dev_link_t *); static dev_link_t *dev_list; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - tc589_detach(link); - } -} - /*====================================================================== tc589_attach() creates an "instance" of the driver, allocating @@ -209,7 +191,6 @@ static dev_link_t *tc589_attach(void) int i, ret; DEBUG(0, "3c589_attach()\n"); - flush_stale_links(); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct el3_private)); @@ -297,10 +278,8 @@ static void tc589_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { tc589_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -466,8 +445,10 @@ static void tc589_release(dev_link_t *link) CardServices(ReleaseIRQ, link->handle, &link->irq); link->state &= ~DEV_CONFIG; - -} /* tc589_release */ + + if (link->state & DEV_STALE_CONFIG) + tc589_detach(link); +} /*====================================================================== diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 104ddf6d39c2b..ae4c6b59e685a 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -140,24 +140,6 @@ typedef struct axnet_dev_t { int flags; } axnet_dev_t; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - axnet_detach(link); - } -} - /*====================================================================== We never need to do anything when a axnet device is "initialized" @@ -187,7 +169,6 @@ static dev_link_t *axnet_attach(void) int i, ret; DEBUG(0, "axnet_attach()\n"); - flush_stale_links(); /* Create new ethernet device */ info = kmalloc(sizeof(*info), GFP_KERNEL); @@ -258,10 +239,8 @@ static void axnet_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { axnet_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -547,7 +526,9 @@ static void axnet_release(dev_link_t *link) link->state &= ~DEV_CONFIG; -} /* axnet_release */ + if (link->state & DEV_STALE_CONFIG) + axnet_detach(link); +} /*====================================================================== diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 3a9b1cd38ee37..7e5a91a4510b4 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -145,24 +145,6 @@ typedef struct com20020_dev_t { dev_node_t node; } com20020_dev_t; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - com20020_detach(link); - } -} - /*====================================================================== com20020_attach() creates an "instance" of the driver, allocating @@ -181,7 +163,6 @@ static dev_link_t *com20020_attach(void) struct arcnet_local *lp; DEBUG(0, "com20020_attach()\n"); - flush_stale_links(); /* Create new network device */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); @@ -290,10 +271,8 @@ static void com20020_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { com20020_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -484,7 +463,9 @@ static void com20020_release(dev_link_t *link) link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING); -} /* com20020_release */ + if (link->state & DEV_STALE_CONFIG) + com20020_detach(link); +} /*====================================================================== diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 62c21fede5938..a78e2dafffb4c 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -242,24 +242,6 @@ typedef struct local_info_t { #define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ #define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - fmvj18x_detach(link); - } -} - static dev_link_t *fmvj18x_attach(void) { local_info_t *lp; @@ -269,7 +251,6 @@ static dev_link_t *fmvj18x_attach(void) int i, ret; DEBUG(0, "fmvj18x_attach()\n"); - flush_stale_links(); /* Make up a FMVJ18x specific data structure */ dev = alloc_etherdev(sizeof(local_info_t)); @@ -353,10 +334,8 @@ static void fmvj18x_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { fmvj18x_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } /* Break the link with Card Services */ @@ -762,8 +741,10 @@ static void fmvj18x_release(dev_link_t *link) CardServices(ReleaseIRQ, link->handle, &link->irq); link->state &= ~DEV_CONFIG; - -} /* fmvj18x_release */ + + if (link->state & DEV_STALE_CONFIG) + fmvj18x_detach(link); +} /*====================================================================*/ diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index fd508a19dcb76..03e20f5c1a906 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -139,24 +139,6 @@ typedef struct ibmtr_dev_t { struct tok_info ti; } ibmtr_dev_t; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - ibmtr_detach(link); - } -} - static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { @@ -184,7 +166,6 @@ static dev_link_t *ibmtr_attach(void) int i, ret; DEBUG(0, "ibmtr_attach()\n"); - flush_stale_links(); /* Create new token-ring device */ dev = alloc_trdev(sizeof(*info)); @@ -273,10 +254,8 @@ static void ibmtr_detach(dev_link_t *link) } if (link->state & DEV_CONFIG) { ibmtr_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -446,7 +425,9 @@ static void ibmtr_release(dev_link_t *link) link->state &= ~DEV_CONFIG; -} /* ibmtr_release */ + if (link->state & DEV_STALE_CONFIG) + ibmtr_detach(link); +} /*====================================================================== diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 97addb9892a33..9846ee6794e58 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -448,21 +448,6 @@ static struct ethtool_ops netdev_ethtool_ops; static dev_link_t *nmclan_attach(void); static void nmclan_detach(dev_link_t *); -/* ---------------------------------------------------------------------------- -flush_stale_links - Clean up stale device structures ----------------------------------------------------------------------------- */ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - nmclan_detach(link); - } -} - /* ---------------------------------------------------------------------------- nmclan_attach Creates an "instance" of the driver, allocating local data @@ -480,7 +465,6 @@ static dev_link_t *nmclan_attach(void) DEBUG(0, "nmclan_attach()\n"); DEBUG(1, "%s\n", rcsid); - flush_stale_links(); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(mace_private)); @@ -569,10 +553,8 @@ static void nmclan_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { nmclan_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -843,7 +825,9 @@ static void nmclan_release(dev_link_t *link) link->state &= ~DEV_CONFIG; -} /* nmclan_release */ + if (link->state & DEV_STALE_CONFIG) + nmclan_detach(link); +} /* ---------------------------------------------------------------------------- nmclan_event diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index c29b74b578d06..d6bcac3b173e8 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -237,24 +237,6 @@ typedef struct pcnet_dev_t { u_long mii_reset; } pcnet_dev_t; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - pcnet_detach(link); - } -} - /*====================================================================== We never need to do anything when a pcnet device is "initialized" @@ -284,7 +266,6 @@ static dev_link_t *pcnet_attach(void) int i, ret; DEBUG(0, "pcnet_attach()\n"); - flush_stale_links(); /* Create new ethernet device */ info = kmalloc(sizeof(*info), GFP_KERNEL); @@ -356,10 +337,8 @@ static void pcnet_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { pcnet_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -821,7 +800,9 @@ static void pcnet_release(dev_link_t *link) link->state &= ~DEV_CONFIG; -} /* pcnet_release */ + if (link->state & DEV_STALE_CONFIG) + pcnet_detach(link); +} /*====================================================================== diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index a22e100c673d2..462d4fa236589 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -305,24 +305,6 @@ static int mdio_read(struct net_device *dev, int phy_id, int loc); static void mdio_write(struct net_device *dev, int phy_id, int loc, int value); static int smc_link_ok(struct net_device *dev); -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - smc91c92_detach(link); - } -} - /*====================================================================== smc91c92_attach() creates an "instance" of the driver, allocating @@ -340,7 +322,6 @@ static dev_link_t *smc91c92_attach(void) int i, ret; DEBUG(0, "smc91c92_attach()\n"); - flush_stale_links(); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct smc_private)); @@ -432,10 +413,8 @@ static void smc91c92_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { smc91c92_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if (link->handle) @@ -1103,7 +1082,9 @@ static void smc91c92_release(dev_link_t *link) link->state &= ~DEV_CONFIG; -} /* smc91c92_release */ + if (link->state & DEV_STALE_CONFIG) + smc91c92_detach(link); +} /*====================================================================== diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index e2824c4b26b21..c8d0fac496d0f 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -390,17 +390,6 @@ static void do_powerdown(struct net_device *dev); static int do_stop(struct net_device *dev); /*=============== Helper functions =========================*/ -static void -flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - xirc2ps_detach(link); - } -} - static int get_tuple_data(int fn, client_handle_t handle, tuple_t *tuple) { @@ -602,7 +591,6 @@ xirc2ps_attach(void) int err; DEBUG(0, "attach()\n"); - flush_stale_links(); /* Allocate the device structure */ dev = alloc_etherdev(sizeof(local_info_t)); @@ -687,13 +675,8 @@ xirc2ps_detach(dev_link_t * link) * the release() function is called, that will trigger a proper * detach(). */ - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) xirc2ps_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; - return; - } - } /* Break the link with Card Services */ if (link->handle) @@ -1183,19 +1166,6 @@ xirc2ps_release(dev_link_t *link) DEBUG(0, "release(0x%p)\n", link); -#if 0 - /* - * If the device is currently in use, we won't release until it - * is actually closed. - */ - if (link->open) { - DEBUG(0, "release postponed, '%s' " - "still open\n", link->dev->dev_name); - link->state |= DEV_STALE_CONFIG; - return; - } -#endif - if (link->win) { struct net_device *dev = link->priv; local_info_t *local = dev->priv; @@ -2030,9 +2000,6 @@ do_stop(struct net_device *dev) SelectPage(0); link->open--; - if (link->state & DEV_STALE_CONFIG) - xirc2ps_release(link); - return 0; } diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 21deba478822f..ad61325b8c21f 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -161,24 +161,6 @@ typedef struct local_info_t { struct net_device *eth_dev; } local_info_t; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - - ======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - airo_detach(link); - } -} - /*====================================================================== airo_attach() creates an "instance" of the driver, allocating @@ -199,8 +181,7 @@ static dev_link_t *airo_attach(void) int ret, i; DEBUG(0, "airo_attach()\n"); - flush_stale_links(); - + /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) { @@ -285,10 +266,8 @@ static void airo_detach(dev_link_t *link) if (link->state & DEV_CONFIG) { airo_release(link); - if (link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if (link->state & DEV_STALE_CONFIG) return; - } } if ( ((local_info_t*)link->priv)->eth_dev ) { @@ -554,8 +533,10 @@ static void airo_release(dev_link_t *link) if (link->irq.AssignedIRQ) CardServices(ReleaseIRQ, link->handle, &link->irq); link->state &= ~DEV_CONFIG; - -} /* airo_release */ + + if (link->state & DEV_STALE_CONFIG) + airo_detach(link); +} /*====================================================================== diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index bacf015ecf421..0d64b13dc6336 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -174,24 +174,6 @@ typedef struct local_info_t { struct net_device *eth_dev; } local_info_t; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - - ======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - atmel_detach(link); - } -} - /*====================================================================== atmel_attach() creates an "instance" of the driver, allocating @@ -212,8 +194,7 @@ static dev_link_t *atmel_attach(void) int ret, i; DEBUG(0, "atmel_attach()\n"); - flush_stale_links(); - + /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) { @@ -296,29 +277,19 @@ static void atmel_detach(dev_link_t *link) if (*linkp == NULL) return; - if ( link->state & DEV_CONFIG ) { + if (link->state & DEV_CONFIG) atmel_release(link); - if ( link->state & DEV_STALE_CONFIG ) { - link->state |= DEV_STALE_LINK; - return; - } - } - /* Break the link with Card Services */ if (link->handle) CardServices(DeregisterClient, link->handle); - - - + /* Unlink device structure, free pieces */ *linkp = link->next; - if (link->priv) { + if (link->priv) kfree(link->priv); - } kfree(link); - -} /* atmel_detach */ +} /*====================================================================== diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index a704847b1fd95..4a1b90951f7f8 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -211,7 +211,6 @@ static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card insertion */ static dev_link_t *netwave_attach(void); /* Create instance */ static void netwave_detach(dev_link_t *); /* Destroy instance */ -static void netwave_flush_stale_links(void); /* Destroy all staled instances */ /* Hardware configuration */ static void netwave_doreset(ioaddr_t iobase, u_char* ramBase); @@ -444,9 +443,6 @@ static dev_link_t *netwave_attach(void) DEBUG(0, "netwave_attach()\n"); - /* Perform some cleanup */ - netwave_flush_stale_links(); - /* Initialize the dev_link_t structure */ dev = alloc_etherdev(sizeof(netwave_private)); if (!dev) @@ -553,7 +549,6 @@ static void netwave_detach(dev_link_t *link) if (link->state & DEV_STALE_CONFIG) { DEBUG(1, "netwave_cs: detach postponed, '%s' still " "locked\n", link->dev->dev_name); - link->state |= DEV_STALE_LINK; return; } } @@ -580,31 +575,6 @@ static void netwave_detach(dev_link_t *link) } /* netwave_detach */ -/* - * Function netwave_flush_stale_links (void) - * - * This deletes all driver "instances" that need to be deleted. - * Sometimes, netwave_detach can't be performed following a call from - * cardmgr (device still open) and the device is put in a STALE_LINK - * state. - * This function is in charge of making the cleanup... - */ -static void netwave_flush_stale_links(void) -{ - dev_link_t * link; /* Current node in linked list */ - dev_link_t * next; /* Next node in linked list */ - - DEBUG(1, "netwave_flush_stale_links(0x%p)\n", dev_list); - - /* Go through the list */ - for (link = dev_list; link; link = next) { - next = link->next; - /* Check if in need of being removed */ - if(link->state & DEV_STALE_LINK) - netwave_detach(link); - } -} /* netwave_flush_stale_links */ - /* * Wireless Handler : get protocol name */ @@ -1181,9 +1151,11 @@ static void netwave_release(dev_link_t *link) CardServices(ReleaseIO, link->handle, &link->io); CardServices(ReleaseIRQ, link->handle, &link->irq); - link->state &= ~(DEV_CONFIG | DEV_STALE_CONFIG); + link->state &= ~DEV_CONFIG; -} /* netwave_release */ + if (link->state & DEV_STALE_CONFIG) + netwave_detach(link); +} /* * Function netwave_event (event, priority, args) @@ -1755,8 +1727,6 @@ static void __exit exit_netwave_cs(void) { pcmcia_unregister_driver(&netwave_driver); - /* Do some cleanup of the device list */ - netwave_flush_stale_links(); if (dev_list != NULL) /* Critical situation */ printk("netwave_cs: devices remaining when removing module\n"); } diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index cf37a7a08a1ad..6ddf2854de5f3 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -153,24 +153,6 @@ orinoco_cs_error(client_handle_t handle, int func, int ret) CardServices(ReportError, handle, &err); } - -/* Remove zombie instances (card removed, detach pending) */ -static void -flush_stale_links(void) -{ - dev_link_t *link, *next; - - TRACE_ENTER(""); - - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) { - orinoco_cs_detach(link); - } - } - TRACE_EXIT(""); -} - /* * This creates an "instance" of the driver, allocating local data * structures for one device. The device is registered with Card @@ -189,9 +171,6 @@ orinoco_cs_attach(void) client_reg_t client_reg; int ret, i; - /* A bit of cleanup */ - flush_stale_links(); - dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); if (! dev) return NULL; @@ -266,13 +245,8 @@ orinoco_cs_detach(dev_link_t * link) return; } - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) orinoco_cs_release(link); - if (link->state & DEV_CONFIG) { - link->state |= DEV_STALE_LINK; - return; - } - } /* Break the link with Card Services */ if (link->handle) diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 76179cf6a441e..8b1ed4946a728 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -319,24 +319,6 @@ static char hop_pattern_length[] = { 1, static char rcsid[] = "Raylink/WebGear wireless LAN - Corey "; -/*====================================================================== - - This bit of code is used to avoid unregistering network devices - at inappropriate times. 2.2 and later kernels are fairly picky - about when this can happen. - -======================================================================*/ - -static void flush_stale_links(void) -{ - dev_link_t *link, *next; - for (link = dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - ray_detach(link); - } -} - /*============================================================================= ray_attach() creates an "instance" of the driver, allocating local data structures for one device. The device is registered @@ -354,7 +336,6 @@ static dev_link_t *ray_attach(void) struct net_device *dev; DEBUG(1, "ray_attach()\n"); - flush_stale_links(); /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); @@ -484,10 +465,8 @@ static void ray_detach(dev_link_t *link) */ if (link->state & DEV_CONFIG) { ray_release(link); - if(link->state & DEV_STALE_CONFIG) { - link->state |= DEV_STALE_LINK; + if(link->state & DEV_STALE_CONFIG) return; - } } /* Break the link with Card Services */ @@ -932,7 +911,11 @@ static void ray_release(dev_link_t *link) if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseIRQ ret = %x\n",i); DEBUG(2,"ray_release ending\n"); -} /* ray_release */ + + if (link->state & DEV_STALE_CONFIG) + ray_detach(link); +} + /*============================================================================= The card status event handler. Mostly, this schedules other stuff to run after an event is received. A CARD_REMOVAL event diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index b0963e6443e41..62d509dd35b21 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4175,50 +4175,14 @@ wv_pcmcia_release(dev_link_t *link) CardServices(ReleaseIO, link->handle, &link->io); CardServices(ReleaseIRQ, link->handle, &link->irq); - link->state &= ~(DEV_CONFIG | DEV_STALE_CONFIG); + link->state &= ~DEV_CONFIG; #ifdef DEBUG_CONFIG_TRACE printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name); #endif -} /* wv_pcmcia_release */ -/*------------------------------------------------------------------*/ -/* - * Sometimes, wavelan_detach can't be performed following a call from - * cardmgr (device still open, pcmcia_release not done) and the device - * is put in a STALE_LINK state and remains in memory. - * - * This function run through our current list of device and attempt - * another time to remove them. We hope that since last time the - * device has properly been closed. - * - * (called by wavelan_attach() & cleanup_module()) - */ -static void -wv_flush_stale_links(void) -{ - dev_link_t * link; /* Current node in linked list */ - dev_link_t * next; /* Next node in linked list */ - -#ifdef DEBUG_CONFIG_TRACE - printk(KERN_DEBUG "-> wv_flush_stale_links(0x%p)\n", dev_list); -#endif - - /* Go through the list */ - for (link = dev_list; link; link = next) - { - next = link->next; - - /* Check if in need of being removed */ - if((link->state & DEV_STALE_LINK) || - (! (link->state & DEV_PRESENT))) - wavelan_detach(link); - - } - -#ifdef DEBUG_CONFIG_TRACE - printk(KERN_DEBUG "<- wv_flush_stale_links()\n"); -#endif + if (link->state & DEV_STALE_CONFIG) + wavelan_detach(link); } /************************ INTERRUPT HANDLING ************************/ @@ -4705,9 +4669,6 @@ wavelan_attach(void) printk(KERN_DEBUG "-> wavelan_attach()\n"); #endif - /* Perform some cleanup */ - wv_flush_stale_links(); - /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) return NULL; @@ -4859,7 +4820,6 @@ wavelan_detach(dev_link_t * link) printk(KERN_DEBUG "wavelan_detach: detach postponed," " '%s' still locked\n", link->dev->dev_name); #endif - link->state |= DEV_STALE_LINK; return; } } @@ -5039,9 +4999,6 @@ init_wavelan_cs(void) static void __exit exit_wavelan_cs(void) { - /* Do some cleanup of the device list */ - wv_flush_stale_links(); - pcmcia_unregister_driver(&wavelan_driver); } diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index b5effe955f0c2..62baa3a7ab145 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h @@ -761,8 +761,7 @@ static inline void static inline int wv_pcmcia_config(dev_link_t *); /* Configure the pcmcia interface */ static void - wv_pcmcia_release(dev_link_t *),/* Remove a device */ - wv_flush_stale_links(void); /* "detach" all possible devices */ + wv_pcmcia_release(dev_link_t *);/* Remove a device */ /* ---------------------- INTERRUPT HANDLING ---------------------- */ static irqreturn_t wavelan_interrupt(int, /* Interrupt handler */ diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 0bb13a6a50b2a..4afd2eb318d54 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -1571,7 +1571,6 @@ static void wl3501_detach(dev_link_t *link) printk(KERN_DEBUG "wl3501_cs: detach postponed, '%s' " "still locked\n", link->dev->dev_name); #endif - link->state |= DEV_STALE_LINK; goto out; } @@ -1589,22 +1588,6 @@ out: return; } -/** - * wl3501_flush_stale_links - Remove zombie instances - * - * Remove zombie instances (card removed, detach pending) - */ -static void wl3501_flush_stale_links(void) -{ - dev_link_t *link, *next; - - for (link = wl3501_dev_list; link; link = next) { - next = link->next; - if (link->state & DEV_STALE_LINK) - wl3501_detach(link); - } -} - static int wl3501_get_name(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -2033,8 +2016,6 @@ static dev_link_t *wl3501_attach(void) struct net_device *dev; int ret, i; - wl3501_flush_stale_links(); - /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(*link), GFP_KERNEL); if (!link) @@ -2263,7 +2244,7 @@ static void wl3501_release(dev_link_t *link) CardServices(ReleaseIRQ, link->handle, &link->irq); link->state &= ~DEV_CONFIG; - if (link->state & DEV_STALE_LINK) + if (link->state & DEV_STALE_CONFIG) wl3501_detach(link); out: return; -- 2.53.0