if (!imm_select(dev, cmd->device->id)) { 
if (!imm_select(dev, scmd_id(cmd))) { 
static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd){	unsigned short ppb = dev->base;	unsigned char l = 0, h = 0;	int retv, x;	/* First check for any errors that may have occurred	 * Here we check for internal errors	 */	if (dev->failed)		return 0;	switch (cmd->SCp.phase) {	case 0:		/* Phase 0 - Waiting for parport */		if (time_after(jiffies, dev->jstart + HZ)) {			/*			 * We waited more than a second			 * for parport to call us			 */			imm_fail(dev, DID_BUS_BUSY);			return 0;		}		return 1;	/* wait until imm_wakeup claims parport */		/* Phase 1 - Connected */	case 1:		imm_connect(dev, CONNECT_EPP_MAYBE);		cmd->SCp.phase++;		/* Phase 2 - We are now talking to the scsi bus */	case 2:		if (!imm_select(dev, cmd->device->id)) {			imm_fail(dev, DID_NO_CONNECT);			return 0;		}		cmd->SCp.phase++;		/* Phase 3 - Ready to accept a command */	case 3:		w_ctr(ppb, 0x0c);		if (!(r_str(ppb) & 0x80))			return 1;		if (!imm_send_command(cmd))			return 0;		cmd->SCp.phase++;		/* Phase 4 - Setup scatter/gather buffers */	case 4:		if (cmd->use_sg) {			/* if many buffers are available, start filling the first */			cmd->SCp.buffer =			    (struct scatterlist *) cmd->request_buffer;			cmd->SCp.this_residual = cmd->SCp.buffer->length;			cmd->SCp.ptr =			    page_address(cmd->SCp.buffer->page) +			    cmd->SCp.buffer->offset;		} else {			/* else fill the only available buffer */			cmd->SCp.buffer = NULL;			cmd->SCp.this_residual = cmd->request_bufflen;			cmd->SCp.ptr = cmd->request_buffer;		}		cmd->SCp.buffers_residual = cmd->use_sg - 1;		cmd->SCp.phase++;		if (cmd->SCp.this_residual & 0x01)			cmd->SCp.this_residual++;		/* Phase 5 - Pre-Data transfer stage */	case 5:		/* Spin lock for BUSY */		w_ctr(ppb, 0x0c);		if (!(r_str(ppb) & 0x80))			return 1;		/* Require negotiation for read requests */		x = (r_str(ppb) & 0xb8);		dev->rd = (x & 0x10) ? 1 : 0;		dev->dp = (x & 0x20) ? 0 : 1;		if ((dev->dp) && (dev->rd))			if (imm_negotiate(dev))				return 0;		cmd->SCp.phase++;		/* Phase 6 - Data transfer stage */	case 6:		/* Spin lock for BUSY */		w_ctr(ppb, 0x0c);		if (!(r_str(ppb) & 0x80))			return 1;		if (dev->dp) {			retv = imm_completion(cmd);			if (retv == -1)				return 0;			if (retv == 0)				return 1;		}		cmd->SCp.phase++;		/* Phase 7 - Post data transfer stage */	case 7:		if ((dev->dp) && (dev->rd)) {			if ((dev->mode == IMM_NIBBLE) || (dev->mode == IMM_PS2)) {				w_ctr(ppb, 0x4);				w_ctr(ppb, 0xc);				w_ctr(ppb, 0xe);				w_ctr(ppb, 0x4);			}		}		cmd->SCp.phase++;		/* Phase 8 - Read status/message */	case 8:		/* Check for data overrun */		if (imm_wait(dev) != (unsigned char) 0xb8) {			imm_fail(dev, DID_ERROR);			return 0;		}		if (imm_negotiate(dev))			return 0;		if (imm_in(dev, &l, 1)) {	/* read status byte */			/* Check for optional message byte */			if (imm_wait(dev) == (unsigned char) 0xb8)				imm_in(dev, &h, 1);			cmd->result = (DID_OK << 16) + (l & STATUS_MASK);		}		if ((dev->mode == IMM_NIBBLE) || (dev->mode == IMM_PS2)) {			w_ctr(ppb, 0x4);			w_ctr(ppb, 0xc);			w_ctr(ppb, 0xe);			w_ctr(ppb, 0x4);		}		return 0;	/* Finished */		break;	default:		printk("imm: Invalid scsi phase\n");	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/imm.c/buggy/drivers/scsi/imm.c