d->num_desc, d->buf_size, d->frame_size, d->nb_cmd); 
d->num_desc - 1, d->buf_size, d->frame_size, d->nb_cmd); 
alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,		  int buf_size, int channel, unsigned int packet_size){	struct dma_iso_ctx *d;	int i;	d = kmalloc(sizeof(struct dma_iso_ctx), GFP_KERNEL);	if (d == NULL) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx");		return NULL;	}	memset(d, 0, sizeof *d);	d->ohci = ohci;	d->type = type;	d->channel = channel;	d->num_desc = num_desc;	d->frame_size = buf_size;	d->buf_size = PAGE_ALIGN(buf_size);	d->last_buffer = -1;	INIT_LIST_HEAD(&d->link);	init_waitqueue_head(&d->waitq);	/* Init the regions for easy cleanup */	dma_region_init(&d->dma);	if (dma_region_alloc(&d->dma, d->num_desc * d->buf_size, ohci->dev,			     PCI_DMA_BIDIRECTIONAL)) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma buffer");		free_dma_iso_ctx(d);		return NULL;	}	if (type == OHCI_ISO_RECEIVE)		ohci1394_init_iso_tasklet(&d->iso_tasklet, type,					  wakeup_dma_ir_ctx,					  (unsigned long) d);	else		ohci1394_init_iso_tasklet(&d->iso_tasklet, type,					  wakeup_dma_it_ctx,					  (unsigned long) d);	if (ohci1394_register_iso_tasklet(ohci, &d->iso_tasklet) < 0) {		PRINT(KERN_ERR, ohci->host->id, "no free iso %s contexts",		      type == OHCI_ISO_RECEIVE ? "receive" : "transmit");		free_dma_iso_ctx(d);		return NULL;	}	d->ctx = d->iso_tasklet.context;	d->prg_reg = kmalloc(d->num_desc * sizeof(struct dma_prog_region),			GFP_KERNEL);	if (d->prg_reg == NULL) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs");		free_dma_iso_ctx(d);		return NULL;	}	/* Makes for easier cleanup */	for (i = 0; i < d->num_desc; i++)		dma_prog_region_init(&d->prg_reg[i]);	if (type == OHCI_ISO_RECEIVE) {		d->ctrlSet = OHCI1394_IsoRcvContextControlSet+32*d->ctx;		d->ctrlClear = OHCI1394_IsoRcvContextControlClear+32*d->ctx;		d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx;		d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx;		d->ir_prg = kmalloc(d->num_desc * sizeof(struct dma_cmd *),				    GFP_KERNEL);		if (d->ir_prg == NULL) {			PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg");			free_dma_iso_ctx(d);			return NULL;		}		memset(d->ir_prg, 0, d->num_desc * sizeof(struct dma_cmd *));		d->nb_cmd = d->buf_size / PAGE_SIZE + 1;		d->left_size = (d->frame_size % PAGE_SIZE) ?			d->frame_size % PAGE_SIZE : PAGE_SIZE;		for (i = 0;i < d->num_desc; i++) {			if (dma_prog_region_alloc(&d->prg_reg[i], d->nb_cmd *						  sizeof(struct dma_cmd), ohci->dev)) {				PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg");				free_dma_iso_ctx(d);				return NULL;			}			d->ir_prg[i] = (struct dma_cmd *)d->prg_reg[i].kvirt;		}	} else {  /* OHCI_ISO_TRANSMIT */		d->ctrlSet = OHCI1394_IsoXmitContextControlSet+16*d->ctx;		d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx;		d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx;		d->it_prg = kmalloc(d->num_desc * sizeof(struct it_dma_prg *),				    GFP_KERNEL);		if (d->it_prg == NULL) {			PRINT(KERN_ERR, ohci->host->id,			      "Failed to allocate dma it prg");			free_dma_iso_ctx(d);			return NULL;		}		memset(d->it_prg, 0, d->num_desc*sizeof(struct it_dma_prg *));		d->packet_size = packet_size;		if (PAGE_SIZE % packet_size || packet_size>4096) {			PRINT(KERN_ERR, ohci->host->id,			      "Packet size %d (page_size: %ld) "			      "not yet supported\n",			      packet_size, PAGE_SIZE);			free_dma_iso_ctx(d);			return NULL;		}		d->nb_cmd = d->frame_size / d->packet_size;		if (d->frame_size % d->packet_size) {			d->nb_cmd++;			d->left_size = d->frame_size % d->packet_size;		} else			d->left_size = d->packet_size;		for (i = 0; i < d->num_desc; i++) {			if (dma_prog_region_alloc(&d->prg_reg[i], d->nb_cmd *						sizeof(struct it_dma_prg), ohci->dev)) {				PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma it prg");				free_dma_iso_ctx(d);				return NULL;			}			d->it_prg[i] = (struct it_dma_prg *)d->prg_reg[i].kvirt;		}	}	d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int),				   GFP_KERNEL);	d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval),				   GFP_KERNEL);	d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int),				   GFP_KERNEL);	d->next_buffer = kmalloc(d->num_desc * sizeof(int),				 GFP_KERNEL);	if (d->buffer_status == NULL) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_status");		free_dma_iso_ctx(d);		return NULL;	}	if (d->buffer_time == NULL) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time");		free_dma_iso_ctx(d);		return NULL;	}	if (d->last_used_cmd == NULL) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate last_used_cmd");		free_dma_iso_ctx(d);		return NULL;	}	if (d->next_buffer == NULL) {		PRINT(KERN_ERR, ohci->host->id, "Failed to allocate next_buffer");		free_dma_iso_ctx(d);		return NULL;	}	memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int));	memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval));	memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int));	memset(d->next_buffer, -1, d->num_desc * sizeof(int));        spin_lock_init(&d->lock);	PRINT(KERN_INFO, ohci->host->id, "Iso %s DMA: %d buffers "	      "of size %d allocated for a frame size %d, each with %d prgs",	      (type == OHCI_ISO_RECEIVE) ? "receive" : "transmit",	      d->num_desc, d->buf_size, d->frame_size, d->nb_cmd);	return d;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/8d98c5cd41d1932bb76a3945b4e8dea889224d87/video1394.c/clean/drivers/ieee1394/video1394.c