diff options
Diffstat (limited to 'drivers/scsi/sun3_NCR5380.c')
| -rw-r--r-- | drivers/scsi/sun3_NCR5380.c | 480 | 
1 files changed, 200 insertions, 280 deletions
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 713620ed70d..88220794cc9 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -49,13 +49,6 @@   *    inside the execution of NCR5380_intr(), leading to recursive   *    calls.   * - *  - I've added a function merge_contiguous_buffers() that tries to - *    merge scatter-gather buffers that are located at contiguous - *    physical addresses and can be processed with the same DMA setup. - *    Since most scatter-gather operations work on a page (4K) of - *    4 buffers (1K), in more than 90% of all cases three interrupts and - *    DMA setup actions are saved. - *   * - I've deleted all the stuff for AUTOPROBE_IRQ, REAL_DMA_POLL, PSEUDO_DMA   *    and USLEEP, because these were messing up readability and will never be   *    needed for Atari SCSI. @@ -266,8 +259,9 @@ static struct scsi_host_template *the_template = NULL;  	(struct NCR5380_hostdata *)(in)->hostdata  #define	HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) -#define	NEXT(cmd)	(*(struct scsi_cmnd **)&((cmd)->host_scribble)) -#define	NEXTADDR(cmd)	((struct scsi_cmnd **)&((cmd)->host_scribble)) +#define	NEXT(cmd)		((struct scsi_cmnd *)(cmd)->host_scribble) +#define	SET_NEXT(cmd, next)	((cmd)->host_scribble = (void *)(next)) +#define	NEXTADDR(cmd)		((struct scsi_cmnd **)&((cmd)->host_scribble))  #define	HOSTNO		instance->host_no  #define	H_NO(cmd)	(cmd)->device->host->host_no @@ -370,7 +364,7 @@ static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)  	return( 0 );      if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >=  	TagAlloc[cmd->device->id][cmd->device->lun].queue_size ) { -	TAG_PRINTK( "scsi%d: target %d lun %d: no free tags\n", +	dprintk(NDEBUG_TAGS,  "scsi%d: target %d lun %d: no free tags\n",  		    H_NO(cmd), cmd->device->id, cmd->device->lun );  	return( 1 );      } @@ -394,7 +388,7 @@ static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)  	!setup_use_tagged_queuing || !cmd->device->tagged_supported) {  	cmd->tag = TAG_NONE;  	hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); -	TAG_PRINTK( "scsi%d: target %d lun %d now allocated by untagged " +	dprintk(NDEBUG_TAGS,  "scsi%d: target %d lun %d now allocated by untagged "  		    "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun );      }      else { @@ -403,7 +397,7 @@ static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)  	cmd->tag = find_first_zero_bit( &ta->allocated, MAX_TAGS );  	set_bit( cmd->tag, &ta->allocated );  	ta->nr_allocated++; -	TAG_PRINTK( "scsi%d: using tag %d for target %d lun %d " +	dprintk(NDEBUG_TAGS,  "scsi%d: using tag %d for target %d lun %d "  		    "(now %d tags in use)\n",  		    H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun,  		    ta->nr_allocated ); @@ -421,7 +415,7 @@ static void cmd_free_tag(struct scsi_cmnd *cmd)      if (cmd->tag == TAG_NONE) {  	hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); -	TAG_PRINTK( "scsi%d: target %d lun %d untagged cmd finished\n", +	dprintk(NDEBUG_TAGS,  "scsi%d: target %d lun %d untagged cmd finished\n",  		    H_NO(cmd), cmd->device->id, cmd->device->lun );      }      else if (cmd->tag >= MAX_TAGS) { @@ -432,7 +426,7 @@ static void cmd_free_tag(struct scsi_cmnd *cmd)  	TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];  	clear_bit( cmd->tag, &ta->allocated );  	ta->nr_allocated--; -	TAG_PRINTK( "scsi%d: freed tag %d for target %d lun %d\n", +	dprintk(NDEBUG_TAGS,  "scsi%d: freed tag %d for target %d lun %d\n",  		    H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun );      }  } @@ -459,47 +453,6 @@ static void free_all_tags( void )  /* - * Function: void merge_contiguous_buffers(struct scsi_cmnd *cmd) - * - * Purpose: Try to merge several scatter-gather requests into one DMA - *    transfer. This is possible if the scatter buffers lie on - *    physical contiguous addresses. - * - * Parameters: struct scsi_cmnd *cmd - *    The command to work on. The first scatter buffer's data are - *    assumed to be already transfered into ptr/this_residual. - */ - -static void merge_contiguous_buffers(struct scsi_cmnd *cmd) -{ -    unsigned long endaddr; -#if (NDEBUG & NDEBUG_MERGING) -    unsigned long oldlen = cmd->SCp.this_residual; -    int		  cnt = 1; -#endif - -    for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; -	 cmd->SCp.buffers_residual && -	 virt_to_phys(SGADDR(&(cmd->SCp.buffer[1]))) == endaddr; ) { -	 -	MER_PRINTK("VTOP(%p) == %08lx -> merging\n", -		   SGADDR(&(cmd->SCp.buffer[1])), endaddr); -#if (NDEBUG & NDEBUG_MERGING) -	++cnt; -#endif -	++cmd->SCp.buffer; -	--cmd->SCp.buffers_residual; -	cmd->SCp.this_residual += cmd->SCp.buffer->length; -	endaddr += cmd->SCp.buffer->length; -    } -#if (NDEBUG & NDEBUG_MERGING) -    if (oldlen != cmd->SCp.this_residual) -	MER_PRINTK("merged %d buffers from %p, new length %08x\n", -		   cnt, cmd->SCp.ptr, cmd->SCp.this_residual); -#endif -} - -/*   * Function : void initialize_SCp(struct scsi_cmnd *cmd)   *   * Purpose : initialize the saved data pointers for cmd to point to the  @@ -520,11 +473,6 @@ static __inline__ void initialize_SCp(struct scsi_cmnd *cmd)  	cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;  	cmd->SCp.ptr = (char *) SGADDR(cmd->SCp.buffer);  	cmd->SCp.this_residual = cmd->SCp.buffer->length; - -	/* ++roman: Try to merge some scatter-buffers if they are at -	 * contiguous physical addresses. -	 */ -//	merge_contiguous_buffers( cmd );      } else {  	cmd->SCp.buffer = NULL;  	cmd->SCp.buffers_residual = 0; @@ -536,7 +484,7 @@ static __inline__ void initialize_SCp(struct scsi_cmnd *cmd)  #include <linux/delay.h> -#if 1 +#if NDEBUG  static struct {      unsigned char mask;      const char * name;}  @@ -624,12 +572,6 @@ static void NCR5380_print_phase(struct Scsi_Host *instance)      }  } -#else /* !NDEBUG */ - -/* dummies... */ -__inline__ void NCR5380_print(struct Scsi_Host *instance) { }; -__inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { }; -  #endif  /* @@ -670,7 +612,7 @@ static inline void NCR5380_all_init (void)  {      static int done = 0;      if (!done) { -	INI_PRINTK("scsi : NCR5380_all_init()\n"); +	dprintk(NDEBUG_INIT, "scsi : NCR5380_all_init()\n");  	done = 1;      }  } @@ -713,121 +655,94 @@ static void __init NCR5380_print_options (struct Scsi_Host *instance)   * Inputs : instance, pointer to this instance.     */ -static void NCR5380_print_status (struct Scsi_Host *instance) +static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd)  { -    char *pr_bfr; -    char *start; -    int len; - -    NCR_PRINT(NDEBUG_ANY); -    NCR_PRINT_PHASE(NDEBUG_ANY); - -    pr_bfr = (char *) __get_free_page(GFP_ATOMIC); -    if (!pr_bfr) { -	printk("NCR5380_print_status: no memory for print buffer\n"); -	return; -    } -    len = NCR5380_proc_info(instance, pr_bfr, &start, 0, PAGE_SIZE, 0); -    pr_bfr[len] = 0; -    printk("\n%s\n", pr_bfr); -    free_page((unsigned long) pr_bfr); +	int i, s; +	unsigned char *command; +	printk("scsi%d: destination target %d, lun %d\n", +		H_NO(cmd), cmd->device->id, cmd->device->lun); +	printk(KERN_CONT "        command = "); +	command = cmd->cmnd; +	printk(KERN_CONT "%2d (0x%02x)", command[0], command[0]); +	for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) +		printk(KERN_CONT " %02x", command[i]); +	printk("\n");  } - -/******************************************/ -/* - * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED] - * - * *buffer: I/O buffer - * **start: if inout == FALSE pointer into buffer where user read should start - * offset: current offset - * length: length of buffer - * hostno: Scsi_Host host_no - * inout: TRUE - user is writing; FALSE - user is reading - * - * Return the number of bytes read from or written -*/ - -#undef SPRINTF -#define SPRINTF(fmt,args...) \ -  do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ -	 pos += sprintf(pos, fmt , ## args); } while(0) -static -char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer, -		       int length); - -static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer, -			     char **start, off_t offset, int length, int inout) +static void NCR5380_print_status(struct Scsi_Host *instance)  { -    char *pos = buffer; -    struct NCR5380_hostdata *hostdata; -    struct scsi_cmnd *ptr; -    unsigned long flags; -    off_t begin = 0; -#define check_offset()				\ -    do {					\ -	if (pos - buffer < offset - begin) {	\ -	    begin += pos - buffer;		\ -	    pos = buffer;			\ -	}					\ -    } while (0) - -    hostdata = (struct NCR5380_hostdata *)instance->hostdata; - -    if (inout) { /* Has data been written to the file ? */ -	return(-ENOSYS);  /* Currently this is a no-op */ -    } -    SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); -    check_offset(); -    local_irq_save(flags); -    SPRINTF("NCR5380: coroutine is%s running.\n", main_running ? "" : "n't"); -    check_offset(); -    if (!hostdata->connected) -	SPRINTF("scsi%d: no currently connected command\n", HOSTNO); -    else -	pos = lprint_Scsi_Cmnd ((struct scsi_cmnd *) hostdata->connected, -				pos, buffer, length); -    SPRINTF("scsi%d: issue_queue\n", HOSTNO); -    check_offset(); -    for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) -    { -	pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); -	check_offset(); -    } - -    SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); -    check_offset(); -    for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; -	 ptr = NEXT(ptr)) { -	pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); -	check_offset(); -    } +	struct NCR5380_hostdata *hostdata; +	Scsi_Cmnd *ptr; +	unsigned long flags; + +	NCR5380_dprint(NDEBUG_ANY, instance); +	NCR5380_dprint_phase(NDEBUG_ANY, instance); + +	hostdata = (struct NCR5380_hostdata *)instance->hostdata; + +	printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); +	local_irq_save(flags); +	printk("NCR5380: coroutine is%s running.\n", +		main_running ? "" : "n't"); +	if (!hostdata->connected) +		printk("scsi%d: no currently connected command\n", HOSTNO); +	else +		lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected); +	printk("scsi%d: issue_queue\n", HOSTNO); +	for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) +		lprint_Scsi_Cmnd(ptr); + +	printk("scsi%d: disconnected_queue\n", HOSTNO); +	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; +	     ptr = NEXT(ptr)) +		lprint_Scsi_Cmnd(ptr); -    local_irq_restore(flags); -    *start = buffer + (offset - begin); -    if (pos - buffer < offset - begin) -	return 0; -    else if (pos - buffer - (offset - begin) < length) -	return pos - buffer - (offset - begin); -    return length; +	local_irq_restore(flags); +	printk("\n");  } -static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer, -			      int length) +static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m)  { -    int i, s; -    unsigned char *command; -    SPRINTF("scsi%d: destination target %d, lun %d\n", -	    H_NO(cmd), cmd->device->id, cmd->device->lun); -    SPRINTF("        command = "); -    command = cmd->cmnd; -    SPRINTF("%2d (0x%02x)", command[0], command[0]); -    for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) -	SPRINTF(" %02x", command[i]); -    SPRINTF("\n"); -    return pos; +	int i, s; +	unsigned char *command; +	seq_printf(m, "scsi%d: destination target %d, lun %d\n", +		H_NO(cmd), cmd->device->id, cmd->device->lun); +	seq_printf(m, "        command = "); +	command = cmd->cmnd; +	seq_printf(m, "%2d (0x%02x)", command[0], command[0]); +	for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) +		seq_printf(m, " %02x", command[i]); +	seq_printf(m, "\n");  } +static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) +{ +	struct NCR5380_hostdata *hostdata; +	Scsi_Cmnd *ptr; +	unsigned long flags; + +	hostdata = (struct NCR5380_hostdata *)instance->hostdata; + +	seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); +	local_irq_save(flags); +	seq_printf(m, "NCR5380: coroutine is%s running.\n", +		main_running ? "" : "n't"); +	if (!hostdata->connected) +		seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); +	else +		show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); +	seq_printf(m, "scsi%d: issue_queue\n", HOSTNO); +	for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) +		show_Scsi_Cmnd(ptr, m); + +	seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO); +	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; +	     ptr = NEXT(ptr)) +		show_Scsi_Cmnd(ptr, m); + +	local_irq_restore(flags); +	return 0; +}  /*    * Function : void NCR5380_init (struct Scsi_Host *instance) @@ -841,7 +756,7 @@ static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,   *    */ -static int NCR5380_init (struct Scsi_Host *instance, int flags) +static int __init NCR5380_init(struct Scsi_Host *instance, int flags)  {      int i;      SETUP_HOSTDATA(instance); @@ -889,6 +804,11 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)      return 0;  } +static void NCR5380_exit(struct Scsi_Host *instance) +{ +	/* Empty, as we didn't schedule any delayed work */ +} +  /*    * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd,   *	void (*done)(struct scsi_cmnd *)) @@ -908,7 +828,7 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)   */  /* Only make static if a wrapper function is used */ -static int NCR5380_queue_command(struct scsi_cmnd *cmd, +static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd,  				 void (*done)(struct scsi_cmnd *))  {      SETUP_HOSTDATA(cmd->device->host); @@ -962,7 +882,7 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,       * in a queue        */ -    NEXT(cmd) = NULL; +    SET_NEXT(cmd, NULL);      cmd->scsi_done = done;      cmd->result = 0; @@ -990,19 +910,19 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,       */      if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {  	LIST(cmd, hostdata->issue_queue); -	NEXT(cmd) = hostdata->issue_queue; +	SET_NEXT(cmd, hostdata->issue_queue);  	hostdata->issue_queue = cmd;      } else {  	for (tmp = (struct scsi_cmnd *)hostdata->issue_queue;  	     NEXT(tmp); tmp = NEXT(tmp))  	    ;  	LIST(cmd, tmp); -	NEXT(tmp) = cmd; +	SET_NEXT(tmp, cmd);      }      local_irq_restore(flags); -    QU_PRINTK("scsi%d: command added to %s of queue\n", H_NO(cmd), +    dprintk(NDEBUG_QUEUES, "scsi%d: command added to %s of queue\n", H_NO(cmd),  	      (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail");      /* If queue_command() is called from an interrupt (real one or bottom @@ -1019,6 +939,8 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,      return 0;  } +static DEF_SCSI_QCMD(NCR5380_queue_command) +  /*   * Function : NCR5380_main (void)    * @@ -1070,7 +992,7 @@ static void NCR5380_main (struct work_struct *bl)  	done = 1;  	if (!hostdata->connected) { -	    MAIN_PRINTK( "scsi%d: not connected\n", HOSTNO ); +	    dprintk(NDEBUG_MAIN,  "scsi%d: not connected\n", HOSTNO );  	    /*  	     * Search through the issue_queue for a command destined  	     * for a target that's not busy. @@ -1084,12 +1006,8 @@ static void NCR5380_main (struct work_struct *bl)  	    for (tmp = (struct scsi_cmnd *) hostdata->issue_queue,  		 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { -#if (NDEBUG & NDEBUG_LISTS)  		if (prev != tmp) -		    printk("MAIN tmp=%p   target=%d   busy=%d lun=%d\n", -			   tmp, tmp->target, hostdata->busy[tmp->target], -			   tmp->lun); -#endif +			dprintk(NDEBUG_LISTS, "MAIN tmp=%p   target=%d   busy=%d lun=%d\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], tmp->device->lun);  		/*  When we find one, remove it from the issue queue. */  		/* ++guenther: possible race with Falcon locking */  		if ( @@ -1103,12 +1021,12 @@ static void NCR5380_main (struct work_struct *bl)  		    local_irq_disable();  		    if (prev) {  		        REMOVE(prev, NEXT(prev), tmp, NEXT(tmp)); -			NEXT(prev) = NEXT(tmp); +			SET_NEXT(prev, NEXT(tmp));  		    } else {  		        REMOVE(-1, hostdata->issue_queue, tmp, NEXT(tmp));  			hostdata->issue_queue = NEXT(tmp);  		    } -		    NEXT(tmp) = NULL; +		    SET_NEXT(tmp, NULL);  		    /* reenable interrupts after finding one */  		    local_irq_restore(flags); @@ -1119,9 +1037,9 @@ static void NCR5380_main (struct work_struct *bl)  		     * On failure, we must add the command back to the  		     *   issue queue so we can keep trying.	  		     */ -		    MAIN_PRINTK("scsi%d: main(): command for target %d " +		    dprintk(NDEBUG_MAIN, "scsi%d: main(): command for target %d "  				"lun %d removed from issue_queue\n", -				HOSTNO, tmp->target, tmp->lun); +				HOSTNO, tmp->device->id, tmp->device->lun);  		    /*   		     * REQUEST SENSE commands are issued without tagged  		     * queueing, even on SCSI-II devices because the  @@ -1142,13 +1060,13 @@ static void NCR5380_main (struct work_struct *bl)  		    } else {  			local_irq_disable();  			LIST(tmp, hostdata->issue_queue); -			NEXT(tmp) = hostdata->issue_queue; +			SET_NEXT(tmp, hostdata->issue_queue);  			hostdata->issue_queue = tmp;  #ifdef SUPPORT_TAGS  			cmd_free_tag( tmp );  #endif  			local_irq_restore(flags); -			MAIN_PRINTK("scsi%d: main(): select() failed, " +			dprintk(NDEBUG_MAIN, "scsi%d: main(): select() failed, "  				    "returned to issue_queue\n", HOSTNO);  			if (hostdata->connected)  			    break; @@ -1162,10 +1080,10 @@ static void NCR5380_main (struct work_struct *bl)  #endif  	    ) {  	    local_irq_restore(flags); -	    MAIN_PRINTK("scsi%d: main: performing information transfer\n", +	    dprintk(NDEBUG_MAIN, "scsi%d: main: performing information transfer\n",  			HOSTNO);  	    NCR5380_information_transfer(instance); -	    MAIN_PRINTK("scsi%d: main: done set false\n", HOSTNO); +	    dprintk(NDEBUG_MAIN, "scsi%d: main: done set false\n", HOSTNO);  	    done = 0;  	}      } while (!done); @@ -1202,7 +1120,7 @@ static void NCR5380_dma_complete( struct Scsi_Host *instance )  	return;      } -    DMA_PRINTK("scsi%d: real DMA transfer complete, basr 0x%X, sr 0x%X\n", +    dprintk(NDEBUG_DMA, "scsi%d: real DMA transfer complete, basr 0x%X, sr 0x%X\n",  	       HOSTNO, NCR5380_read(BUS_AND_STATUS_REG),  	       NCR5380_read(STATUS_REG)); @@ -1261,27 +1179,27 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)      int done = 1, handled = 0;      unsigned char basr; -    INT_PRINTK("scsi%d: NCR5380 irq triggered\n", HOSTNO); +    dprintk(NDEBUG_INTR, "scsi%d: NCR5380 irq triggered\n", HOSTNO);      /* Look for pending interrupts */      basr = NCR5380_read(BUS_AND_STATUS_REG); -    INT_PRINTK("scsi%d: BASR=%02x\n", HOSTNO, basr); +    dprintk(NDEBUG_INTR, "scsi%d: BASR=%02x\n", HOSTNO, basr);      /* dispatch to appropriate routine if found and done=0 */      if (basr & BASR_IRQ) { -	NCR_PRINT(NDEBUG_INTR); +	NCR5380_dprint(NDEBUG_INTR, instance);  	if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) {  	    done = 0;  //	    ENABLE_IRQ(); -	    INT_PRINTK("scsi%d: SEL interrupt\n", HOSTNO); +	    dprintk(NDEBUG_INTR, "scsi%d: SEL interrupt\n", HOSTNO);  	    NCR5380_reselect(instance);  	    (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);  	}  	else if (basr & BASR_PARITY_ERROR) { -	    INT_PRINTK("scsi%d: PARITY interrupt\n", HOSTNO); +	    dprintk(NDEBUG_INTR, "scsi%d: PARITY interrupt\n", HOSTNO);  	    (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);  	}  	else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) { -	    INT_PRINTK("scsi%d: RESET interrupt\n", HOSTNO); +	    dprintk(NDEBUG_INTR, "scsi%d: RESET interrupt\n", HOSTNO);  	    (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);  	}  	else { @@ -1301,7 +1219,7 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)  		((basr & BASR_END_DMA_TRANSFER) ||   		 !(basr & BASR_PHASE_MATCH))) { -		INT_PRINTK("scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO); +		dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO);  		NCR5380_dma_complete( instance );  		done = 0;  //		ENABLE_IRQ(); @@ -1310,7 +1228,7 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)  	    {  /* MS: Ignore unknown phase mismatch interrupts (caused by EOP interrupt) */  		if (basr & BASR_PHASE_MATCH) -		   INT_PRINTK("scsi%d: unknown interrupt, " +		   dprintk(NDEBUG_INTR, "scsi%d: unknown interrupt, "  			   "BASR 0x%x, MR 0x%x, SR 0x%x\n",  			   HOSTNO, basr, NCR5380_read(MODE_REG),  			   NCR5380_read(STATUS_REG)); @@ -1334,7 +1252,7 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)      }      if (!done) { -	INT_PRINTK("scsi%d: in int routine, calling main\n", HOSTNO); +	dprintk(NDEBUG_INTR, "scsi%d: in int routine, calling main\n", HOSTNO);  	/* Put a call to NCR5380_main() on the queue... */  	queue_main();      } @@ -1410,8 +1328,8 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,      unsigned long flags;      hostdata->restart_select = 0; -    NCR_PRINT(NDEBUG_ARBITRATION); -    ARB_PRINTK("scsi%d: starting arbitration, id = %d\n", HOSTNO, +    NCR5380_dprint(NDEBUG_ARBITRATION, instance); +    dprintk(NDEBUG_ARBITRATION, "scsi%d: starting arbitration, id = %d\n", HOSTNO,  	       instance->this_id);      /*  @@ -1437,7 +1355,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,      local_irq_restore(flags);      /* Wait for arbitration logic to complete */ -#if NCR_TIMEOUT +#ifdef NCR_TIMEOUT      {        unsigned long timeout = jiffies + 2*NCR_TIMEOUT; @@ -1457,7 +1375,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,  	 && !hostdata->connected);  #endif -    ARB_PRINTK("scsi%d: arbitration complete\n", HOSTNO); +    dprintk(NDEBUG_ARBITRATION, "scsi%d: arbitration complete\n", HOSTNO);      if (hostdata->connected) {  	NCR5380_write(MODE_REG, MR_BASE);  @@ -1478,7 +1396,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,  	(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||  	hostdata->connected) {  	NCR5380_write(MODE_REG, MR_BASE);  -	ARB_PRINTK("scsi%d: lost arbitration, deasserting MR_ARBITRATE\n", +	dprintk(NDEBUG_ARBITRATION, "scsi%d: lost arbitration, deasserting MR_ARBITRATE\n",  		   HOSTNO);  	return -1;      } @@ -1493,7 +1411,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,  	hostdata->connected) {  	NCR5380_write(MODE_REG, MR_BASE);  	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); -	ARB_PRINTK("scsi%d: lost arbitration, deasserting ICR_ASSERT_SEL\n", +	dprintk(NDEBUG_ARBITRATION, "scsi%d: lost arbitration, deasserting ICR_ASSERT_SEL\n",  		   HOSTNO);  	return -1;      } @@ -1516,7 +1434,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,  	return -1;      } -    ARB_PRINTK("scsi%d: won arbitration\n", HOSTNO); +    dprintk(NDEBUG_ARBITRATION, "scsi%d: won arbitration\n", HOSTNO);      /*        * Now that we have won arbitration, start Selection process, asserting  @@ -1576,7 +1494,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,      udelay(1); -    SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->device->id); +    dprintk(NDEBUG_SELECTION, "scsi%d: selecting target %d\n", HOSTNO, cmd->device->id);      /*        * The SCSI specification calls for a 250 ms timeout for the actual  @@ -1631,7 +1549,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,  	    printk(KERN_ERR "scsi%d: weirdness\n", HOSTNO);  	    if (hostdata->restart_select)  		printk(KERN_NOTICE "\trestart select\n"); -	    NCR_PRINT(NDEBUG_ANY); +	    NCR5380_dprint(NDEBUG_ANY, instance);  	    NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);  	    return -1;  	} @@ -1644,7 +1562,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,  #endif  	cmd->scsi_done(cmd);  	NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); -	SEL_PRINTK("scsi%d: target did not respond within 250ms\n", HOSTNO); +	dprintk(NDEBUG_SELECTION, "scsi%d: target did not respond within 250ms\n", HOSTNO);  	NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);  	return 0;      }  @@ -1669,7 +1587,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,      /* Wait for start of REQ/ACK handshake */      while (!(NCR5380_read(STATUS_REG) & SR_REQ)); -    SEL_PRINTK("scsi%d: target %d selected, going into MESSAGE OUT phase.\n", +    dprintk(NDEBUG_SELECTION, "scsi%d: target %d selected, going into MESSAGE OUT phase.\n",  	       HOSTNO, cmd->device->id);      tmp[0] = IDENTIFY(1, cmd->device->lun); @@ -1689,7 +1607,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,      data = tmp;      phase = PHASE_MSGOUT;      NCR5380_transfer_pio(instance, &phase, &len, &data); -    SEL_PRINTK("scsi%d: nexus established.\n", HOSTNO); +    dprintk(NDEBUG_SELECTION, "scsi%d: nexus established.\n", HOSTNO);      /* XXX need to handle errors here */      hostdata->connected = cmd;  #ifndef SUPPORT_TAGS @@ -1715,7 +1633,7 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,   *	bytes to transfer, **data - pointer to data pointer.   *    * Returns : -1 when different phase is entered without transferring - *	maximum number of bytes, 0 if all bytes are transfered or exit + *	maximum number of bytes, 0 if all bytes are transferred or exit   *	is in same phase.   *   * 	Also, *phase, *count, *data are modified in place. @@ -1752,12 +1670,12 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,  	 */  	while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ)); -	HSH_PRINTK("scsi%d: REQ detected\n", HOSTNO); +	dprintk(NDEBUG_HANDSHAKE, "scsi%d: REQ detected\n", HOSTNO);  	/* Check for phase mismatch */	  	if ((tmp & PHASE_MASK) != p) { -	    PIO_PRINTK("scsi%d: phase mismatch\n", HOSTNO); -	    NCR_PRINT_PHASE(NDEBUG_PIO); +	    dprintk(NDEBUG_PIO, "scsi%d: phase mismatch\n", HOSTNO); +	    NCR5380_dprint_phase(NDEBUG_PIO, instance);  	    break;  	} @@ -1780,24 +1698,24 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,  	    if (!((p & SR_MSG) && c > 1)) {  		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |   		    ICR_ASSERT_DATA); -		NCR_PRINT(NDEBUG_PIO); +		NCR5380_dprint(NDEBUG_PIO, instance);  		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |   			ICR_ASSERT_DATA | ICR_ASSERT_ACK);  	    } else {  		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |  		    ICR_ASSERT_DATA | ICR_ASSERT_ATN); -		NCR_PRINT(NDEBUG_PIO); +		NCR5380_dprint(NDEBUG_PIO, instance);  		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |   		    ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK);  	    }  	} else { -	    NCR_PRINT(NDEBUG_PIO); +	    NCR5380_dprint(NDEBUG_PIO, instance);  	    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);  	}  	while (NCR5380_read(STATUS_REG) & SR_REQ); -	HSH_PRINTK("scsi%d: req false, handshake complete\n", HOSTNO); +	dprintk(NDEBUG_HANDSHAKE, "scsi%d: req false, handshake complete\n", HOSTNO);  /*   * We have several special cases to consider during REQ/ACK handshaking :  @@ -1818,7 +1736,7 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,  	}       } while (--c); -    PIO_PRINTK("scsi%d: residual %d\n", HOSTNO, c); +    dprintk(NDEBUG_PIO, "scsi%d: residual %d\n", HOSTNO, c);      *count = c;      *data = d; @@ -1902,7 +1820,7 @@ static int do_abort (struct Scsi_Host *host)   *	bytes to transfer, **data - pointer to data pointer.   *    * Returns : -1 when different phase is entered without transferring - *	maximum number of bytes, 0 if all bytes or transfered or exit + *	maximum number of bytes, 0 if all bytes or transferred or exit   *	is in same phase.   *   * 	Also, *phase, *count, *data are modified in place. @@ -1926,7 +1844,7 @@ static int NCR5380_transfer_dma( struct Scsi_Host *instance,      }      hostdata->dma_len = c; -    DMA_PRINTK("scsi%d: initializing DMA for %s, %d bytes %s %p\n", +    dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n",  	       HOSTNO, (p & SR_IO) ? "reading" : "writing",  	       c, (p & SR_IO) ? "to" : "from", *data); @@ -2003,7 +1921,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  	    phase = (tmp & PHASE_MASK);    	    if (phase != old_phase) {  		old_phase = phase; -		NCR_PRINT_PHASE(NDEBUG_INFORMATION); +		NCR5380_dprint_phase(NDEBUG_INFORMATION, instance);  	    }  	    if(phase == PHASE_CMDOUT) { @@ -2068,12 +1986,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		    --cmd->SCp.buffers_residual;  		    cmd->SCp.this_residual = cmd->SCp.buffer->length;  		    cmd->SCp.ptr = SGADDR(cmd->SCp.buffer); - -		    /* ++roman: Try to merge some scatter-buffers if -		     * they are at contiguous physical addresses. -		     */ -//		    merge_contiguous_buffers( cmd ); -		    INF_PRINTK("scsi%d: %d bytes and %d buffers left\n", +		    dprintk(NDEBUG_INFORMATION, "scsi%d: %d bytes and %d buffers left\n",  			       HOSTNO, cmd->SCp.this_residual,  			       cmd->SCp.buffers_residual);  		} @@ -2165,7 +2078,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		    /* Accept message by clearing ACK */  		    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); -		    LNK_PRINTK("scsi%d: target %d lun %d linked command " +		    dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %d linked command "  			       "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun);  		    /* Enable reselect interrupts */ @@ -2190,7 +2103,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		     * and don't free it! */  		    cmd->next_link->tag = cmd->tag;  		    cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);  -		    LNK_PRINTK("scsi%d: target %d lun %d linked request " +		    dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %d linked request "  			       "done, calling scsi_done().\n",  			       HOSTNO, cmd->device->id, cmd->device->lun);  #ifdef NCR5380_STATS @@ -2205,7 +2118,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		    /* Accept message by clearing ACK */  		    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);  		    hostdata->connected = NULL; -		    QU_PRINTK("scsi%d: command for target %d, lun %d " +		    dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %d "  			      "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);  #ifdef SUPPORT_TAGS  		    cmd_free_tag( cmd ); @@ -2219,7 +2132,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  			/* ++Andreas: the mid level code knows about  			   QUEUE_FULL now. */  			TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; -			TAG_PRINTK("scsi%d: target %d lun %d returned " +			dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d returned "  				   "QUEUE_FULL after %d commands\n",  				   HOSTNO, cmd->device->id, cmd->device->lun,  				   ta->nr_allocated); @@ -2263,7 +2176,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		    if ((cmd->cmnd[0] != REQUEST_SENSE) &&   			(status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {  			scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0); -			ASEN_PRINTK("scsi%d: performing request sense\n", +			dprintk(NDEBUG_AUTOSENSE, "scsi%d: performing request sense\n",  				    HOSTNO);  			/* this is initialized from initialize_SCp   			cmd->SCp.buffer = NULL; @@ -2272,10 +2185,10 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  			local_irq_save(flags);  			LIST(cmd,hostdata->issue_queue); -			NEXT(cmd) = hostdata->issue_queue; +			SET_NEXT(cmd, hostdata->issue_queue);  		        hostdata->issue_queue = (struct scsi_cmnd *) cmd;  		        local_irq_restore(flags); -			QU_PRINTK("scsi%d: REQUEST SENSE added to head of " +			dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "  				  "issue queue\n", H_NO(cmd));  		   } else  #endif /* def AUTOSENSE */ @@ -2315,7 +2228,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  			cmd->device->tagged_supported = 0;  			hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);  			cmd->tag = TAG_NONE; -			TAG_PRINTK("scsi%d: target %d lun %d rejected " +			dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d rejected "  				   "QUEUE_TAG message; tagged queuing "  				   "disabled\n",  				   HOSTNO, cmd->device->id, cmd->device->lun); @@ -2328,11 +2241,11 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		    local_irq_save(flags);  		    cmd->device->disconnect = 1;  		    LIST(cmd,hostdata->disconnected_queue); -		    NEXT(cmd) = hostdata->disconnected_queue; +		    SET_NEXT(cmd, hostdata->disconnected_queue);  		    hostdata->connected = NULL;  		    hostdata->disconnected_queue = cmd;  		    local_irq_restore(flags); -		    QU_PRINTK("scsi%d: command for target %d lun %d was " +		    dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d lun %d was "  			      "moved from connected to the "  			      "disconnected_queue\n", HOSTNO,   			      cmd->device->id, cmd->device->lun); @@ -2385,13 +2298,13 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		    /* Accept first byte by clearing ACK */  		    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); -		    EXT_PRINTK("scsi%d: receiving extended message\n", HOSTNO); +		    dprintk(NDEBUG_EXTENDED, "scsi%d: receiving extended message\n", HOSTNO);  		    len = 2;  		    data = extended_msg + 1;  		    phase = PHASE_MSGIN;  		    NCR5380_transfer_pio(instance, &phase, &len, &data); -		    EXT_PRINTK("scsi%d: length=%d, code=0x%02x\n", HOSTNO, +		    dprintk(NDEBUG_EXTENDED, "scsi%d: length=%d, code=0x%02x\n", HOSTNO,  			       (int)extended_msg[1], (int)extended_msg[2]);  		    if (!len && extended_msg[1] <=  @@ -2403,7 +2316,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  			phase = PHASE_MSGIN;  			NCR5380_transfer_pio(instance, &phase, &len, &data); -			EXT_PRINTK("scsi%d: message received, residual %d\n", +			dprintk(NDEBUG_EXTENDED, "scsi%d: message received, residual %d\n",  				   HOSTNO, len);  			switch (extended_msg[2]) { @@ -2493,7 +2406,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)  		break;  	    default:  		printk("scsi%d: unknown phase\n", HOSTNO); -		NCR_PRINT(NDEBUG_ANY); +		NCR5380_dprint(NDEBUG_ANY, instance);  	    } /* switch(phase) */  	} /* if (tmp * SR_REQ) */       } /* while (1) */ @@ -2535,7 +2448,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)      target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); -    RSL_PRINTK("scsi%d: reselect\n", HOSTNO); +    dprintk(NDEBUG_RESELECTION, "scsi%d: reselect\n", HOSTNO);      /*        * At this point, we have detected that our SCSI ID is on the bus, @@ -2587,12 +2500,12 @@ static void NCR5380_reselect (struct Scsi_Host *instance)  	    ) {  	    if (prev) {  		REMOVE(prev, NEXT(prev), tmp, NEXT(tmp)); -		NEXT(prev) = NEXT(tmp); +		SET_NEXT(prev, NEXT(tmp));  	    } else {  		REMOVE(-1, hostdata->disconnected_queue, tmp, NEXT(tmp));  		hostdata->disconnected_queue = NEXT(tmp);  	    } -	    NEXT(tmp) = NULL; +	    SET_NEXT(tmp, NULL);  	    break;  	}      } @@ -2657,14 +2570,14 @@ static void NCR5380_reselect (struct Scsi_Host *instance)  	if (!NCR5380_transfer_pio(instance, &phase, &len, &data) &&  	    msg[1] == SIMPLE_QUEUE_TAG)  	    tag = msg[2]; -	TAG_PRINTK("scsi%d: target mask %02x, lun %d sent tag %d at " +	dprintk(NDEBUG_TAGS, "scsi%d: target mask %02x, lun %d sent tag %d at "  		   "reselection\n", HOSTNO, target_mask, lun, tag);      }  #endif      hostdata->connected = tmp; -    RSL_PRINTK("scsi%d: nexus established, target = %d, lun = %d, tag = %d\n", -	       HOSTNO, tmp->target, tmp->lun, tmp->tag); +    dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %d, tag = %d\n", +	       HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);  } @@ -2699,7 +2612,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)      local_irq_save(flags); -    ABRT_PRINTK("scsi%d: abort called basr 0x%02x, sr 0x%02x\n", HOSTNO, +    dprintk(NDEBUG_ABORT, "scsi%d: abort called basr 0x%02x, sr 0x%02x\n", HOSTNO,  		NCR5380_read(BUS_AND_STATUS_REG),  		NCR5380_read(STATUS_REG)); @@ -2712,7 +2625,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)      if (hostdata->connected == cmd) { -	ABRT_PRINTK("scsi%d: aborting connected command\n", HOSTNO); +	dprintk(NDEBUG_ABORT, "scsi%d: aborting connected command\n", HOSTNO);  /*   * We should perform BSY checking, and make sure we haven't slipped   * into BUS FREE. @@ -2741,11 +2654,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)  #endif  	  local_irq_restore(flags);  	  cmd->scsi_done(cmd); -	  return SCSI_ABORT_SUCCESS; +	  return SUCCESS;  	} else {  /*	  local_irq_restore(flags); */  	  printk("scsi%d: abort of connected command failed!\n", HOSTNO); -	  return SCSI_ABORT_ERROR; +	  return FAILED;  	}      }  #endif @@ -2760,15 +2673,15 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)  	if (cmd == tmp) {  	    REMOVE(5, *prev, tmp, NEXT(tmp));  	    (*prev) = NEXT(tmp); -	    NEXT(tmp) = NULL; +	    SET_NEXT(tmp, NULL);  	    tmp->result = DID_ABORT << 16;  	    local_irq_restore(flags); -	    ABRT_PRINTK("scsi%d: abort removed command from issue queue.\n", +	    dprintk(NDEBUG_ABORT, "scsi%d: abort removed command from issue queue.\n",  			HOSTNO);  	    /* Tagged queuing note: no tag to free here, hasn't been assigned  	     * yet... */  	    tmp->scsi_done(tmp); -	    return SCSI_ABORT_SUCCESS; +	    return SUCCESS;  	}  /*  @@ -2784,8 +2697,8 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)      if (hostdata->connected) {  	local_irq_restore(flags); -	ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO); -        return SCSI_ABORT_SNOOZE; +	dprintk(NDEBUG_ABORT, "scsi%d: abort failed, command connected.\n", HOSTNO); +        return FAILED;      }  /* @@ -2817,12 +2730,12 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)  	 tmp = NEXT(tmp))           if (cmd == tmp) {              local_irq_restore(flags); -	    ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO); +	    dprintk(NDEBUG_ABORT, "scsi%d: aborting disconnected command.\n", HOSTNO);              if (NCR5380_select (instance, cmd, (int) cmd->tag))  -		return SCSI_ABORT_BUSY; +		return FAILED; -	    ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO); +	    dprintk(NDEBUG_ABORT, "scsi%d: nexus reestablished.\n", HOSTNO);  	    do_abort (instance); @@ -2833,7 +2746,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)  		    if (cmd == tmp) {  		    REMOVE(5, *prev, tmp, NEXT(tmp));  		    *prev = NEXT(tmp); -		    NEXT(tmp) = NULL; +		    SET_NEXT(tmp, NULL);  		    tmp->result = DID_ABORT << 16;  		    /* We must unlock the tag/LUN immediately here, since the  		     * target goes to BUS FREE and doesn't send us another @@ -2846,7 +2759,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)  #endif  		    local_irq_restore(flags);  		    tmp->scsi_done(tmp); -		    return SCSI_ABORT_SUCCESS; +		    return SUCCESS;  		}  	} @@ -2863,7 +2776,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)      local_irq_restore(flags);      printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO);  -    return SCSI_ABORT_NOT_RUNNING; +    return FAILED;  } @@ -2872,7 +2785,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)   *    * Purpose : reset the SCSI bus.   * - * Returns : SCSI_RESET_WAKEUP + * Returns : SUCCESS or FAILURE   *   */  @@ -2881,7 +2794,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)      SETUP_HOSTDATA(cmd->device->host);      int           i;      unsigned long flags; -#if 1 +#if defined(RESET_RUN_DONE)      struct scsi_cmnd *connected, *disconnected_queue;  #endif @@ -2903,8 +2816,15 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)       * through anymore ... */      (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG ); -#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */ -      /* XXX see below                                            XXX */ +	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this +	 * should go. +	 * Catch-22: if we don't clear all queues, the SCSI driver lock will +	 * not be released by atari_scsi_reset()! +	 */ + +#if defined(RESET_RUN_DONE) +	/* XXX Should now be done by midlevel code, but it's broken XXX */ +	/* XXX see below                                            XXX */      /* MSch: old-style reset: actually abort all command processing here */ @@ -2934,26 +2854,26 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)       */      if ((cmd = connected)) { -	ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); +	dprintk(NDEBUG_ABORT, "scsi%d: reset aborted a connected command\n", H_NO(cmd));  	cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);  	cmd->scsi_done( cmd );      }      for (i = 0; (cmd = disconnected_queue); ++i) {  	disconnected_queue = NEXT(cmd); -	NEXT(cmd) = NULL; +	SET_NEXT(cmd, NULL);  	cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);  	cmd->scsi_done( cmd );      }      if (i > 0) -	ABRT_PRINTK("scsi: reset aborted %d disconnected command(s)\n", i); +	dprintk(NDEBUG_ABORT, "scsi: reset aborted %d disconnected command(s)\n", i);      /* since all commands have been explicitly terminated, we need to tell       * the midlevel code that the reset was SUCCESSFUL, and there is no        * need to 'wake up' the commands by a request_sense       */ -    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET; +    return SUCCESS;  #else /* 1 */      /* MSch: new-style reset handling: let the mid-level do what it can */ @@ -2980,11 +2900,11 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)       */      if (hostdata->issue_queue) -	ABRT_PRINTK("scsi%d: reset aborted issued command(s)\n", H_NO(cmd)); +	dprintk(NDEBUG_ABORT, "scsi%d: reset aborted issued command(s)\n", H_NO(cmd));      if (hostdata->connected)  -	ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); +	dprintk(NDEBUG_ABORT, "scsi%d: reset aborted a connected command\n", H_NO(cmd));      if (hostdata->disconnected_queue) -	ABRT_PRINTK("scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd)); +	dprintk(NDEBUG_ABORT, "scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd));      local_irq_save(flags);      hostdata->issue_queue = NULL; @@ -3001,7 +2921,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)      local_irq_restore(flags);      /* we did no complete reset of all commands, so a wakeup is required */ -    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET; +    return SUCCESS;  #endif /* 1 */  }  | 
