People from time to time point out a wart in ethernet initialization: The net_device is allocated and registered to the system in init_etherdev, which is usually one of the first things an ethernet driver probe function does. The net_device's final members are setup at some time between then and the exit of the probe function. There is never a clear point where the net device is available to the system for use. Our API already supports a solution -- setup the device, then call register_netdev. The patch below adds a helper, alloc_etherdev, to eliminate duplicate code in drivers. Ethernet device initialization, after the patch, should now look like dev = alloc_etherdev(sizeof(struct netdev_private)); ... initialize device ... ... set up net_device struct members ... rc = register_netdevice(dev); if (rc) /* handle error */ netif_start_queue(dev); This makes the ethernet driver look and behave similar to other APIs in the kernel, and presents a nice and atomic present-this-netdev-to-the-system operation. It should be noted that there is a net_device::init function. IIRC in the last discussion of this issue, ::init() was mentioned as a possible solution. I agree that init() can be used, but I do not like the idea of using init as a probe function, as the ISA drivers do it. This means the ethernet device has the potential of holdling rtnl_lock for a long time, and staying in the probe function, inside register_netdevice, for a long time. And... I agree that init() can be used as a constructor for filling in dev->xxx and dev->priv->xxx values, but I think doing so is pointless: you must fill in certain values before your "constructor" is called, just so your constructor has enough information to operate. Patch description: * Add alloc_etherdev, alloc_trdev, alloc_hippi_dev, alloc_fcdev, ... * Use declarator macros to create init_etherdev, init_trdev, etc., and remove duplicate code. * Move net_init EXPORT_SYMBOL from net/netsyms.c to net_init.c. * Convert drivers/net/8139too.c to use alloc_etherdev, as an example. Final word, mostly PCI drivers need this change. ISA drivers use the net_device::init constructor approach. IMHO they shouldn't stay in register_netdevice so long, but that is a wart. This patch fixes a bug, the huge span of time between init_etherdev and the indeterminant point in the future when the net device is ready for use. Comments? -- Jeff Garzik | "You see, in this world there's two kinds of Building 1024 | people, my friend: Those with loaded guns MandrakeSoft | and those who dig. You dig." --Blondie