Commit 6ffc67a8 authored by Jeff Garzik's avatar Jeff Garzik Committed by Stephen Hemminger

[netdrvr tc35815] switch to using alloc_etherdev

Also handle ioremap failure.
parent f87f47b4
...@@ -525,31 +525,32 @@ tc35815_probe(struct pci_dev *pdev, ...@@ -525,31 +525,32 @@ tc35815_probe(struct pci_dev *pdev,
static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr, unsigned int irq) static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr, unsigned int irq)
{ {
static unsigned version_printed = 0; static unsigned version_printed = 0;
int i; int i, ret;
struct tc35815_local *lp; struct tc35815_local *lp;
struct tc35815_regs *tr; struct tc35815_regs *tr;
struct net_device *dev; struct net_device *dev;
/* Allocate a new 'dev' if needed. */ /* Allocate a new 'dev' if needed. */
dev = init_etherdev(NULL, sizeof(struct tc35815_local)); dev = alloc_etherdev(sizeof(struct tc35815_local));
if (dev == NULL) if (dev == NULL)
return -ENOMEM; return -ENOMEM;
/* /*
* init_etherdev allocs and zeros dev->priv * alloc_etherdev allocs and zeros dev->priv
*/ */
lp = dev->priv; lp = dev->priv;
if (tc35815_debug && version_printed++ == 0) if (tc35815_debug && version_printed++ == 0)
printk(KERN_DEBUG "%s", version); printk(KERN_DEBUG "%s", version);
printk(KERN_INFO "%s: %s found at %#x, irq %d\n",
dev->name, cardname, base_addr, irq);
/* Fill in the 'dev' fields. */ /* Fill in the 'dev' fields. */
dev->irq = irq; dev->irq = irq;
dev->base_addr = (unsigned long)ioremap(base_addr, dev->base_addr = (unsigned long)ioremap(base_addr,
sizeof(struct tc35815_regs)); sizeof(struct tc35815_regs));
if (!dev->base_addr) {
ret = -ENOMEM;
goto err_out;
}
tr = (struct tc35815_regs*)dev->base_addr; tr = (struct tc35815_regs*)dev->base_addr;
tc35815_chip_reset(dev); tc35815_chip_reset(dev);
...@@ -566,9 +567,6 @@ static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr ...@@ -566,9 +567,6 @@ static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr
dev->dev_addr[i] = data & 0xff; dev->dev_addr[i] = data & 0xff;
dev->dev_addr[i+1] = data >> 8; dev->dev_addr[i+1] = data >> 8;
} }
for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i]);
printk("\n");
/* Initialize the device structure. */ /* Initialize the device structure. */
lp->pdev = pdev; lp->pdev = pdev;
...@@ -590,8 +588,6 @@ static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr ...@@ -590,8 +588,6 @@ static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr
/* do auto negotiation */ /* do auto negotiation */
tc35815_phy_chip_init(dev); tc35815_phy_chip_init(dev);
printk(KERN_INFO "%s: linkspeed %dMbps, %s Duplex\n",
dev->name, lp->linkspeed, lp->fullduplex ? "Full" : "Half");
dev->open = tc35815_open; dev->open = tc35815_open;
dev->stop = tc35815_close; dev->stop = tc35815_close;
...@@ -602,12 +598,25 @@ static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr ...@@ -602,12 +598,25 @@ static int __devinit tc35815_probe1(struct pci_dev *pdev, unsigned int base_addr
dev->set_multicast_list = tc35815_set_multicast_list; dev->set_multicast_list = tc35815_set_multicast_list;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
#if 0 /* XXX called in init_etherdev */ ret = register_netdev(dev);
/* Fill in the fields of the device structure with ethernet values. */ if (ret)
ether_setup(dev); goto err_out_iounmap;
#endif
printk(KERN_INFO "%s: %s found at %#x, irq %d, MAC",
dev->name, cardname, base_addr, irq);
for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i]);
printk("\n");
printk(KERN_INFO "%s: linkspeed %dMbps, %s Duplex\n",
dev->name, lp->linkspeed, lp->fullduplex ? "Full" : "Half");
return 0; return 0;
err_out_iounmap:
iounmap((void *) dev->base_addr);
err_out:
free_netdev(dev);
return ret;
} }
......
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