Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c28bda25 authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds
Browse files

m68k: Reformat the Atari SCSI driver



Reformat the Atari SCSI driver

Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fb810d12
Loading
Loading
Loading
Loading
+2198 −2189
Original line number Diff line number Diff line
@@ -78,12 +78,20 @@

#if (NDEBUG & NDEBUG_LISTS)
#define LIST(x, y)						\
  { printk("LINE:%d   Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); \
    if ((x)==(y)) udelay(5); }
	do {							\
		printk("LINE:%d   Adding %p to %p\n",		\
		       __LINE__, (void*)(x), (void*)(y));	\
		if ((x) == (y))					\
			udelay(5);				\
	} while (0)
#define REMOVE(w, x, y, z)					\
  { printk("LINE:%d   Removing: %p->%p  %p->%p \n", __LINE__, \
	   (void*)(w), (void*)(x), (void*)(y), (void*)(z)); \
    if ((x)==(y)) udelay(5); }
	do {							\
		printk("LINE:%d   Removing: %p->%p  %p->%p \n",	\
		       __LINE__, (void*)(w), (void*)(x),	\
		       (void*)(y), (void*)(z));			\
		if ((x) == (y))					\
			udelay(5);				\
	} while (0)
#else
#define LIST(x,y)
#define REMOVE(w,x,y,z)
@@ -355,17 +363,17 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged )
	SETUP_HOSTDATA(cmd->device->host);

	if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun))
	return( 1 );
		return 1;
	if (!should_be_tagged ||
	    !setup_use_tagged_queuing || !cmd->device->tagged_supported)
	return( 0 );
		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",
			   H_NO(cmd), cmd->device->id, cmd->device->lun);
	return( 1 );
		return 1;
	}
    return( 0 );
	return 0;
}


@@ -387,8 +395,7 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged )
		hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
		TAG_PRINTK("scsi%d: target %d lun %d now allocated by untagged "
			   "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun);
    }
    else {
	} else {
		TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];

		cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS);
@@ -396,8 +403,8 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged )
		ta->nr_allocated++;
		TAG_PRINTK("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 );
			   H_NO(cmd), cmd->tag, cmd->device->id,
			   cmd->device->lun, ta->nr_allocated);
	}
}

