lkml.org 
[lkml]   [2000]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] drivers/net/sys900.c: bugfix and cleanups
Hi,

Please consider applying, comments are on the patch.

- Arnaldo

--- linux-2.4.0-test8-pre1/drivers/net/sis900.c Thu Aug 10 10:14:32 2000
+++ linux-2.4.0-test8-pre1.acme/drivers/net/sis900.c Thu Aug 31 23:17:10 2000
@@ -18,6 +18,12 @@
preliminary Rev. 1.0 Jan. 18, 1998
http://www.sis.com.tw/support/databook.htm

+ Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/08/31
+ - get rid of check_region (possible race in 2.4)
+ - release the net_dev returned by init_etherdev after unregister_netdevice on failure
+ - no need to allocate and zeroing of net_dev->priv, init_etherdev does this for us
+ - small cleanups
+
Rev 1.07.01 Aug. 08 2000 Ollie Lho minor update fro SiS 630E and SiS 630E A1
Rev 1.07 Mar. 07 2000 Ollie Lho bug fix in Rx buffer ring
Rev 1.06.04 Feb. 11 2000 Jeff Garzik <jgarzik@mandrakesoft.com> softnet and init for kernel 2.4
@@ -179,7 +185,8 @@
}

pci_io_base = pci_resource_start(pci_dev, 0);
- if (check_region(pci_io_base, SIS900_TOTAL_SIZE)) {
+ /* We do a request_region() to register /proc/ioports info. */
+ if (!request_region(pci_io_base, SIS900_TOTAL_SIZE, "sis900")) {
printk(KERN_ERR "sis900.c: can't allocate I/O space at 0x%08x\n",
pci_io_base);
return -ENODEV;
@@ -187,14 +194,18 @@

/* setup various bits in PCI command register */
if (pci_enable_device (pci_dev))
- return -ENODEV;
+ goto cleanup_region;
+
pci_set_master(pci_dev);

/* do the real low level jobs */
if (sis900_mac_probe(pci_dev, card_names[pci_id->driver_data]) == NULL)
- return -ENODEV;
+ goto cleanup_region;

return 0;
+cleanup_region:
+ release_region(pci_io_base, SIS900_TOTAL_SIZE);
+ return -ENODEV;
}

/* older SiS900 and friends, use EEPROM to store MAC address */
@@ -274,7 +285,8 @@
int i, ret = 0;
u8 revision;

- if ((net_dev = init_etherdev(net_dev, 0)) == NULL)
+ net_dev = init_etherdev(NULL, sizeof(struct sis900_private));
+ if (!net_dev)
return NULL;

pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &revision);
@@ -285,10 +297,8 @@
else
ret = sis900_get_mac_addr(pci_dev, net_dev);

- if (ret == 0) {
- unregister_netdevice(net_dev);
- return NULL;
- }
+ if (ret == 0)
+ goto cleanup_netdev;

/* print some information about our NIC */
printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name,
@@ -297,28 +307,15 @@
printk("%2.2x:", (u8)net_dev->dev_addr[i]);
printk("%2.2x.\n", net_dev->dev_addr[i]);

- if ((net_dev->priv = kmalloc(sizeof(struct sis900_private), GFP_KERNEL)) == NULL) {
- unregister_netdevice(net_dev);
- return NULL;
- }
-
sis_priv = net_dev->priv;
- memset(sis_priv, 0, sizeof(struct sis900_private));
-
- /* We do a request_region() to register /proc/ioports info. */
- request_region(ioaddr, SIS900_TOTAL_SIZE, net_dev->name);
net_dev->base_addr = ioaddr;
net_dev->irq = irq;
sis_priv->pci_dev = pci_dev;
spin_lock_init(&sis_priv->lock);

/* probe for mii transciver */
- if (sis900_mii_probe(net_dev) == 0) {
- unregister_netdev(net_dev);
- kfree(sis_priv);
- release_region(ioaddr, SIS900_TOTAL_SIZE);
- return NULL;
- }
+ if (sis900_mii_probe(net_dev) == 0)
+ goto cleanup_netdev;

pci_dev->driver_data = net_dev;
pci_dev->dma_mask = SIS900_DMA_MASK;
@@ -334,6 +331,10 @@
net_dev->watchdog_timeo = TX_TIMEOUT;

return net_dev;
+cleanup_netdev:
+ unregister_netdevice(net_dev);
+ kfree(net_dev);
+ return NULL;
}

static int __init sis900_mii_probe (struct net_device * net_dev)
@@ -655,7 +656,7 @@
net_dev->name, inl(ioaddr + txdp));
}

-/* Initialize the Rx descriptor ring, pre-allocate recevie buffers */
+/* Initialize the Rx descriptor ring, pre-allocate receive buffers */
static void
sis900_init_rx_ring(struct net_device *net_dev)
{
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.027 / U:49.300 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site