xircom init cleanups
davej@codemonkey.org.uk
Thu, 15 May 2003 04:31:10 +0100
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/drivers/net/tulip/xircom_cb.c linux-2.5/drivers/net/tulip/xircom_cb.c
--- bk-linus/drivers/net/tulip/xircom_cb.c 2003-04-22 00:40:43.000000000 +0100
+++ linux-2.5/drivers/net/tulip/xircom_cb.c 2003-04-22 01:23:14.000000000 +0100
@@ -243,38 +243,29 @@ static int __devinit xircom_probe(struct
return -ENODEV;
}
-
/*
Before changing the hardware, allocate the memory.
This way, we can fail gracefully if not enough memory
is available.
*/
- private = kmalloc(sizeof(*private),GFP_KERNEL);
- memset(private, 0, sizeof(struct xircom_private));
+ if ((dev = init_etherdev(NULL, sizeof(struct xircom_private))) == NULL) {
+ printk(KERN_ERR "xircom_probe: failed to allocate etherdev\n");
+ goto device_fail;
+ }
+ private = dev->priv;
/* Allocate the send/receive buffers */
private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle);
-
if (private->rx_buffer == NULL) {
printk(KERN_ERR "xircom_probe: no memory for rx buffer \n");
- kfree(private);
- return -ENODEV;
+ goto rx_buf_fail;
}
private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle);
if (private->tx_buffer == NULL) {
printk(KERN_ERR "xircom_probe: no memory for tx buffer \n");
- kfree(private->rx_buffer);
- 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;
+ goto tx_buf_fail;
}
+
SET_MODULE_OWNER(dev);
printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq);
@@ -304,14 +295,21 @@ static int __devinit xircom_probe(struct
transceiver_voodoo(private);
spin_lock_irqsave(&private->lock,flags);
- activate_transmitter(private);
- activate_receiver(private);
+ activate_transmitter(private);
+ activate_receiver(private);
spin_unlock_irqrestore(&private->lock,flags);
trigger_receive(private);
leave("xircom_probe");
return 0;
+
+tx_buf_fail:
+ kfree(private->rx_buffer);
+rx_buf_fail:
+ kfree(dev);
+device_fail:
+ return -ENODEV;
}
@@ -336,7 +334,6 @@ static void __devexit xircom_remove(stru
pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle);
card->tx_buffer = NULL;
}
- kfree(card);
}
release_region(dev->base_addr, 128);
unregister_netdev(dev);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/