@@ -414,12 +421,10 @@ static void cmd_free_tag( Scsi_Cmnd *cmd )
		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
		TAG_PRINTK("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) {
	} else if (cmd->tag >= MAX_TAGS) {
		printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n",
		       H_NO(cmd), cmd->tag);
    }
    else {
	} else {
		TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
		clear_bit(cmd->tag, ta->allocated);
		ta->nr_allocated--;
@@ -499,7 +504,7 @@ static void merge_contiguous_buffers( Scsi_Cmnd *cmd )
 * Inputs : cmd - Scsi_Cmnd structure to have pointers reset.
 */

static __inline__ void initialize_SCp(Scsi_Cmnd *cmd)
static inline void initialize_SCp(Scsi_Cmnd *cmd)
{
	/*
	 * Initialize the Scsi Pointer field so that all of the commands in the
@@ -529,21 +534,26 @@ static __inline__ void initialize_SCp(Scsi_Cmnd *cmd)
#if NDEBUG
static struct {
	unsigned char mask;
    const char * name;} 
signals[] = {{ SR_DBP, "PARITY"}, { SR_RST, "RST" }, { SR_BSY, "BSY" }, 
	const char *name;
} signals[] = {
	{ SR_DBP, "PARITY"}, { SR_RST, "RST" }, { SR_BSY, "BSY" },
	{ SR_REQ, "REQ" }, { SR_MSG, "MSG" }, { SR_CD,  "CD" }, { SR_IO, "IO" },
    { SR_SEL, "SEL" }, {0, NULL}}, 
basrs[] = {{BASR_ATN, "ATN"}, {BASR_ACK, "ACK"}, {0, NULL}},
icrs[] = {{ICR_ASSERT_RST, "ASSERT RST"},{ICR_ASSERT_ACK, "ASSERT ACK"},
	{ SR_SEL, "SEL" }, {0, NULL}
}, basrs[] = {
	{BASR_ATN, "ATN"}, {BASR_ACK, "ACK"}, {0, NULL}
}, icrs[] = {
	{ICR_ASSERT_RST, "ASSERT RST"},{ICR_ASSERT_ACK, "ASSERT ACK"},
	{ICR_ASSERT_BSY, "ASSERT BSY"}, {ICR_ASSERT_SEL, "ASSERT SEL"},
	{ICR_ASSERT_ATN, "ASSERT ATN"}, {ICR_ASSERT_DATA, "ASSERT DATA"},
    {0, NULL}},
mrs[] = {{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"}, 
	{0, NULL}
}, mrs[] = {
	{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"},
	{MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"}, {MR_ENABLE_PAR_INTR,
	"MODE PARITY INTR"}, {MR_ENABLE_EOP_INTR,"MODE EOP INTR"},
	{MR_MONITOR_BSY, "MODE MONITOR BSY"},
	{MR_DMA_MODE, "MODE DMA"}, {MR_ARBITRATE, "MODE ARBITRATION"},
    {0, NULL}};
	{0, NULL}
};

/*
 * Function : void NCR5380_print(struct Scsi_Host *instance)
@@ -553,7 +563,8 @@ mrs[] = {{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, {MR_TARGET, "MODE TARGET"},
 * Input : instance - which NCR5380
 */

static void NCR5380_print(struct Scsi_Host *instance) {
static void NCR5380_print(struct Scsi_Host *instance)
{
	unsigned char status, data, basr, mr, icr, i;
	unsigned long flags;

@@ -589,7 +600,8 @@ static struct {
} phases[] = {
	{PHASE_DATAOUT, "DATAOUT"}, {PHASE_DATAIN, "DATAIN"}, {PHASE_CMDOUT, "CMDOUT"},
	{PHASE_STATIN, "STATIN"}, {PHASE_MSGOUT, "MSGOUT"}, {PHASE_MSGIN, "MSGIN"},
    {PHASE_UNKNOWN, "UNKNOWN"}};
	{PHASE_UNKNOWN, "UNKNOWN"}
};

/*
 * Function : void NCR5380_print_phase(struct Scsi_Host *instance)
@@ -609,7 +621,8 @@ static void NCR5380_print_phase(struct Scsi_Host *instance)
		printk(KERN_DEBUG "scsi%d: REQ not asserted, phase unknown.\n", HOSTNO);
	else {
		for (i = 0; (phases[i].value != PHASE_UNKNOWN) &&
	    (phases[i].value != (status & PHASE_MASK)); ++i); 
		     (phases[i].value != (status & PHASE_MASK)); ++i)
			;
		printk(KERN_DEBUG "scsi%d: phase %s\n", HOSTNO, phases[i].name);
	}
}
@@ -617,8 +630,12 @@ 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) { };
static inline void NCR5380_print(struct Scsi_Host *instance)
{
};
static inline void NCR5380_print_phase(struct Scsi_Host *instance)
{
};

#endif

@@ -638,10 +655,10 @@ __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { };
#include <linux/workqueue.h>
#include <linux/interrupt.h>

static volatile int main_running = 0;
static volatile int main_running;
static DECLARE_WORK(NCR5380_tqueue, (void (*)(void *))NCR5380_main, NULL);

static __inline__ void queue_main(void)
static inline void queue_main(void)
{
	if (!main_running) {
		/* If in interrupt and NCR5380_main() not already running,
@@ -739,14 +756,14 @@ static void NCR5380_print_status (struct Scsi_Host *instance)

#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 (Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
	do {									\
		if (pos + strlen(fmt) + 20 /* slop */ < buffer + length)	\
			pos += sprintf(pos, fmt , ## args);			\
	} while(0)
static char *lprint_Scsi_Cmnd(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 int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer,
			     char **start, off_t offset, int length, int inout)
{
	char *pos = buffer;
	struct NCR5380_hostdata *hostdata;
@@ -763,13 +780,13 @@ int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **start, o

	hostdata = (struct NCR5380_hostdata *)instance->hostdata;

    if (inout) { /* Has data been written to the file ? */
	return(-ENOSYS);  /* Currently this is a no-op */
    }
	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");
	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);
@@ -800,8 +817,7 @@ int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **start, o
	return length;
}

static char *
lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length)
static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length)
{
	int i, s;
	unsigned char *command;
@@ -861,7 +877,6 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
		first_instance = instance;
	}


#ifndef AUTOSENSE
	if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1))
		printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n"
