alloc_netdev()函数生成一个net_device结构体,对其成员赋值并返回该结构体的指针。第一个参数是设备私有成员的大小,第二个参数为设备名,第三个参数为net_device的setup()函数指针。setup()函数接收的参数为struct net_device指针,用于预置net_device成员的值。 linux-2.6.22/net/core/dev.c ---------------------------------------- struct net_device *alloc_netdev(int sizeof_priv, const char *name, void (*setup)(struct net_device *)) { void *p; struct net_device *dev; int alloc_size; BUG_ON(strlen(name) >= sizeof(dev->name)); /* ensure 32-byte alignment of both the device and private area */ alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST; alloc_size +