patch-2.4.6 linux/drivers/net/wan/comx-hw-mixcom.c

Next file: linux/drivers/net/wan/comx-proto-fr.c
Previous file: linux/drivers/net/via-rhine.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/drivers/net/wan/comx-hw-mixcom.c linux/drivers/net/wan/comx-hw-mixcom.c
@@ -487,15 +487,18 @@
 	struct mixcom_privdata *hw = ch->HW_privdata;
 	struct proc_dir_entry *procfile = ch->procdir->subdir;
 	unsigned long flags; 
+	int ret = -ENODEV;
 
-	if (!dev->base_addr || !dev->irq) return -ENODEV;
+	if (!dev->base_addr || !dev->irq)
+		goto err_ret;
 
 
 	if(hw->channel==1) {
 		if(!TWIN(dev) || !(COMX_CHANNEL(TWIN(dev))->init_status & 
 		    IRQ_ALLOCATED)) {
 			printk(KERN_ERR "%s: channel 0 not yet initialized\n",dev->name);
-			return -EAGAIN;
+			ret = -EAGAIN;
+			goto err_ret;
 		}
 	}
 
@@ -503,28 +506,29 @@
 	/* Is our hw present at all ? Not checking for channel 0 if it is already 
 	   open */
 	if(hw->channel!=0 || !(ch->init_status & IRQ_ALLOCATED)) {
-		if (check_region(dev->base_addr, MIXCOM_IO_EXTENT)) {
-			return -EAGAIN;
+		if (!request_region(dev->base_addr, MIXCOM_IO_EXTENT, dev->name)) {
+			ret = -EAGAIN;
+			goto err_ret;
 		}
 		if (mixcom_probe(dev)) {
-			return -ENODEV;
+			ret = -ENODEV;
+			goto err_release_region;
 		}
 	}
 
-	save_flags(flags); cli();
-
-	if(hw->channel==1) {
-		request_region(dev->base_addr, MIXCOM_IO_EXTENT, dev->name);
-	} 
-
 	if(hw->channel==0 && !(ch->init_status & IRQ_ALLOCATED)) {
 		if (request_irq(dev->irq, MIXCOM_interrupt, 0, 
 		    dev->name, (void *)dev)) {
 			printk(KERN_ERR "MIXCOM: unable to obtain irq %d\n", dev->irq);
-			return -EAGAIN;
+			ret = -EAGAIN;
+			goto err_release_region;
 		}
+	}
+
+	save_flags(flags); cli();
+
+	if(hw->channel==0 && !(ch->init_status & IRQ_ALLOCATED)) {
 		ch->init_status|=IRQ_ALLOCATED;
-		request_region(dev->base_addr, MIXCOM_IO_EXTENT, dev->name);
 		mixcom_board_on(dev);
 	}
 
@@ -560,6 +564,13 @@
 	}
 
 	return 0;
+	
+err_restore_flags:
+	restore_flags(flags);
+err_release_region:
+	release_region(dev->base_addr, MIXCOM_IO_EXTENT);
+err_ret:
+	return ret;
 }
 
 static int MIXCOM_close(struct net_device *dev)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)