@@ -897,11 +912,10 @@ int atari_scsi_update_timeout(Scsi_Cmnd * SCset, int timeout)
	 * timers for timeout.
	 */

    if (!timer_pending(&SCset->eh_timeout)) {
	if (!timer_pending(&SCset->eh_timeout))
		rtn = 0;
    } else {
	else
		rtn = SCset->eh_timeout.expires - jiffies;
    }

	if (timeout == 0) {
		del_timer(&SCset->eh_timeout);
@@ -935,8 +949,7 @@ int atari_scsi_update_timeout(Scsi_Cmnd * SCset, int timeout)
 *
 */

static
int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
static int NCR5380_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
{
	SETUP_HOSTDATA(cmd->device->host);
	Scsi_Cmnd *tmp;
@@ -956,7 +969,6 @@ int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
	}
#endif /* (NDEBUG & NDEBUG_NO_WRITE) */


#ifdef NCR5380_STATS
# if 0
	if (!hostdata->connected && !hostdata->issue_queue &&
@@ -967,8 +979,7 @@ int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
# ifdef NCR5380_STAT_LIMIT
	if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
# endif
	switch (cmd->cmnd[0])
	{
		switch (cmd->cmnd[0]) {
		case WRITE:
		case WRITE_6:
		case WRITE_10:
@@ -996,7 +1007,6 @@ int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))

	cmd->result = 0;


	/*
	 * Insert the cmd into the issue queue. Note that REQUEST SENSE
	 * commands are added to the head of the queue since any command will
@@ -1113,7 +1123,9 @@ static void NCR5380_main (void *bl)
			     tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp))
				;
			/*printk("%p  ", tmp);*/
	    if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/
			if ((tmp == prev) && tmp)
				printk(" LOOP\n");
			/* else printk("\n"); */
#endif
			for (tmp = (Scsi_Cmnd *) hostdata->issue_queue,
			     prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) {
@@ -1246,9 +1258,9 @@ static void NCR5380_dma_complete( struct Scsi_Host *instance )
		p = hostdata->connected->SCp.phase;
		if (p & SR_IO) {
			udelay(10);
	    if ((((NCR5380_read(BUS_AND_STATUS_REG)) &
			if ((NCR5380_read(BUS_AND_STATUS_REG) &
			     (BASR_PHASE_MATCH|BASR_ACK)) ==
		 (BASR_PHASE_MATCH|BASR_ACK))) {
			    (BASR_PHASE_MATCH|BASR_ACK)) {
				saved_data = NCR5380_read(INPUT_DATA_REG);
				overrun = 1;
				DMA_PRINTK("scsi%d: read overrun handled\n", HOSTNO);
@@ -1267,8 +1279,8 @@ static void NCR5380_dma_complete( struct Scsi_Host *instance )
	transfered = hostdata->dma_len - NCR5380_dma_residual(instance);
	hostdata->dma_len = 0;

    data = (unsigned char **) &(hostdata->connected->SCp.ptr);
    count = &(hostdata->connected->SCp.this_residual);
	data = (unsigned char **)&hostdata->connected->SCp.ptr;
	count = &hostdata->connected->SCp.this_residual;
	*data += transfered;
	*count -= transfered;

@@ -1322,16 +1334,13 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
			INT_PRINTK("scsi%d: SEL interrupt\n", HOSTNO);
			NCR5380_reselect(instance);
			(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
	}
	else if (basr & BASR_PARITY_ERROR) {
		} else if (basr & BASR_PARITY_ERROR) {
			INT_PRINTK("scsi%d: PARITY interrupt\n", HOSTNO);
			(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
	}
	else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) {
		} else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) {
			INT_PRINTK("scsi%d: RESET interrupt\n", HOSTNO);
			(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
	}
	else {
		} else {
			/*
			 * The rest of the interrupt conditions can occur only during a
			 * DMA transfer
@@ -1365,8 +1374,7 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
			}
		} /* if !(SELECTION || PARITY) */
		handled = 1;
    } /* BASR & IRQ */
    else {
	} /* BASR & IRQ */ else {
		printk(KERN_NOTICE "scsi%d: interrupt without IRQ bit set in BASR, "
		       "BASR 0x%X, MR 0x%X, SR 0x%x\n", HOSTNO, basr,
		       NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG));
@@ -1387,8 +1395,7 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
# ifdef NCR5380_STAT_LIMIT
	if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
# endif
	switch (cmd->cmnd[0])
	{
		switch (cmd->cmnd[0]) {
		case WRITE:
		case WRITE_6:
		case WRITE_10:
@@ -1464,7 +1471,6 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
	}
	NCR5380_write(TARGET_COMMAND_REG, 0);


	/*
	 * Start arbitration.
	 */
@@ -1479,11 +1485,10 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
	{
		unsigned long timeout = jiffies + 2*NCR_TIMEOUT;

      while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
	   && time_before(jiffies, timeout) && !hostdata->connected)
		while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) &&
		       time_before(jiffies, timeout) && !hostdata->connected)
			;
      if (time_after_eq(jiffies, timeout))
      {
		if (time_after_eq(jiffies, timeout)) {
			printk("scsi : arbitration timeout at %d\n", __LINE__);
			NCR5380_write(MODE_REG, MR_BASE);
			NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
@@ -1491,8 +1496,9 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
		}
	}
#else /* NCR_TIMEOUT */
    while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
	 && !hostdata->connected);
	while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) &&
	       !hostdata->connected)
		;
#endif

	ARB_PRINTK("scsi%d: arbitration complete\n", HOSTNO);
@@ -1524,8 +1530,8 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
	/* after/during arbitration, BSY should be asserted.
	   IBM DPES-31080 Version S31Q works now */
	/* Tnx to Thomas_Roesch@m2.maus.de for finding this! (Roman) */
    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_SEL |
					 ICR_ASSERT_BSY ) ;
	NCR5380_write(INITIATOR_COMMAND_REG,
		      ICR_BASE | ICR_ASSERT_SEL | ICR_ASSERT_BSY);

	if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) ||
	    hostdata->connected) {
@@ -1634,14 +1640,14 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
	 * IO while SEL is true. But again, there are some disks out the in the
	 * world that do that nevertheless. (Somebody claimed that this announces
	 * reselection capability of the target.) So we better skip that test and
     * only wait for BSY... (Famous german words: Der Klügere gibt nach :-)
	 * only wait for BSY... (Famous german words: Der Klügere gibt nach :-)
	 */

    while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & 
	(SR_BSY | SR_IO)));
	while (time_before(jiffies, timeout) &&
	       !(NCR5380_read(STATUS_REG) & (SR_BSY | SR_IO)))
		;

    if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == 
	    (SR_SEL | SR_IO)) {
	if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
		NCR5380_reselect(instance);
		printk(KERN_ERR "scsi%d: reselection after won arbitration?\n",
@@ -1650,7 +1656,8 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
		return -1;
	}
#else
    while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY));
	while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY))
		;
