if (st) { u32 count, error; /* An error has occurred */ 
cmd->result = error & 0xff; /* * if DeviceStatus is not SCSI_SUCCESS copy over the sense data and let * the SCSI layer handle the error */ if (cmd->result) memcpy(cmd->sense_buffer, &msg->body[3], min(sizeof(cmd->sense_buffer), (size_t) 40)); 
static int i2o_scsi_reply(struct i2o_controller *c, u32 m,			  struct i2o_message *msg){	struct scsi_cmnd *cmd;	struct device *dev;	u8 as, ds, st;	cmd = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));	if (msg->u.head[0] & (1 << 13)) {		struct i2o_message __iomem *pmsg;	/* preserved message */		u32 pm;		int err = DID_ERROR;		pm = le32_to_cpu(msg->body[3]);		pmsg = i2o_msg_in_to_virt(c, pm);		osm_err("IOP fail.\n");		osm_err("From %d To %d Cmd %d.\n",			(msg->u.head[1] >> 12) & 0xFFF,			msg->u.head[1] & 0xFFF, msg->u.head[1] >> 24);		osm_err("Failure Code %d.\n", msg->body[0] >> 24);		if (msg->body[0] & (1 << 16))			osm_err("Format error.\n");		if (msg->body[0] & (1 << 17))			osm_err("Path error.\n");		if (msg->body[0] & (1 << 18))			osm_err("Path State.\n");		if (msg->body[0] & (1 << 18))		{			osm_err("Congestion.\n");			err = DID_BUS_BUSY;		}		osm_debug("Failing message is %p.\n", pmsg);		cmd = i2o_cntxt_list_get(c, readl(&pmsg->u.s.tcntxt));		if (!cmd)			return 1;		cmd->result = err << 16;		cmd->scsi_done(cmd);		/* Now flush the message by making it a NOP */		i2o_msg_nop(c, pm);		return 1;	}	/*	 *      Low byte is device status, next is adapter status,	 *      (then one byte reserved), then request status.	 */	ds = (u8) le32_to_cpu(msg->body[0]);	as = (u8) (le32_to_cpu(msg->body[0]) >> 8);	st = (u8) (le32_to_cpu(msg->body[0]) >> 24);	/*	 *      Is this a control request coming back - eg an abort ?	 */	if (!cmd) {		if (st)			osm_warn("SCSI abort: %08X", le32_to_cpu(msg->body[0]));		osm_info("SCSI abort completed.\n");		return -EFAULT;	}	osm_debug("Completed %ld\n", cmd->serial_number);	if (st) {		u32 count, error;		/* An error has occurred */		switch (st) {		case 0x06:			count = le32_to_cpu(msg->body[1]);			if (count < cmd->underflow) {				int i;				osm_err("SCSI underflow 0x%08X 0x%08X\n", count,					cmd->underflow);				osm_debug("Cmd: ");				for (i = 0; i < 15; i++)					pr_debug("%02X ", cmd->cmnd[i]);				pr_debug(".\n");				cmd->result = (DID_ERROR << 16);			}			break;		default:			error = le32_to_cpu(msg->body[0]);			osm_err("SCSI error %08x\n", error);			if ((error & 0xff) == 0x02 /*CHECK_CONDITION */ ) {				int i;				u32 len = sizeof(cmd->sense_buffer);				len = (len > 40) ? 40 : len;				// Copy over the sense data				memcpy(cmd->sense_buffer, (void *)&msg->body[3],				       len);				for (i = 0; i <= len; i++)					osm_info("%02x\n",						 cmd->sense_buffer[i]);				if (cmd->sense_buffer[0] == 0x70				    && cmd->sense_buffer[2] == DATA_PROTECT) {					/* This is to handle an array failed */					cmd->result = (DID_TIME_OUT << 16);					printk(KERN_WARNING "%s: SCSI Data "					       "Protect-Device (%d,%d,%d) "					       "hba_status=0x%x, dev_status="					       "0x%x, cmd=0x%x\n", c->name,					       (u32) cmd->device->channel,					       (u32) cmd->device->id,					       (u32) cmd->device->lun,					       (error >> 8) & 0xff,					       error & 0xff, cmd->cmnd[0]);				} else					cmd->result = (DID_ERROR << 16);				break;			}			switch (as) {			case 0x0E:				/* SCSI Reset */				cmd->result = DID_RESET << 16;				break;			case 0x0F:				cmd->result = DID_PARITY << 16;				break;			default:				cmd->result = DID_ERROR << 16;				break;			}			break;		}		cmd->scsi_done(cmd);		return 1;	}	cmd->result = DID_OK << 16 | ds;	dev = &c->pdev->dev;	if (cmd->use_sg)		dma_unmap_sg(dev, (struct scatterlist *)cmd->buffer,			     cmd->use_sg, cmd->sc_data_direction);	else if (cmd->request_bufflen)		dma_unmap_single(dev, (dma_addr_t) ((long)cmd->SCp.ptr),				 cmd->request_bufflen, cmd->sc_data_direction);	cmd->scsi_done(cmd);	return 1;};
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/9e87545f06930c1d294423a8091d1077e7444a47/i2o_scsi.c/clean/drivers/message/i2o/i2o_scsi.c