l->logi = kmalloc (count * 3 * sizeof(logi), GFP_KERNEL); l->fcmds = kmalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); 
l->logi = kzalloc (count * 3 * sizeof(logi), GFP_KERNEL); l->fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); 
int fcp_initialize(fc_channel *fcchain, int count){	fc_channel *fc;	fcp_cmnd *fcmd;	int i, retry, ret;	ls *l;	FCND(("fcp_inititialize %08lx\n", (long)fcp_init))	FCND(("fc_channels %08lx\n", (long)fc_channels))	FCND((" SID %d DID %d\n", fcchain->sid, fcchain->did))	l = kmalloc(sizeof (ls) + count, GFP_KERNEL);	if (!l) {		printk ("FC: Cannot allocate memory for initialization\n");		return -ENOMEM;	}	memset (l, 0, sizeof(ls) + count);	l->magic = LSMAGIC;	l->count = count;	FCND(("FCP Init for %d channels\n", count))	init_MUTEX_LOCKED(&l->sem);	init_timer(&l->timer);	l->timer.function = fcp_login_timeout;	l->timer.data = (unsigned long)l;	atomic_set (&l->todo, count);	l->logi = kmalloc (count * 3 * sizeof(logi), GFP_KERNEL);	l->fcmds = kmalloc (count * sizeof(fcp_cmnd), GFP_KERNEL);	if (!l->logi || !l->fcmds) {		if (l->logi) kfree (l->logi);		if (l->fcmds) kfree (l->fcmds);		kfree (l);		printk ("FC: Cannot allocate DMA memory for initialization\n");		return -ENOMEM;	}	memset (l->logi, 0, count * 3 * sizeof(logi));	memset (l->fcmds, 0, count * sizeof(fcp_cmnd));	for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) {		fc->state = FC_STATE_UNINITED;		fc->rst_pkt = NULL;	/* kmalloc when first used */	}	/* First try if we are in a AL topology */	FCND(("Initializing REPORT_MAP packets\n"))	for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) {		fcmd = l->fcmds + i;		fc->login = fcmd;		fc->ls = (void *)l;		/* Assumes sizeof(fc_al_posmap) < 3 * sizeof(logi), which is true */		fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi),					    DMA_BIDIRECTIONAL);		fcmd->proto = PROTO_REPORT_AL_MAP;		fcmd->token = i;		fcmd->fc = fc;	}	for (retry = 0; retry < 8; retry++) {		int nqueued = 0;		FCND(("Sending REPORT_MAP/FLOGI/PLOGI packets\n"))		for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) {			if (fc->state == FC_STATE_ONLINE || fc->state == FC_STATE_OFFLINE)				continue;			disable_irq(fc->irq);			if (fc->state == FC_STATE_MAYBEOFFLINE) {				if (!l->grace[i]) {					l->grace[i]++;					FCD(("Grace\n"))				} else {					fc->state = FC_STATE_OFFLINE;					enable_irq(fc->irq);					dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), DMA_BIDIRECTIONAL);					if (atomic_dec_and_test (&l->todo))						goto all_done;				}			}			ret = fc->hw_enque (fc, fc->login);			enable_irq(fc->irq);			if (!ret) {				nqueued++;				continue;			}			if (ret == -ENOSYS && fc->login->proto == PROTO_REPORT_AL_MAP) {				/* Oh yes, this card handles Point-to-Point only, so let's try that. */				fc_hdr *fch;				FCD(("SID %d DID %d\n", fc->sid, fc->did))				fcmd = l->fcmds + i;				dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi), DMA_BIDIRECTIONAL);				fch = &fcmd->fch;				FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, FS_FABRIC_F_PORT);				FILL_FCHDR_SID(fch, 0);				FILL_FCHDR_TYPE_FCTL(fch, TYPE_EXTENDED_LS, F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE);				FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0);				FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);				fch->param = 0;				l->logi [3 * i].code = LS_FLOGI;				fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi), DMA_BIDIRECTIONAL);				fcmd->rsp = fcmd->cmd + sizeof(logi);				fcmd->cmdlen = sizeof(logi);				fcmd->rsplen = sizeof(logi);				fcmd->data = (dma_addr_t)NULL;				fcmd->class = FC_CLASS_SIMPLE;				fcmd->proto = TYPE_EXTENDED_LS;			} else				printk ("FC: Cannot enque FLOGI/REPORT_MAP packet on %s\n", fc->name);		}				if (nqueued) {			l->timer.expires = jiffies + 5 * HZ;			add_timer(&l->timer);			down(&l->sem);			if (!atomic_read(&l->todo)) {				FCND(("All channels answered in time\n"))				break; /* All fc channels have answered us */			}		}	}all_done:	for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) {		fc->ls = NULL;		switch (fc->state) {		case FC_STATE_ONLINE: break;		case FC_STATE_OFFLINE: break;		default: dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), DMA_BIDIRECTIONAL);			break;		}	}	del_timer(&l->timer);	kfree (l->logi);	kfree (l->fcmds);	kfree (l);	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/49d0c6039dd36791cad36624e68bce5fe011bf12/fc.c/clean/drivers/fc4/fc.c