#endif

	/*
@@ -1705,7 +1712,8 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
	 */

	/* Wait for start of REQ/ACK handshake */
    while (!(NCR5380_read(STATUS_REG) & SR_REQ));
	while (!(NCR5380_read(STATUS_REG) & SR_REQ))
		;

	SEL_PRINTK("scsi%d: target %d selected, going into MESSAGE OUT phase.\n",
		   HOSTNO, cmd->device->id);
@@ -1736,7 +1744,6 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)

	initialize_SCp(cmd);


	return 0;
}

@@ -1786,7 +1793,8 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,
		 * Wait for assertion of REQ, after which the phase bits will be
		 * valid
		 */
	while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ));
		while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ))
			;

		HSH_PRINTK("scsi%d: REQ detected\n", HOSTNO);

@@ -1814,8 +1822,7 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,

		if (!(p & SR_IO)) {
			if (!((p & SR_MSG) && c > 1)) {
		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
		    ICR_ASSERT_DATA);
				NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA);
				NCR_PRINT(NDEBUG_PIO);
				NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
					      ICR_ASSERT_DATA | ICR_ASSERT_ACK);
@@ -1831,7 +1838,8 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,
			NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);
		}

	while (NCR5380_read(STATUS_REG) & SR_REQ);
		while (NCR5380_read(STATUS_REG) & SR_REQ)
			;

		HSH_PRINTK("scsi%d: req false, handshake complete\n", HOSTNO);

@@ -1861,7 +1869,8 @@ static int NCR5380_transfer_pio( struct Scsi_Host *instance,
	tmp = NCR5380_read(STATUS_REG);
	/* The phase read from the bus is valid if either REQ is (already)
	 * asserted or if ACK hasn't been released yet. The latter is the case if
     * we're in MSGIN and all wanted bytes have been received. */
	 * we're in MSGIN and all wanted bytes have been received.
	 */
	if ((tmp & SR_REQ) || (p == PHASE_MSGIN && c == 0))
		*phase = tmp & PHASE_MASK;
	else
@@ -1900,14 +1909,16 @@ static int do_abort (struct Scsi_Host *host)
	 * the target sees, so we just handshake.
	 */

    while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ);
	while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ)
		;

	NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));

	if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
			      ICR_ASSERT_ACK);
	while (NCR5380_read(STATUS_REG) & SR_REQ);
		while (NCR5380_read(STATUS_REG) & SR_REQ)
			;
		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
	}

