Commit 06290b1b authored by Stephen Hemminger's avatar Stephen Hemminger

[netdrvr dgrs] convert to using alloc_etherdev

parent 263cd274
...@@ -1252,18 +1252,12 @@ dgrs_found_device( ...@@ -1252,18 +1252,12 @@ dgrs_found_device(
{ {
DGRS_PRIV *priv; DGRS_PRIV *priv;
struct net_device *dev, *aux; struct net_device *dev, *aux;
/* Allocate and fill new device structure. */
int dev_size = sizeof(struct net_device) + sizeof(DGRS_PRIV);
int i, ret; int i, ret;
dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL); dev = alloc_etherdev(sizeof(DGRS_PRIV));
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
memset(dev, 0, dev_size);
dev->priv = ((void *)dev) + sizeof(struct net_device);
priv = (DGRS_PRIV *)dev->priv; priv = (DGRS_PRIV *)dev->priv;
dev->base_addr = io; dev->base_addr = io;
...@@ -1279,7 +1273,7 @@ dgrs_found_device( ...@@ -1279,7 +1273,7 @@ dgrs_found_device(
dev->init = dgrs_probe1; dev->init = dgrs_probe1;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
ether_setup(dev);
if (register_netdev(dev) != 0) { if (register_netdev(dev) != 0) {
kfree(dev); kfree(dev);
return -EIO; return -EIO;
...@@ -1302,15 +1296,18 @@ dgrs_found_device( ...@@ -1302,15 +1296,18 @@ dgrs_found_device(
struct net_device *devN; struct net_device *devN;
DGRS_PRIV *privN; DGRS_PRIV *privN;
/* Allocate new dev and priv structures */ /* Allocate new dev and priv structures */
devN = (struct net_device *) kmalloc(dev_size, GFP_KERNEL); devN = alloc_etherdev(sizeof(DGRS_PRIV));
/* Make it an exact copy of dev[0]... */
ret = -ENOMEM; ret = -ENOMEM;
if (!devN) if (!devN)
goto fail; goto fail;
memcpy(devN, dev, dev_size);
memset(devN->name, 0, sizeof(devN->name)); /* Make it an exact copy of dev[0]... */
devN->priv = ((void *)devN) + sizeof(struct net_device); *devN = *dev;
/* copy the priv structure of dev[0] */
privN = (DGRS_PRIV *)devN->priv; privN = (DGRS_PRIV *)devN->priv;
*privN = *priv;
/* ... and zero out VM areas */ /* ... and zero out VM areas */
privN->vmem = 0; privN->vmem = 0;
privN->vplxdma = 0; privN->vplxdma = 0;
...@@ -1318,9 +1315,11 @@ dgrs_found_device( ...@@ -1318,9 +1315,11 @@ dgrs_found_device(
devN->irq = 0; devN->irq = 0;
/* ... and base MAC address off address of 1st port */ /* ... and base MAC address off address of 1st port */
devN->dev_addr[5] += i; devN->dev_addr[5] += i;
/* ... choose a new name */
strncpy(devN->name, "eth%d", IFNAMSIZ);
devN->init = dgrs_initclone; devN->init = dgrs_initclone;
SET_MODULE_OWNER(devN); SET_MODULE_OWNER(devN);
ether_setup(devN);
ret = -EIO; ret = -EIO;
if (register_netdev(devN)) { if (register_netdev(devN)) {
kfree(devN); kfree(devN);
......
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