From: davej@codemonkey.org.uk
To: jgarzik@pobox.com
Cc: linux-kernel@vger.kernel.org
Subject: xircom init cleanups
Date: Thu, 15 May 2003 04:31:10 +0100 [thread overview]
Message-ID: <200305150331.h4F3VAH6000662@deviant.impure.org.uk> (raw)
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);
reply other threads:[~2003-05-15 3:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200305150331.h4F3VAH6000662@deviant.impure.org.uk \
--to=davej@codemonkey.org.uk \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®