case 0:  c->Request.CDBLen = 12; c->Request.Type.Attribute = ATTR_SIMPLE; c->Request.Type.Direction = XFER_WRITE; c->Request.Timeout = 0; c->Request.CDB[0] = cmd;  c->Request.CDB[1] = 0;     memcpy(&c->Request.CDB[4], buff, 8); break; case 1:  c->Request.CDBLen = 12; c->Request.Type.Attribute = ATTR_SIMPLE; c->Request.Type.Direction = XFER_WRITE; c->Request.Timeout = 0; memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); c->Request.CDB[0] = cmd;   c->Request.CDB[1] = 0x04;
static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff,	size_t size,	unsigned int use_unit_num, /* 0: address the controller,				      1: address logical volume log_unit,				      2: periph device address is scsi3addr */	unsigned int log_unit, __u8 page_code, unsigned char *scsi3addr,	int cmd_type){	ctlr_info_t *h= hba[ctlr];	u64bit buff_dma_handle;	int status = IO_OK;	c->cmd_type = CMD_IOCTL_PEND;	c->Header.ReplyQueue = 0;	if( buff != NULL) {		c->Header.SGList = 1;		c->Header.SGTotal= 1;	} else {		c->Header.SGList = 0;                c->Header.SGTotal= 0;	}	c->Header.Tag.lower = c->busaddr;	c->Request.Type.Type = cmd_type;	if (cmd_type == TYPE_CMD) {		switch(cmd) {		case  CISS_INQUIRY:			/* If the logical unit number is 0 then, this is going			to controller so It's a physical command			mode = 0 target = 0.  So we have nothing to write.			otherwise, if use_unit_num == 1,			mode = 1(volume set addressing) target = LUNID			otherwise, if use_unit_num == 2,			mode = 0(periph dev addr) target = scsi3addr */			if (use_unit_num == 1) {				c->Header.LUN.LogDev.VolId=					h->drv[log_unit].LunID;                        	c->Header.LUN.LogDev.Mode = 1;			} else if (use_unit_num == 2) {				memcpy(c->Header.LUN.LunAddrBytes,scsi3addr,8);				c->Header.LUN.LogDev.Mode = 0;			}			/* are we trying to read a vital product page */			if(page_code != 0) {				c->Request.CDB[1] = 0x01;				c->Request.CDB[2] = page_code;			}			c->Request.CDBLen = 6;			c->Request.Type.Attribute = ATTR_SIMPLE;  			c->Request.Type.Direction = XFER_READ;			c->Request.Timeout = 0;			c->Request.CDB[0] =  CISS_INQUIRY;			c->Request.CDB[4] = size  & 0xFF;  		break;		case CISS_REPORT_LOG:		case CISS_REPORT_PHYS:                        /* Talking to controller so It's a physical command			   mode = 00 target = 0.  Nothing to write.                        */			c->Request.CDBLen = 12;			c->Request.Type.Attribute = ATTR_SIMPLE;			c->Request.Type.Direction = XFER_READ;			c->Request.Timeout = 0;			c->Request.CDB[0] = cmd;			c->Request.CDB[6] = (size >> 24) & 0xFF;  //MSB			c->Request.CDB[7] = (size >> 16) & 0xFF;			c->Request.CDB[8] = (size >> 8) & 0xFF;			c->Request.CDB[9] = size & 0xFF;			break;		case CCISS_READ_CAPACITY:			c->Header.LUN.LogDev.VolId = h->drv[log_unit].LunID;			c->Header.LUN.LogDev.Mode = 1;			c->Request.CDBLen = 10;			c->Request.Type.Attribute = ATTR_SIMPLE;			c->Request.Type.Direction = XFER_READ;			c->Request.Timeout = 0;			c->Request.CDB[0] = cmd;		break;		case CCISS_CACHE_FLUSH:			c->Request.CDBLen = 12;			c->Request.Type.Attribute = ATTR_SIMPLE;			c->Request.Type.Direction = XFER_WRITE;			c->Request.Timeout = 0;			c->Request.CDB[0] = BMIC_WRITE;			c->Request.CDB[6] = BMIC_CACHE_FLUSH;		break;		default:			printk(KERN_WARNING				"cciss%d:  Unknown Command 0x%c\n", ctlr, cmd);			return(IO_ERROR);		}	} else if (cmd_type == TYPE_MSG) {		switch (cmd) {		case 3:	/* No-Op message */			c->Request.CDBLen = 1;			c->Request.Type.Attribute = ATTR_SIMPLE;			c->Request.Type.Direction = XFER_WRITE;			c->Request.Timeout = 0;			c->Request.CDB[0] = cmd;			break;		default:			printk(KERN_WARNING				"cciss%d: unknown message type %d\n",				ctlr, cmd);			return IO_ERROR;		}	} else {		printk(KERN_WARNING			"cciss%d: unknown command type %d\n", ctlr, cmd_type);		return IO_ERROR;	}	/* Fill in the scatter gather information */	if (size > 0) {		buff_dma_handle.val = (__u64) pci_map_single(h->pdev,			buff, size, PCI_DMA_BIDIRECTIONAL);		c->SG[0].Addr.lower = buff_dma_handle.val32.lower;		c->SG[0].Addr.upper = buff_dma_handle.val32.upper;		c->SG[0].Len = size;		c->SG[0].Ext = 0;  /* we are not chaining */	}	return status;}