use code in module_exit?

Dominik Brodowski linux at brodo.de
Mon Aug 18 23:07:06 BST 2003


On Sun, Aug 17, 2003 at 09:44:40PM +0100, Christoph Hellwig wrote:
> All pcmcia drivers have code in module_exit() to walk dev_list
> and call detach on all remaining dev_link_t.  But looking at ds.c
> we see that we get a module reference before each ->attach and release
> the reference only after ->detach so this code is completly superflous.
> 
> That's what my testing with orinoco_cs suggest aswell.
> 
> Can we just rip out lots of long-obsolete code or did I miss something
> obvious?

IIRC, this is not as easy. From pcnet_cs.c :

static void pcnet_detach(dev_link_t *link)
{
    pcnet_dev_t *info = 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;

    if (link->state & DEV_CONFIG) {
	pcnet_release(link);
	if (link->state & DEV_STALE_CONFIG) {
	    link->state |= DEV_STALE_LINK;
	    return;
    ...

which means that if DEV_STALE_CONFIG is set while doing
pcnet_driver->detach(), dev_link_t *link isn't removed
from the dev_list. This is only done if either pcnet_driver->attach() calls
flush_stale_links, or (hopefully) in the second run being called by
exit_pcnet_cs().

However, is this still true?:

/*======================================================================

    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.
    
======================================================================*/


If not, all this **** could be cleaned up.

	Dominik



More information about the linux-pcmcia mailing list