Commit c9ad2f34 authored by Dave Jones's avatar Dave Jones Committed by Jeff Garzik

[PATCH] xircom init cleanups

parent cb9370a8
...@@ -243,38 +243,29 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_ ...@@ -243,38 +243,29 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
return -ENODEV; return -ENODEV;
} }
/* /*
Before changing the hardware, allocate the memory. Before changing the hardware, allocate the memory.
This way, we can fail gracefully if not enough memory This way, we can fail gracefully if not enough memory
is available. is available.
*/ */
private = kmalloc(sizeof(*private),GFP_KERNEL); if ((dev = init_etherdev(NULL, sizeof(struct xircom_private))) == NULL) {
memset(private, 0, sizeof(struct xircom_private)); printk(KERN_ERR "xircom_probe: failed to allocate etherdev\n");
goto device_fail;
}
private = dev->priv;
/* Allocate the send/receive buffers */ /* Allocate the send/receive buffers */
private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle); private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle);
if (private->rx_buffer == NULL) { if (private->rx_buffer == NULL) {
printk(KERN_ERR "xircom_probe: no memory for rx buffer \n"); printk(KERN_ERR "xircom_probe: no memory for rx buffer \n");
kfree(private); goto rx_buf_fail;
return -ENODEV;
} }
private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle); private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle);
if (private->tx_buffer == NULL) { if (private->tx_buffer == NULL) {
printk(KERN_ERR "xircom_probe: no memory for tx buffer \n"); printk(KERN_ERR "xircom_probe: no memory for tx buffer \n");
kfree(private->rx_buffer); goto tx_buf_fail;
kfree(private);
return -ENODEV;
}
dev = init_etherdev(dev, 0);
if (dev == NULL) {
printk(KERN_ERR "xircom_probe: failed to allocate etherdev\n");
kfree(private->rx_buffer);
kfree(private->tx_buffer);
kfree(private);
return -ENODEV;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq); printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq);
...@@ -305,14 +296,21 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_ ...@@ -305,14 +296,21 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
transceiver_voodoo(private); transceiver_voodoo(private);
spin_lock_irqsave(&private->lock,flags); spin_lock_irqsave(&private->lock,flags);
activate_transmitter(private); activate_transmitter(private);
activate_receiver(private); activate_receiver(private);
spin_unlock_irqrestore(&private->lock,flags); spin_unlock_irqrestore(&private->lock,flags);
trigger_receive(private); trigger_receive(private);
leave("xircom_probe"); leave("xircom_probe");
return 0; return 0;
tx_buf_fail:
kfree(private->rx_buffer);
rx_buf_fail:
kfree(dev);
device_fail:
return -ENODEV;
} }
...@@ -337,7 +335,6 @@ static void __devexit xircom_remove(struct pci_dev *pdev) ...@@ -337,7 +335,6 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle); pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle);
card->tx_buffer = NULL; card->tx_buffer = NULL;
} }
kfree(card);
} }
release_region(dev->base_addr, 128); release_region(dev->base_addr, 128);
unregister_netdev(dev); unregister_netdev(dev);
......
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