Commit edc25b0d authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr r8169] use alloc_etherdev, pci_disable_device

parent 7cc3fd49
...@@ -365,8 +365,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, ...@@ -365,8 +365,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
*ioaddr_out = NULL; *ioaddr_out = NULL;
*dev_out = NULL; *dev_out = NULL;
// dev zeroed in init_etherdev // dev zeroed in alloc_etherdev
dev = init_etherdev(NULL, sizeof (*tp)); dev = alloc_etherdev(sizeof (*tp));
if (dev == NULL) { if (dev == NULL) {
printk(KERN_ERR PFX "unable to alloc new ethernet\n"); printk(KERN_ERR PFX "unable to alloc new ethernet\n");
return -ENOMEM; return -ENOMEM;
...@@ -391,18 +391,18 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, ...@@ -391,18 +391,18 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
printk(KERN_ERR PFX printk(KERN_ERR PFX
"region #1 not an MMIO resource, aborting\n"); "region #1 not an MMIO resource, aborting\n");
rc = -ENODEV; rc = -ENODEV;
goto err_out; goto err_out_disable;
} }
// check for weird/broken PCI region reporting // check for weird/broken PCI region reporting
if (mmio_len < RTL_MIN_IO_SIZE) { if (mmio_len < RTL_MIN_IO_SIZE) {
printk(KERN_ERR PFX "Invalid PCI region size(s), aborting\n"); printk(KERN_ERR PFX "Invalid PCI region size(s), aborting\n");
rc = -ENODEV; rc = -ENODEV;
goto err_out; goto err_out_disable;
} }
rc = pci_request_regions(pdev, dev->name); rc = pci_request_regions(pdev, dev->name);
if (rc) if (rc)
goto err_out; goto err_out_disable;
// enable PCI bus-mastering // enable PCI bus-mastering
pci_set_master(pdev); pci_set_master(pdev);
...@@ -450,8 +450,10 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out, ...@@ -450,8 +450,10 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
err_out_free_res: err_out_free_res:
pci_release_regions(pdev); pci_release_regions(pdev);
err_out_disable:
pci_disable_device(pdev);
err_out: err_out:
unregister_netdev(dev);
kfree(dev); kfree(dev);
return rc; return rc;
} }
...@@ -464,7 +466,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -464,7 +466,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
void *ioaddr = NULL; void *ioaddr = NULL;
static int board_idx = -1; static int board_idx = -1;
static int printed_version = 0; static int printed_version = 0;
int i; int i, rc;
int option = -1, Cap10_100 = 0, Cap1000 = 0; int option = -1, Cap10_100 = 0, Cap1000 = 0;
assert(pdev != NULL); assert(pdev != NULL);
...@@ -477,20 +479,18 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -477,20 +479,18 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
printed_version = 1; printed_version = 1;
} }
i = rtl8169_init_board(pdev, &dev, &ioaddr); rc = rtl8169_init_board(pdev, &dev, &ioaddr);
if (i < 0) { if (rc)
return i; return rc;
}
tp = dev->priv; tp = dev->priv;
assert(ioaddr != NULL); assert(ioaddr != NULL);
assert(dev != NULL); assert(dev != NULL);
assert(tp != NULL); assert(tp != NULL);
// Get MAC address // // Get MAC address. FIXME: read EEPROM
for (i = 0; i < MAC_ADDR_LEN; i++) { for (i = 0; i < MAC_ADDR_LEN; i++)
dev->dev_addr[i] = RTL_R8(MAC0 + i); dev->dev_addr[i] = RTL_R8(MAC0 + i);
}
dev->open = rtl8169_open; dev->open = rtl8169_open;
dev->hard_start_xmit = rtl8169_start_xmit; dev->hard_start_xmit = rtl8169_start_xmit;
...@@ -507,11 +507,20 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -507,11 +507,20 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->pci_dev = pdev; tp->pci_dev = pdev;
tp->mmio_addr = ioaddr; tp->mmio_addr = ioaddr;
spin_lock_init(&tp->lock);
rc = register_netdev(dev);
if (rc) {
iounmap(ioaddr);
pci_release_regions(pdev);
pci_disable_device(pdev);
kfree(dev);
return rc;
}
printk(KERN_DEBUG "%s: Identified chip type is '%s'.\n", dev->name, printk(KERN_DEBUG "%s: Identified chip type is '%s'.\n", dev->name,
rtl_chip_info[tp->chipset].name); rtl_chip_info[tp->chipset].name);
spin_lock_init(&tp->lock);
pci_set_drvdata(pdev, dev); pci_set_drvdata(pdev, dev);
printk(KERN_INFO "%s: %s at 0x%lx, " printk(KERN_INFO "%s: %s at 0x%lx, "
...@@ -623,7 +632,7 @@ static void __devexit ...@@ -623,7 +632,7 @@ static void __devexit
rtl8169_remove_one(struct pci_dev *pdev) rtl8169_remove_one(struct pci_dev *pdev)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
struct rtl8169_private *tp = (struct rtl8169_private *) (dev->priv); struct rtl8169_private *tp = dev->priv;
assert(dev != NULL); assert(dev != NULL);
assert(tp != NULL); assert(tp != NULL);
...@@ -636,6 +645,7 @@ rtl8169_remove_one(struct pci_dev *pdev) ...@@ -636,6 +645,7 @@ rtl8169_remove_one(struct pci_dev *pdev)
memset(dev, 0xBC, memset(dev, 0xBC,
sizeof (struct net_device) + sizeof (struct rtl8169_private)); sizeof (struct net_device) + sizeof (struct rtl8169_private));
pci_disable_device(pdev);
kfree(dev); kfree(dev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
} }
......
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