patch-2.4.0-test11 linux/drivers/net/seeq8005.c
Next file: linux/drivers/net/sis900.c
Previous file: linux/drivers/net/rrunner.c
Back to the patch index
Back to the overall index
- Lines: 135
- Date:
Sat Nov 11 18:56:58 2000
- Orig file:
v2.4.0-test10/linux/drivers/net/seeq8005.c
- Orig date:
Tue Oct 31 12:42:26 2000
diff -u --recursive --new-file v2.4.0-test10/linux/drivers/net/seeq8005.c linux/drivers/net/seeq8005.c
@@ -116,13 +116,9 @@
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
- for (i = 0; seeq8005_portlist[i]; i++) {
- int ioaddr = seeq8005_portlist[i];
- if (check_region(ioaddr, SEEQ8005_IO_EXTENT))
- continue;
- if (seeq8005_probe1(dev, ioaddr) == 0)
+ for (i = 0; seeq8005_portlist[i]; i++)
+ if (seeq8005_probe1(dev, seeq8005_portlist[i]) == 0)
return 0;
- }
return -ENODEV;
}
@@ -133,7 +129,7 @@
static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
{
- static unsigned version_printed = 0;
+ static unsigned version_printed;
int i,j;
unsigned char SA_prom[32];
int old_cfg1;
@@ -141,33 +137,42 @@
int old_stat;
int old_dmaar;
int old_rear;
+ int retval;
+
+ if (!request_region(ioaddr, SEEQ8005_IO_EXTENT, "seeq8005"))
+ return -ENODEV;
if (net_debug>1)
printk("seeq8005: probing at 0x%x\n",ioaddr);
old_stat = inw(SEEQ_STATUS); /* read status register */
- if (old_stat == 0xffff)
- return -ENODEV; /* assume that 0xffff == no device */
+ if (old_stat == 0xffff) {
+ retval = -ENODEV;
+ goto out; /* assume that 0xffff == no device */
+ }
if ( (old_stat & 0x1800) != 0x1800 ) { /* assume that unused bits are 1, as my manual says */
if (net_debug>1) {
printk("seeq8005: reserved stat bits != 0x1800\n");
printk(" == 0x%04x\n",old_stat);
}
- return -ENODEV;
+ retval = -ENODEV;
+ goto out;
}
old_rear = inw(SEEQ_REA);
if (old_rear == 0xffff) {
outw(0,SEEQ_REA);
if (inw(SEEQ_REA) == 0xffff) { /* assume that 0xffff == no device */
- return -ENODEV;
+ retval = -ENODEV;
+ goto out;
}
} else if ((old_rear & 0xff00) != 0xff00) { /* assume that unused bits are 1 */
if (net_debug>1) {
printk("seeq8005: unused rear bits != 0xff00\n");
printk(" == 0x%04x\n",old_rear);
}
- return -ENODEV;
+ retval = -ENODEV;
+ goto out;
}
old_cfg2 = inw(SEEQ_CFG2); /* read CFG2 register */
@@ -185,8 +190,8 @@
outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); /* setup for reading PROM */
outw( 0, SEEQ_DMAAR); /* set starting PROM address */
outw( SEEQCFG1_BUFFER_PROM, SEEQ_CFG1); /* set buffer to look at PROM */
-
-
+
+
j=0;
for(i=0; i <32; i++) {
j+= SA_prom[i] = inw(SEEQ_BUFFER) & 0xff;
@@ -201,7 +206,8 @@
outw( old_stat, SEEQ_STATUS);
outw( old_dmaar, SEEQ_DMAAR);
outw( old_cfg1, SEEQ_CFG1);
- return -ENODEV;
+ retval = -ENODEV;
+ goto out;
}
#endif
@@ -279,11 +285,11 @@
if (dev->irq == 0xff)
; /* Do nothing: a user-level program will set it. */
else if (dev->irq < 2) { /* "Auto-IRQ" */
- autoirq_setup(0);
+ unsigned long cookie = probe_irq_on();
outw( SEEQCMD_RX_INT_EN | SEEQCMD_SET_RX_ON | SEEQCMD_SET_RX_OFF, SEEQ_CMD );
- dev->irq = autoirq_report(0);
+ dev->irq = probe_irq_off(cookie);
if (net_debug >= 2)
printk(" autoirq is %d\n", dev->irq);
@@ -299,14 +305,12 @@
if (irqval) {
printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
dev->irq, irqval);
- return -EAGAIN;
+ retval = -EAGAIN;
+ goto out;
}
}
#endif
- /* Grab the region so we can find another board if autoIRQ fails. */
- request_region(ioaddr, SEEQ8005_IO_EXTENT,"seeq8005");
-
/* Initialize the device structure. */
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL)
@@ -327,6 +331,9 @@
dev->flags &= ~IFF_MULTICAST;
return 0;
+out:
+ release_region(ioaddr, SEEQ8005_IO_EXTENT);
+ return retval;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)