(scsicmd->device->channel == 2)) { 
(scmd_channel(scsicmd) == 2)) { 
static void aac_srb_callback(void *context, struct fib * fibptr){	struct aac_dev *dev;	struct aac_srb_reply *srbreply;	struct scsi_cmnd *scsicmd;	scsicmd = (struct scsi_cmnd *) context;	dev = (struct aac_dev *)scsicmd->device->host->hostdata;	if (fibptr == NULL)		BUG();	srbreply = (struct aac_srb_reply *) fib_data(fibptr);	scsicmd->sense_buffer[0] = '\0';  /* Initialize sense valid flag to false */	/*	 *	Calculate resid for sg 	 */	 	scsicmd->resid = scsicmd->request_bufflen - 		le32_to_cpu(srbreply->data_xfer_length);	if(scsicmd->use_sg)		pci_unmap_sg(dev->pdev, 			(struct scatterlist *)scsicmd->buffer,			scsicmd->use_sg,			scsicmd->sc_data_direction);	else if(scsicmd->request_bufflen)		pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle, scsicmd->request_bufflen,			scsicmd->sc_data_direction);	/*	 * First check the fib status	 */	if (le32_to_cpu(srbreply->status) != ST_OK){		int len;		printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));		len = (le32_to_cpu(srbreply->sense_data_size) > 				sizeof(scsicmd->sense_buffer)) ?				sizeof(scsicmd->sense_buffer) : 				le32_to_cpu(srbreply->sense_data_size);		scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;		memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);	}	/*	 * Next check the srb status	 */	switch( (le32_to_cpu(srbreply->srb_status))&0x3f){	case SRB_STATUS_ERROR_RECOVERY:	case SRB_STATUS_PENDING:	case SRB_STATUS_SUCCESS:		if(scsicmd->cmnd[0] == INQUIRY ){			u8 b;			u8 b1;			/* We can't expose disk devices because we can't tell whether they			 * are the raw container drives or stand alone drives.  If they have			 * the removable bit set then we should expose them though.			 */			b = (*(u8*)scsicmd->buffer)&0x1f;			b1 = ((u8*)scsicmd->buffer)[1];			if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER 					|| (b==TYPE_DISK && (b1&0x80)) ){				scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;			/*			 * We will allow disk devices if in RAID/SCSI mode and			 * the channel is 2			 */			} else if ((dev->raid_scsi_mode) &&					(scsicmd->device->channel == 2)) {				scsicmd->result = DID_OK << 16 | 						COMMAND_COMPLETE << 8;			} else {				scsicmd->result = DID_NO_CONNECT << 16 | 						COMMAND_COMPLETE << 8;			}		} else {			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;		}		break;	case SRB_STATUS_DATA_OVERRUN:		switch(scsicmd->cmnd[0]){		case  READ_6:		case  WRITE_6:		case  READ_10:		case  WRITE_10:		case  READ_12:		case  WRITE_12:		case  READ_16:		case  WRITE_16:			if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {				printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");			} else {				printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n");			}			scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;			break;		case INQUIRY: {			u8 b;			u8 b1;			/* We can't expose disk devices because we can't tell whether they			* are the raw container drives or stand alone drives			*/			b = (*(u8*)scsicmd->buffer)&0x0f;			b1 = ((u8*)scsicmd->buffer)[1];			if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER					|| (b==TYPE_DISK && (b1&0x80)) ){				scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;			/*			 * We will allow disk devices if in RAID/SCSI mode and			 * the channel is 2			 */			} else if ((dev->raid_scsi_mode) &&					(scsicmd->device->channel == 2)) {				scsicmd->result = DID_OK << 16 | 						COMMAND_COMPLETE << 8;			} else {				scsicmd->result = DID_NO_CONNECT << 16 | 						COMMAND_COMPLETE << 8;			}			break;		}		default:			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;			break;		}		break;	case SRB_STATUS_ABORTED:		scsicmd->result = DID_ABORT << 16 | ABORT << 8;		break;	case SRB_STATUS_ABORT_FAILED:		// Not sure about this one - but assuming the hba was trying to abort for some reason		scsicmd->result = DID_ERROR << 16 | ABORT << 8;		break;	case SRB_STATUS_PARITY_ERROR:		scsicmd->result = DID_PARITY << 16 | MSG_PARITY_ERROR << 8;		break;	case SRB_STATUS_NO_DEVICE:	case SRB_STATUS_INVALID_PATH_ID:	case SRB_STATUS_INVALID_TARGET_ID:	case SRB_STATUS_INVALID_LUN:	case SRB_STATUS_SELECTION_TIMEOUT:		scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;		break;	case SRB_STATUS_COMMAND_TIMEOUT:	case SRB_STATUS_TIMEOUT:		scsicmd->result = DID_TIME_OUT << 16 | COMMAND_COMPLETE << 8;		break;	case SRB_STATUS_BUSY:		scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;		break;	case SRB_STATUS_BUS_RESET:		scsicmd->result = DID_RESET << 16 | COMMAND_COMPLETE << 8;		break;	case SRB_STATUS_MESSAGE_REJECTED:		scsicmd->result = DID_ERROR << 16 | MESSAGE_REJECT << 8;		break;	case SRB_STATUS_REQUEST_FLUSHED:	case SRB_STATUS_ERROR:	case SRB_STATUS_INVALID_REQUEST:	case SRB_STATUS_REQUEST_SENSE_FAILED:	case SRB_STATUS_NO_HBA:	case SRB_STATUS_UNEXPECTED_BUS_FREE:	case SRB_STATUS_PHASE_SEQUENCE_FAILURE:	case SRB_STATUS_BAD_SRB_BLOCK_LENGTH:	case SRB_STATUS_DELAYED_RETRY:	case SRB_STATUS_BAD_FUNCTION:	case SRB_STATUS_NOT_STARTED:	case SRB_STATUS_NOT_IN_USE:	case SRB_STATUS_FORCE_ABORT:	case SRB_STATUS_DOMAIN_VALIDATION_FAIL:	default:#ifdef AAC_DETAILED_STATUS_INFO		printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",			le32_to_cpu(srbreply->srb_status) & 0x3F,			aac_get_status_string(				le32_to_cpu(srbreply->srb_status) & 0x3F), 			scsicmd->cmnd[0], 			le32_to_cpu(srbreply->scsi_status));#endif		scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;		break;	}	if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){  // Check Condition		int len;		scsicmd->result |= SAM_STAT_CHECK_CONDITION;		len = (le32_to_cpu(srbreply->sense_data_size) > 				sizeof(scsicmd->sense_buffer)) ?				sizeof(scsicmd->sense_buffer) :				le32_to_cpu(srbreply->sense_data_size);#ifdef AAC_DETAILED_STATUS_INFO		printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",					le32_to_cpu(srbreply->status), len);#endif		memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);			}	/*	 * OR in the scsi status (already shifted up a bit)	 */	scsicmd->result |= le32_to_cpu(srbreply->scsi_status);	fib_complete(fibptr);	fib_free(fibptr);	scsicmd->scsi_done(scsicmd);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/aachba.c/buggy/drivers/scsi/aacraid/aachba.c