Skip to contentSkip to conversation

make drivers/scsi/fastlane.c check return code of request_irq (241p9)

PATCH In review Rasmus Andersen 1 participant 2 messages Jan 22, 2001 – Jan 23, 2001 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make drivers/scsi/fastlane.c check return code of request_irq (241p9)

Hi.

(I have not been able to find a maintainer for this code.)

The following patch makes drivers/scsi/fastlane.c check the return code of request_irq and converts (some) error paths to use forward gotos.

It applies cleanly against ac10 and 241p9.

Comments?

drivers/scsi/fastlane.c +16 -9
@@ -96,9 +96,7 @@
 		 * this ID value. Fortunately only Fastlane maps in Z3 space
 		 */
 		if (board < 0x1000000) {
-			release_mem_region(board+FASTLANE_ESP_ADDR,
-					   sizeof(struct ESP_regs));
-			return 0;
+			goto err_release;
 		}
 		esp = esp_allocate(tpnt, (void *)board+FASTLANE_ESP_ADDR);
 
@@ -146,10 +144,7 @@
 
 		if(!address){
 			printk("Could not remap Fastlane controller memory!");
-			scsi_unregister (esp->ehost);
-			release_mem_region(board+FASTLANE_ESP_ADDR,
-					   sizeof(struct ESP_regs));
-			return 0;
+			goto err_unregister;
 		}
 
 
@@ -171,8 +166,11 @@
 
 		esp->irq = IRQ_AMIGA_PORTS;
 		esp->slot = board+FASTLANE_ESP_ADDR;
-		request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ,
-			    "Fastlane SCSI", esp_intr);
+		if (request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ,
+				"Fastlane SCSI", esp_intr)) {
+			printk(KERN_WARNING "Fastlane: Could not get IRQ%d, aborting.\n", esp_intr);
+			goto err_unmap;
+		}			
 
 		/* Controller ID */
 		esp->scsi_id = 7;
@@ -188,6 +186,15 @@
 		return esps_in_use;
 	    }
 	}
+	return 0;
+
+ err_unmap:
+	iounmap(board, z->resource.end-board+1);
+ err_unregister:
+	scsi_unregister (esp->ehost);
+ err_release:
+	release_mem_region(board+FASTLANE_ESP_ADDR,
+			   sizeof(struct ESP_regs));
 	return 0;
 }
 
Signature · 9 lines
Regards,
        Rasmus([email protected])

"No man is genuinely happy, married, who has to drink worse whiskey than he
used to drink when he was single." H.L. Mencken
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#1 lore raw

On Tue, Jan 23, 2001 at 12:37:18AM +0100, Rasmus Andersen wrote:

Hi.

This is an updated patch since I messed the one from yesterday up. The comments still apply, though. Apologies for the extra mails.

drivers/scsi/fastlane.c +16 -9
@@ -96,9 +96,7 @@
 		 * this ID value. Fortunately only Fastlane maps in Z3 space
 		 */
 		if (board < 0x1000000) {
-			release_mem_region(board+FASTLANE_ESP_ADDR,
-					   sizeof(struct ESP_regs));
-			return 0;
+			goto err_release;
 		}
 		esp = esp_allocate(tpnt, (void *)board+FASTLANE_ESP_ADDR);
 
@@ -146,10 +144,7 @@
 
 		if(!address){
 			printk("Could not remap Fastlane controller memory!");
-			scsi_unregister (esp->ehost);
-			release_mem_region(board+FASTLANE_ESP_ADDR,
-					   sizeof(struct ESP_regs));
-			return 0;
+			goto err_unregister;
 		}
 
 
@@ -171,8 +166,11 @@
 
 		esp->irq = IRQ_AMIGA_PORTS;
 		esp->slot = board+FASTLANE_ESP_ADDR;
-		request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ,
-			    "Fastlane SCSI", esp_intr);
+		if (request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ,
+				"Fastlane SCSI", esp_intr)) {
+			printk(KERN_WARNING "Fastlane: Could not get IRQ%d, aborting.\n", IRQ_AMIGA_PORTS);
+			goto err_unmap;
+		}			
 
 		/* Controller ID */
 		esp->scsi_id = 7;
@@ -188,6 +186,15 @@
 		return esps_in_use;
 	    }
 	}
+	return 0;
+
+ err_unmap:
+	iounmap((void *)address);
+ err_unregister:
+	scsi_unregister (esp->ehost);
+ err_release:
+	release_mem_region(z->resource.start+FASTLANE_ESP_ADDR,
+			   sizeof(struct ESP_regs));
 	return 0;
 }
 
Signature · 9 lines
Regards,
        Rasmus([email protected])

"God prevent we should ever be twenty years without a revolution." 
  -- Thomas Jefferson
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/