Commit 83a05e30 authored by William Stinson's avatar William Stinson Committed by Jeff Garzik

[janitor] update the ni65 network driver to

        1) remove call to check_region and use request_region instead checking the return value 
        2) release region resource in case of driver initialisation error

I don't have this hardware so compilation checked only.
parent 16315ada
......@@ -353,18 +353,21 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
unsigned long flags;
for(i=0;i<NUM_CARDS;i++) {
if(check_region(ioaddr, cards[i].total_size))
if(!request_region(ioaddr, cards[i].total_size, cards[i].cardname))
continue;
if(cards[i].id_offset >= 0) {
if(inb(ioaddr+cards[i].id_offset+0) != cards[i].id0 ||
inb(ioaddr+cards[i].id_offset+1) != cards[i].id1) {
release_region(ioaddr, cards[i].total_size);
continue;
}
}
if(cards[i].vendor_id) {
for(j=0;j<3;j++)
if(inb(ioaddr+cards[i].addr_offset+j) != cards[i].vendor_id[j])
if(inb(ioaddr+cards[i].addr_offset+j) != cards[i].vendor_id[j]) {
release_region(ioaddr, cards[i].total_size);
continue;
}
}
break;
}
......@@ -374,8 +377,10 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
for(j=0;j<6;j++)
dev->dev_addr[j] = inb(ioaddr+cards[i].addr_offset+j);
if( (j=ni65_alloc_buffer(dev)) < 0)
if( (j=ni65_alloc_buffer(dev)) < 0) {
release_region(ioaddr, cards[i].total_size);
return j;
}
p = (struct priv *) dev->priv;
p->cmdr_addr = ioaddr + cards[i].cmd_offset;
p->cardno = i;
......@@ -386,6 +391,7 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
if( (j=readreg(CSR0)) != 0x4) {
printk(KERN_ERR "can't RESET card: %04x\n",j);
ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN;
}
......@@ -437,6 +443,7 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
if(i == 5) {
printk("Can't detect DMA channel!\n");
ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN;
}
dev->dma = dmatab[i];
......@@ -459,6 +466,7 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
{
printk("Failed to detect IRQ line!\n");
ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN;
}
printk("IRQ %d (autodetected).\n",dev->irq);
......@@ -471,14 +479,10 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
{
printk("%s: Can't request dma-channel %d\n",dev->name,(int) dev->dma);
ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN;
}
/*
* Grab the region so we can find another board.
*/
request_region(ioaddr,cards[p->cardno].total_size,cards[p->cardno].cardname);
dev->base_addr = ioaddr;
dev->open = ni65_open;
......
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