if (!ppa_select(dev, cmd->device->id)) { 
if (!ppa_select(dev, scmd_id(cmd))) { 
static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd){	unsigned short ppb = dev->base;	unsigned char l = 0, h = 0;	int retv;	/* First check for any errors that may of 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			 */			ppa_fail(dev, DID_BUS_BUSY);			return 0;		}		return 1;	/* wait until ppa_wakeup claims parport */	case 1:		/* Phase 1 - Connected */		{		/* Perform a sanity check for cable unplugged */			int retv = 2;	/* Failed */			ppa_connect(dev, CONNECT_EPP_MAYBE);			w_ctr(ppb, 0xe);			if ((r_str(ppb) & 0x08) == 0x08)				retv--;			w_ctr(ppb, 0xc);			if ((r_str(ppb) & 0x08) == 0x00)				retv--;			if (retv) {				if ((jiffies - dev->jstart) > (1 * HZ)) {					printk					    ("ppa: Parallel port cable is unplugged!!\n");					ppa_fail(dev, DID_BUS_BUSY);					return 0;				} else {					ppa_disconnect(dev);					return 1;	/* Try again in a jiffy */				}			}			cmd->SCp.phase++;		}	case 2:		/* Phase 2 - We are now talking to the scsi bus */		if (!ppa_select(dev, cmd->device->id)) {			ppa_fail(dev, DID_NO_CONNECT);			return 0;		}		cmd->SCp.phase++;	case 3:		/* Phase 3 - Ready to accept a command */		w_ctr(ppb, 0x0c);		if (!(r_str(ppb) & 0x80))			return 1;		if (!ppa_send_command(cmd))			return 0;		cmd->SCp.phase++;	case 4:		/* Phase 4 - Setup scatter/gather buffers */		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++;	case 5:		/* Phase 5 - Data transfer stage */		w_ctr(ppb, 0x0c);		if (!(r_str(ppb) & 0x80))			return 1;		retv = ppa_completion(cmd);		if (retv == -1)			return 0;		if (retv == 0)			return 1;		cmd->SCp.phase++;	case 6:		/* Phase 6 - Read status/message */		cmd->result = DID_OK << 16;		/* Check for data overrun */		if (ppa_wait(dev) != (unsigned char) 0xf0) {			ppa_fail(dev, DID_ERROR);			return 0;		}		if (ppa_in(dev, &l, 1)) {	/* read status byte */			/* Check for optional message byte */			if (ppa_wait(dev) == (unsigned char) 0xf0)				ppa_in(dev, &h, 1);			cmd->result =			    (DID_OK << 16) + (h << 8) + (l & STATUS_MASK);		}		return 0;	/* Finished */		break;	default:		printk("ppa: Invalid scsi phase\n");	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/ppa.c/buggy/drivers/scsi/ppa.c