From: viro@parcelfarce.linux.theplanet.co.uk Removal of the following: init_etherdev() init_netdev() dev_alloc() Rationale: all of them are inherently racy and all users should be gone by now. They _are_ exported, but any 3rd-party driver that still uses them is broken. --- drivers/net/net_init.c | 111 -------------------------------------------- include/linux/etherdevice.h | 6 -- include/linux/netdevice.h | 5 - net/core/dev.c | 35 ------------- 4 files changed, 157 deletions(-) diff -puN drivers/net/net_init.c~kill-old-dead-netdev-apis drivers/net/net_init.c --- 25/drivers/net/net_init.c~kill-old-dead-netdev-apis 2004-02-24 18:26:46.000000000 -0800 +++ 25-akpm/drivers/net/net_init.c 2004-02-24 18:26:46.000000000 -0800 @@ -103,116 +103,6 @@ struct net_device *alloc_netdev(int size } EXPORT_SYMBOL(alloc_netdev); -static struct net_device *init_alloc_dev(int sizeof_priv) -{ - struct net_device *dev; - int alloc_size; - - /* ensure 32-byte alignment of the private area */ - alloc_size = sizeof (*dev) + sizeof_priv + 31; - - dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL); - if (dev == NULL) - { - printk(KERN_ERR "alloc_dev: Unable to allocate device memory.\n"); - return NULL; - } - - memset(dev, 0, alloc_size); - - if (sizeof_priv) - dev->priv = (void *) (((long)(dev + 1) + 31) & ~31); - - return dev; -} - -/* - * Create and name a device from a prototype, then perform any needed - * setup. - */ - -static struct net_device *init_netdev(struct net_device *dev, int sizeof_priv, - char *mask, void (*setup)(struct net_device *)) -{ - int new_device = 0; - - /* - * Allocate a device if one is not provided. - */ - - if (dev == NULL) { - dev=init_alloc_dev(sizeof_priv); - if(dev==NULL) - return NULL; - new_device = 1; - } - - /* - * Allocate a name - */ - - if (dev->name[0] == '\0' || dev->name[0] == ' ') { - strcpy(dev->name, mask); - rtnl_lock(); - if (dev_alloc_name(dev, mask)<0) { - rtnl_unlock(); - if (new_device) - kfree(dev); - return NULL; - } - rtnl_unlock(); - } - - netdev_boot_setup_check(dev); - - /* - * Configure via the caller provided setup function then - * register if needed. - */ - - setup(dev); - - if (new_device) { - int err; - - rtnl_lock(); - err = register_netdevice(dev); - rtnl_unlock(); - - if (err < 0) { - kfree(dev); - dev = NULL; - } - } - return dev; -} - -/** - * init_etherdev - Register ethernet device - * @dev: An ethernet device structure to be filled in, or %NULL if a new - * struct should be allocated. - * @sizeof_priv: Size of additional driver-private structure to be allocated - * for this ethernet device - * - * Fill in the fields of the device structure with ethernet-generic values. - * - * If no device structure is passed, a new one is constructed, complete with - * a private data area of size @sizeof_priv. A 32-byte (not bit) - * alignment is enforced for this private data area. - * - * If an empty string area is passed as dev->name, or a new structure is made, - * a new name string is constructed. - * - * Deprecated because of exposed window between device registration - * and interfaces pointers that need to be set by driver. - * Use alloc_etherdev and register_netdev instead. - */ - -struct net_device *__init_etherdev(struct net_device *dev, int sizeof_priv) -{ - return init_netdev(dev, sizeof_priv, "eth%d", ether_setup); -} - /** * alloc_etherdev - Allocates and sets up an ethernet device * @sizeof_priv: Size of additional driver-private structure to be allocated @@ -231,7 +121,6 @@ struct net_device *alloc_etherdev(int si return alloc_netdev(sizeof_priv, "eth%d", ether_setup); } -EXPORT_SYMBOL(__init_etherdev); EXPORT_SYMBOL(alloc_etherdev); static int eth_mac_addr(struct net_device *dev, void *p) diff -puN include/linux/etherdevice.h~kill-old-dead-netdev-apis include/linux/etherdevice.h --- 25/include/linux/etherdevice.h~kill-old-dead-netdev-apis 2004-02-24 18:26:46.000000000 -0800 +++ 25-akpm/include/linux/etherdevice.h 2004-02-24 18:26:46.000000000 -0800 @@ -38,12 +38,6 @@ extern int eth_header_cache(struct neig struct hh_cache *hh); extern int eth_header_parse(struct sk_buff *skb, unsigned char *haddr); -extern struct net_device *__init_etherdev(struct net_device *dev, int sizeof_priv); -static inline struct net_device *init_etherdev(struct net_device *dev, - int sizeof_priv) -{ - return __init_etherdev(dev, sizeof_priv); -} extern struct net_device *alloc_etherdev(int sizeof_priv); static inline void eth_copy_and_sum (struct sk_buff *dest, unsigned char *src, int len, int base) diff -puN include/linux/netdevice.h~kill-old-dead-netdev-apis include/linux/netdevice.h --- 25/include/linux/netdevice.h~kill-old-dead-netdev-apis 2004-02-24 18:26:46.000000000 -0800 +++ 25-akpm/include/linux/netdevice.h 2004-02-24 18:26:46.000000000 -0800 @@ -531,11 +531,6 @@ extern struct net_device *__dev_get_by_f unsigned short mask); extern struct net_device *dev_get_by_name(const char *name); extern struct net_device *__dev_get_by_name(const char *name); -extern struct net_device *__dev_alloc(const char *name, int *err); -static inline __deprecated struct net_device *dev_alloc(const char *name, int *err) -{ - return __dev_alloc(name, err); -} extern int dev_alloc_name(struct net_device *dev, const char *name); extern int dev_open(struct net_device *dev); extern int dev_close(struct net_device *dev); diff -puN net/core/dev.c~kill-old-dead-netdev-apis net/core/dev.c --- 25/net/core/dev.c~kill-old-dead-netdev-apis 2004-02-24 18:26:46.000000000 -0800 +++ 25-akpm/net/core/dev.c 2004-02-24 18:26:46.000000000 -0800 @@ -811,40 +811,6 @@ int dev_change_name(struct net_device *d } /** - * dev_alloc - allocate a network device and name - * @name: name format string - * @err: error return pointer - * - * Passed a format string, eg. "lt%d", it will allocate a network device - * and space for the name. %NULL is returned if no memory is available. - * If the allocation succeeds then the name is assigned and the - * device pointer returned. %NULL is returned if the name allocation - * failed. The cause of an error is returned as a negative errno code - * in the variable @err points to. - * - * This call is deprecated in favor of alloc_netdev because - * the caller must hold the @dev_base or RTNL locks when doing this in - * order to avoid duplicate name allocations. - */ - -struct net_device *__dev_alloc(const char *name, int *err) -{ - struct net_device *dev = kmalloc(sizeof(*dev), GFP_KERNEL); - - if (!dev) - *err = -ENOBUFS; - else { - memset(dev, 0, sizeof(*dev)); - *err = dev_alloc_name(dev, name); - if (*err < 0) { - kfree(dev); - dev = NULL; - } - } - return dev; -} - -/** * netdev_state_change - device changes state * @dev: device to cause notification * @@ -3247,7 +3213,6 @@ EXPORT_SYMBOL(__dev_remove_pack); EXPORT_SYMBOL(__skb_linearize); EXPORT_SYMBOL(call_netdevice_notifiers); EXPORT_SYMBOL(dev_add_pack); -EXPORT_SYMBOL(__dev_alloc); EXPORT_SYMBOL(dev_alloc_name); EXPORT_SYMBOL(dev_close); EXPORT_SYMBOL(dev_get_by_flags); _