Commit 29d55497 authored by Alexander Viro's avatar Alexander Viro Committed by Christoph Hellwig

[PATCH] remove init_{etherdev,netdev} and dev_alloc

These are racy by "design", and all users have been eliminated.
parent d25843bd
......@@ -103,116 +103,6 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *mask,
}
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 sizeof_priv)
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)
......
......@@ -38,12 +38,6 @@ extern int eth_header_cache(struct neighbour *neigh,
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)
......
......@@ -525,11 +525,6 @@ extern struct net_device *__dev_get_by_flags(unsigned short flags,
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);
......
......@@ -809,40 +809,6 @@ int dev_change_name(struct net_device *dev, char *newname)
return 0;
}
/**
* 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
......@@ -3232,7 +3198,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment