BUG_ON (fibsize > (sizeof(struct hw_fib) -
BUG_ON (fibsize > (dev->max_fib_size -
static int aac_write(struct scsi_cmnd * scsicmd, int cid){	u32 lba;	u32 count;	int status;	u16 fibsize;	struct aac_dev *dev;	struct fib * cmd_fibcontext;	dev = (struct aac_dev *)scsicmd->device->host->hostdata;	/*	 *	Get block address and transfer length	 */	if (scsicmd->cmnd[0] == WRITE_6)	/* 6 byte command */	{		lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];		count = scsicmd->cmnd[4];		if (count == 0)			count = 256;	} else {		dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid));		lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];		count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];	}	dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n",	  smp_processor_id(), (unsigned long long)lba, jiffies));	/*	 *	Allocate and initialize a Fib then setup a BlockWrite command	 */	if (!(cmd_fibcontext = fib_alloc(dev))) {		scsicmd->result = DID_ERROR << 16;		aac_io_done(scsicmd);		return 0;	}	fib_init(cmd_fibcontext);	if(dev->dac_support == 1) {		struct aac_write64 *writecmd;		writecmd = (struct aac_write64 *) fib_data(cmd_fibcontext);		writecmd->command = cpu_to_le32(VM_CtHostWrite64);		writecmd->cid = cpu_to_le16(cid);		writecmd->sector_count = cpu_to_le16(count); 		writecmd->block = cpu_to_le32(lba);		writecmd->pad	= 0;		writecmd->flags	= 0;		aac_build_sg64(scsicmd, &writecmd->sg);		fibsize = sizeof(struct aac_write64) + 			((le32_to_cpu(writecmd->sg.count) - 1) * 			 sizeof (struct sgentry64));		BUG_ON (fibsize > (sizeof(struct hw_fib) - 					sizeof(struct aac_fibhdr)));		/*		 *	Now send the Fib to the adapter		 */		status = fib_send(ContainerCommand64, 			  cmd_fibcontext, 			  fibsize, 			  FsaNormal, 			  0, 1, 			  (fib_callback) write_callback, 			  (void *) scsicmd);	} else {		struct aac_write *writecmd;		writecmd = (struct aac_write *) fib_data(cmd_fibcontext);		writecmd->command = cpu_to_le32(VM_CtBlockWrite);		writecmd->cid = cpu_to_le32(cid);		writecmd->block = cpu_to_le32(lba);		writecmd->count = cpu_to_le32(count * 512);		writecmd->sg.count = cpu_to_le32(1);		/* ->stable is not used - it did mean which type of write */		if (count * 512 > (64 * 1024)) {			BUG();		}		aac_build_sg(scsicmd, &writecmd->sg);		fibsize = sizeof(struct aac_write) + 			((le32_to_cpu(writecmd->sg.count) - 1) * 			 sizeof (struct sgentry));		BUG_ON (fibsize > (sizeof(struct hw_fib) - 					sizeof(struct aac_fibhdr)));		/*		 *	Now send the Fib to the adapter		 */		status = fib_send(ContainerCommand, 			  cmd_fibcontext, 			  fibsize, 			  FsaNormal, 			  0, 1, 			  (fib_callback) write_callback, 			  (void *) scsicmd);	}	/*	 *	Check that the command queued to the controller	 */	if (status == -EINPROGRESS)	{		dprintk("write queued.\n");		return 0;	}	printk(KERN_WARNING "aac_write: fib_send failed with status: %d\n", status);	/*	 *	For some reason, the Fib didn't queue, return QUEUE_FULL	 */	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;	aac_io_done(scsicmd);	fib_complete(cmd_fibcontext);	fib_free(cmd_fibcontext);	return 0;}