patch-2.3.99-pre2 linux/drivers/net/net_init.c
Next file: linux/drivers/net/pcnet32.c
Previous file: linux/drivers/net/Makefile
Back to the patch index
Back to the overall index
- Lines: 73
- Date:
Sat Mar 18 16:48:22 2000
- Orig file:
v2.3.99-pre1/linux/drivers/net/net_init.c
- Orig date:
Tue Mar 7 14:32:26 2000
diff -u --recursive --new-file v2.3.99-pre1/linux/drivers/net/net_init.c linux/drivers/net/net_init.c
@@ -70,10 +70,9 @@
{
struct net_device *dev;
int alloc_size;
-
- /* 32-byte alignment */
+
+ /* ensure 32-byte alignment of the private area */
alloc_size = sizeof (*dev) + IFNAMSIZ + sizeof_priv + 31;
- alloc_size &= ~31;
dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
if (dev == NULL)
@@ -85,9 +84,9 @@
memset(dev, 0, alloc_size);
if (sizeof_priv)
- dev->priv = (void *) (dev + 1);
+ dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
- dev->name = sizeof_priv + (char *)(dev + 1);
+ dev->name = sizeof_priv + 31 + (char *)(dev + 1);
return dev;
}
@@ -395,6 +394,8 @@
int register_netdev(struct net_device *dev)
{
+ int err;
+
rtnl_lock();
/*
@@ -404,8 +405,9 @@
if (dev->name && strchr(dev->name, '%'))
{
+ err = -EBUSY;
if(dev_alloc_name(dev, dev->name)<0)
- return -EBUSY;
+ goto out;
}
/*
@@ -414,17 +416,21 @@
if (dev->name && (dev->name[0]==0 || dev->name[0]==' '))
{
+ err = -EBUSY;
if(dev_alloc_name(dev, "eth%d")<0)
- return -EBUSY;
+ goto out;
}
- if (register_netdevice(dev)) {
- rtnl_unlock();
- return -EIO;
- }
+ err = -EIO;
+ if (register_netdevice(dev))
+ goto out;
+
+ err = 0;
+
+out:
rtnl_unlock();
- return 0;
+ return err;
}
void unregister_netdev(struct net_device *dev)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)