make drivers/scsi/atari_scsi.c check request_irq (240p3)
Subsystems (2)
PATCH 1/1 make drivers/scsi/atari_scsi.c check request_irq (240p3)
Hi.
The following patch makes drivers/scsi/atari_scsi.c check request_irq's return code. It applies cleanly against 240p3 and ac9.
Comments?
drivers/scsi/atari_scsi.c renamed from drivers/scsi/atari_scsi.c~ +17 -10
@@ -690,19 +690,27 @@/* This int is actually "pseudo-slow", i.e. it acts like a slow * interrupt after having cleared the pending flag for the DMA * interrupt. */ -request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , -"SCSI NCR5380" , scsi_tt_intr); +if (!request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , +"SCSI NCR5380" , scsi_tt_intr)) { +printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting" ,IRQ_TT_MFP_SCSI ); +atari_stram_free (atari_dma_buffer); + atari_dma_buffer =0 ; +return 0 ; + } tt_mfp.active_edge |=0x80 ;/* SCSI int on L->H */ #ifdef REAL_DMA tt_scsi_dma.dma_ctrl =0 ; atari_dma_residual =0 ; -#endif /* REAL_DMA */ -#ifdef REAL_DMA #ifdef CONFIG_TT_DMA_EMUL if (MACH_IS_HADES ) { -request_irq (IRQ_AUTO_2 , hades_dma_emulator, -IRQ_TYPE_PRIO ,"Hades DMA emulator" , - hades_dma_emulator); +if (!request_irq (IRQ_AUTO_2 , hades_dma_emulator, +IRQ_TYPE_PRIO ,"Hades DMA emulator" , + hades_dma_emulator)) { +printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting (MACH_IS_HADES)" ,IRQ_AUTO_2 ); +atari_stram_free (atari_dma_buffer); + atari_dma_buffer =0 ; +return 0 ; + } }#endif if (MACH_IS_MEDUSA ||MACH_IS_HADES ) {
@@ -719,9 +727,8 @@* the rest data bug is fixed, this can be lowered to 1. */ atari_read_overruns = 4; - } -#endif - + } +#endif /*REAL_DMA*/ }else {/* ! IS_A_TT */
Signature · 10 lines
Rasmus([email protected]) Are they taking DDT? -- Vice President Dan Quayle asking doctors at a Manhattan AIDS clinic about their treatments of choice, 4/30/92 (reported in Esquire, 8/92, and NY Post early May 92) - 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/
Hi again and sorry for the noise.
Hans Grobler kindly pointed me towards scsi_unregister which I heppily had ignored. The following patch includes this function in the exit paths. Otherwise it is identical to the earlier one.
drivers/scsi/atari_scsi.c renamed from drivers/scsi/atari_scsi.c.org +19 -10
@@ -690,19 +690,29 @@/* This int is actually "pseudo-slow", i.e. it acts like a slow * interrupt after having cleared the pending flag for the DMA * interrupt. */ -request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , -"SCSI NCR5380" , scsi_tt_intr); +if (!request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , +"SCSI NCR5380" , scsi_tt_intr)) { +printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting" ,IRQ_TT_MFP_SCSI ); +scsi_unregister (atari_scsi_host); +atari_stram_free (atari_dma_buffer); + atari_dma_buffer =0 ; +return 0 ; + } tt_mfp.active_edge |=0x80 ;/* SCSI int on L->H */ #ifdef REAL_DMA tt_scsi_dma.dma_ctrl =0 ; atari_dma_residual =0 ; -#endif /* REAL_DMA */ -#ifdef REAL_DMA #ifdef CONFIG_TT_DMA_EMUL if (MACH_IS_HADES ) { -request_irq (IRQ_AUTO_2 , hades_dma_emulator, -IRQ_TYPE_PRIO ,"Hades DMA emulator" , - hades_dma_emulator); +if (!request_irq (IRQ_AUTO_2 , hades_dma_emulator, +IRQ_TYPE_PRIO ,"Hades DMA emulator" , + hades_dma_emulator)) { +printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting (MACH_IS_HADES)" ,IRQ_AUTO_2 ); +scsi_unregister (atari_scsi_host); +atari_stram_free (atari_dma_buffer); + atari_dma_buffer =0 ; +return 0 ; + } }#endif if (MACH_IS_MEDUSA ||MACH_IS_HADES ) {
@@ -719,9 +729,8 @@* the rest data bug is fixed, this can be lowered to 1. */ atari_read_overruns = 4; - } -#endif - + } +#endif /*REAL_DMA*/ }else {/* ! IS_A_TT */
Signature · 9 lines
Regards,
Rasmus([email protected])
Without censorship, things can get terribly confused in the
public mind. -General William Westmoreland, during the war in Viet Nam
-
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/Quoted 13 lines · Rasmus Andersen
Hi.
The following patch makes
drivers/scsi/atari_scsi.ccheck request_irq's return code. It applies cleanly against 240p3 and ac9.Comments?
drivers/scsi/atari_scsi.c Sun Jan 14 19:28:00 2001 renamed from drivers/scsi/atari_scsi.c~ Tue Nov 28 02:57:34 2000 +0
-0@@ -690,19 +690,27 @@ /* This int is actually "pseudo-slow", i.e. it acts like a slow * interrupt after having cleared the pending flag for the DMA
drivers/scsi/atari_scsi.c Sun Jan 14 19:28:00 2001 line 699
Quoted 10 lines
drivers/scsi/atari_scsi.c Sun Jan 14 19:28:00 2001 renamed from drivers/scsi/atari_scsi.c~ Tue Nov 28 02:57:34 2000 +7
-2* interrupt. */ - request_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr, IRQ_TYPE_SLOW, - "SCSI NCR5380", scsi_tt_intr); + if (!request_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr, IRQ_TYPE_SLOW, + "SCSI NCR5380", scsi_tt_intr)) { + printk(KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting",IRQ_TT_MFP_SCSI); + atari_stram_free(atari_dma_buffer); + atari_dma_buffer = 0; + return 0; + }
request_irq returns zero on success, not on failure. Further, you need to return the request_irq error value back to the caller, if possible.
Jeff
Signature · 7 lines
Jeff Garzik | "You see, in this world there's two kinds of Building 1024 | people, my friend: Those with loaded guns MandrakeSoft | and those who dig. You dig." --Blondie - 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/
Quoted 2 lines · Jeff Garzik
request_irqreturns zero on success, not on failure. Further, you need to return therequest_irqerror value back to the caller, if possible.
<choke><blush>
My, that was embarassing. I'll change this as soon as I trust myself with a keyboard again :)
Thank you for the catch.
Signature · 12 lines
Regards,
Rasmus([email protected])
"If you aim the gun at your foot and pull the trigger, it's UNIX's job to
ensure reliable delivery of the bullet to where you aimed the gun (in
this case, Mr. Foot)." -- Terry Lambert, FreeBSD-Hackers mailing list.
PS: Welcome back. I hope your wrists have got all the rest they needed.
-
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/Hi again.
The following patch should correct the request_irq mistake. (The zero return on failure seems to be required by scsi/scsi.c and is what everybody else does.)
Other comments? :)
drivers/scsi/atari_scsi.c renamed from drivers/scsi/atari_scsi.c.org +20 -10
@@ -690,19 +690,30 @@/* This int is actually "pseudo-slow", i.e. it acts like a slow * interrupt after having cleared the pending flag for the DMA * interrupt. */ -request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , -"SCSI NCR5380" , scsi_tt_intr); +if (request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , +"SCSI NCR5380" , scsi_tt_intr)) { +printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting" ,IRQ_TT_MFP_SCSI ); +scsi_unregister (atari_scsi_host); +atari_stram_free (atari_dma_buffer); + atari_dma_buffer =0 ; +return 0 ; + } tt_mfp.active_edge |=0x80 ;/* SCSI int on L->H */ #ifdef REAL_DMA tt_scsi_dma.dma_ctrl =0 ; atari_dma_residual =0 ; -#endif /* REAL_DMA */ -#ifdef REAL_DMA #ifdef CONFIG_TT_DMA_EMUL if (MACH_IS_HADES ) { -request_irq (IRQ_AUTO_2 , hades_dma_emulator, -IRQ_TYPE_PRIO ,"Hades DMA emulator" , - hades_dma_emulator); +if (request_irq (IRQ_AUTO_2 , hades_dma_emulator, +IRQ_TYPE_PRIO ,"Hades DMA emulator" , + hades_dma_emulator)) { +printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting (MACH_IS_HADES)" ,IRQ_AUTO_2 ); +free_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr); +scsi_unregister (atari_scsi_host); +atari_stram_free (atari_dma_buffer); + atari_dma_buffer =0 ; +return 0 ; + } }#endif if (MACH_IS_MEDUSA ||MACH_IS_HADES ) {
@@ -719,9 +730,8 @@* the rest data bug is fixed, this can be lowered to 1. */ atari_read_overruns = 4; - } -#endif - + } +#endif /*REAL_DMA*/ }else {/* ! IS_A_TT */
Signature · 9 lines
Regards,
Rasmus([email protected])
After all, it is only the mediocre who are always at their best.
-- Jean Giraudoux
-
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/