Subject: [PATCH] make drivers/scsi/dec_esp.c check request_irq return code (240p3) (fwd)

From: Geert Uytterhoeven <[email-masked]>
Date: Fri, 19 Jan 2001 09:31:54 +0100 (CET)

---------- Forwarded message ----------
Date: Wed, 17 Jan 2001 23:18:52 +0100
From: Rasmus Andersen <[email-masked]>
To: [email-masked]
Subject: [PATCH] make drivers/scsi/dec_esp.c check request_irq return code
    (240p3)

Hi.

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

This patch makes drivers/scsi/dec_esp.c check the return code of
request_irq. It applies cleanly against 240p3 and ac9.

In the search_tc_slot loop I made it continue the search on failure
for one slot. Would this be correct?

Please comment.

--- linux-ac9/drivers/scsi/dec_esp.c.org	Sun Jan 14 20:03:50 2001
+++ linux-ac9/drivers/scsi/dec_esp.c	Wed Jan 17 22:52:52 2001
@@ -87,7 +87,7 @@
 unsigned char scsi_pmaz_dma_buff_used[ESP_NCMD];
 unsigned char scsi_cur_buff = 1;	/* Leave space for command buffer */
 __u32 esp_virt_buffer;
-int scsi_current_length = 0;
+int scsi_current_length;
 
 volatile unsigned char cmd_buffer[16];
 volatile unsigned char pmaz_cmd_buffer[16];
@@ -181,10 +181,13 @@
 		esp->esp_command_dvma = (__u32) KSEG1ADDR((volatile unsigned char *) cmd_buffer);
 	
 		esp->irq = SCSI_INT;
-	request_irq(esp->irq, esp_intr, SA_INTERRUPT, "NCR 53C94 SCSI",
-	            NULL);
-		request_irq(SCSI_DMA_INT, scsi_dma_int, SA_INTERRUPT, "JUNKIO SCSI DMA",
-			    NULL);
+		if (request_irq(esp->irq, esp_intr, SA_INTERRUPT, 
+				"NCR 53C94 SCSI", NULL))
+			goto err_dealloc;
+		if (request_irq(SCSI_DMA_INT, scsi_dma_int, SA_INTERRUPT, 
+				"JUNKIO SCSI DMA", NULL))
+			goto err_free_irq;
+			
 
 	esp->scsi_id = 7;
 		
@@ -257,7 +260,12 @@
 			esp->dma_mmu_release_scsi_sgl = 0;
 			esp->dma_advance_sg = 0;
 
-			request_irq(esp->irq, esp_intr, SA_INTERRUPT, "PMAZ_AA", NULL);
+			if (request_irq(esp->irq, esp_intr, SA_INTERRUPT, 
+					 "PMAZ_AA", NULL)) {
+				esp_deallocate(esp);
+				release_tc_card(slot);
+				continue;
+			}
 			esp->scsi_id = 7;
 			esp->diff = 0;
 			esp_initialize(esp);
@@ -267,10 +275,16 @@
 
 	if(nesps) {
 		printk("ESP: Total of %d ESP hosts found, %d actually in use.\n", nesps, esps_in_use);
-	esps_running = esps_in_use;
-	return esps_in_use;
-	} else
-    return 0;
+		esps_running = esps_in_use;
+		return esps_in_use;
+	}
+	return 0;
+
+ err_free_irq:
+	free_irq(esp->irq, esp_intr);
+ err_dealloc:
+	esp_deallocate(esp);
+	return 0;
 }
 
 /************************************************************* DMA Functions */
@@ -524,4 +538,4 @@
 	    (char *) KSEG0ADDR((sp->request_buffer));
 }
 
-#endif
\ No newline at end of file
+#endif

-- 
Regards,
        Rasmus([email-masked])

``When the president does it, that means that it is not illegal.''
             --Richard M. Nixon, TV interview with David Frost, 1977 May 4
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email-masked]
Please read the FAQ at http://www.tux.org/lkml/

---

From: "Houten K.H.C. van (Karel)" <[email-masked]>
Date: Fri, 19 Jan 2001 09:40:44 +0100

Hi all,

> for one slot. Would this be correct?

Would this be the cause of the problem I have in my 5000/260
that I can only use the on-board SCSI interface, and not
the TC scsi card (which should use the same driver)?

I hope to be able to test this patch this weekend!

Regards,
Karel.
-- 
Karel van Houten

----------------------------------------------------------
The box said "Requires Windows 95 or better."
I can't understand why it won't work on my Linux computer. 
----------------------------------------------------------

---

From: Florian Lohoff <[email-masked]>
Date: Fri, 19 Jan 2001 11:58:05 +0100

> I hope to be able to test this patch this weekend!

I dont think so - The addtional cards have been broken since early
2.4.0 and i tried once to fix it and clean up the spaghetti stuff
but i think i failed horribly and made it worse in the cvs.

I'll have a look at it soon(tm).

Flo
-- 
Florian Lohoff                  [email-masked]             +49-5201-669912
     Why is it called "common sense" when nobody seems to have any?

---

From: Florian Lohoff <[email-masked]>
Date: Fri, 19 Jan 2001 12:46:19 +0100

> I'll have a look at it soon(tm).

Sorry - Meant early 2.3. 

Flo

---

From: Rasmus Andersen <[email-masked]>
Date: Fri, 19 Jan 2001 21:03:13 +0100

> the TC scsi card (which should use the same driver)?

As Florian Lohoff commented I doubt this patch will be of any
help for you. My comment wrt. continuing in the tc loop was
merely in case of a request_irq failure, a failure ignored
earlier. So I would guess that this patch is not your
problemkiller. But testing is always nice :)

-- 
Regards,
        Rasmus([email-masked])

There are two major products that come out of Berkeley: LSD and UNIX. We 
don't believe this to be a coincidence. -- Jeremy S. Anderson