@@ -1962,9 +1973,8 @@ static int NCR5380_transfer_dma( struct Scsi_Host *instance,
		return -1;
	}

    if (atari_read_overruns && (p & SR_IO)) {
	if (atari_read_overruns && (p & SR_IO))
		c -= atari_read_overruns;
    }

	DMA_PRINTK("scsi%d: initializing DMA for %s, %d bytes %s %p\n",
		   HOSTNO, (p & SR_IO) ? "reading" : "writing",
@@ -2054,7 +2064,8 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)

				NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN |
					      ICR_ASSERT_ACK);
		while (NCR5380_read(STATUS_REG) & SR_REQ);
				while (NCR5380_read(STATUS_REG) & SR_REQ)
					;
				NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
					      ICR_ASSERT_ATN);
				sink = 0;
@@ -2145,8 +2156,8 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
				} else
#endif /* defined(REAL_DMA) */
					NCR5380_transfer_pio(instance, &phase,
		    (int *) &cmd->SCp.this_residual, (unsigned char **)
		    &cmd->SCp.ptr);
							     (int *)&cmd->SCp.this_residual,
							     (unsigned char **)&cmd->SCp.ptr);
				break;
			case PHASE_MSGIN:
				len = 1;
@@ -2265,8 +2276,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
#ifdef AUTOSENSE
					if ((cmd->cmnd[0] != REQUEST_SENSE) &&
					    (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
			ASEN_PRINTK("scsi%d: performing request sense\n",
				    HOSTNO);
						ASEN_PRINTK("scsi%d: performing request sense\n", HOSTNO);
						cmd->cmnd[0] = REQUEST_SENSE;
						cmd->cmnd[1] &= 0xe0;
						cmd->cmnd[2] = 0;
@@ -2463,8 +2473,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)


					msgout = MESSAGE_REJECT;
		    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
			ICR_ASSERT_ATN);
					NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
					break;
				} /* switch (tmp) */
				break;
@@ -2499,8 +2508,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
				 * PSEUDO-DMA architecture we should probably
				 * use the dma transfer function.
				 */
		NCR5380_transfer_pio(instance, &phase, &len, 
		    &data);
				NCR5380_transfer_pio(instance, &phase, &len, &data);
				break;
			case PHASE_STATIN:
				len = 1;
@@ -2565,14 +2573,16 @@ static void NCR5380_reselect (struct Scsi_Host *instance)

	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY);

    while (NCR5380_read(STATUS_REG) & SR_SEL);
	while (NCR5380_read(STATUS_REG) & SR_SEL)
		;
	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);

	/*
	 * Wait for target to go into MSGIN.
	 */

    while (!(NCR5380_read(STATUS_REG) & SR_REQ));
	while (!(NCR5380_read(STATUS_REG) & SR_REQ))
		;

	len = 1;
	data = msg;
@@ -2755,7 +2765,7 @@ int NCR5380_abort (Scsi_Cmnd *cmd)
	 */
	for (prev = (Scsi_Cmnd **)&(hostdata->issue_queue),
	     tmp = (Scsi_Cmnd *)hostdata->issue_queue;
	tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) )
	     tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) {
		if (cmd == tmp) {
			REMOVE(5, *prev, tmp, NEXT(tmp));
			(*prev) = NEXT(tmp);
@@ -2770,6 +2780,7 @@ int NCR5380_abort (Scsi_Cmnd *cmd)
			falcon_release_lock_if_possible(hostdata);
			return SCSI_ABORT_SUCCESS;
		}
	}

	/*
	 * Case 3 : If any commands are connected, we're going to fail the abort
@@ -2814,7 +2825,7 @@ int NCR5380_abort (Scsi_Cmnd *cmd)
	 */

	for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp;
	 tmp = NEXT(tmp)) 
	     tmp = NEXT(tmp)) {
		if (cmd == tmp) {
			local_irq_restore(flags);
			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
@@ -2829,7 +2840,7 @@ int NCR5380_abort (Scsi_Cmnd *cmd)
			local_irq_save(flags);
			for (prev = (Scsi_Cmnd **)&(hostdata->disconnected_queue),
			     tmp = (Scsi_Cmnd *)hostdata->disconnected_queue;
		tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) )
			     tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) {
				if (cmd == tmp) {
					REMOVE(5, *prev, tmp, NEXT(tmp));
					*prev = NEXT(tmp);
@@ -2850,6 +2861,8 @@ int NCR5380_abort (Scsi_Cmnd *cmd)
					return SCSI_ABORT_SUCCESS;
				}
			}
		}
	}

	/*
	 * Case 5 : If we reached this point, the command was not found in any of
@@ -3021,7 +3034,3 @@ static int NCR5380_bus_reset( Scsi_Cmnd *cmd)
	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
#endif /* 1 */
}

/* Local Variables: */
/* tab-width: 8     */
/* End:             */
+175 −186

File changed.

Preview size limit exceeded, changes collapsed.