if (chip->position_fix == POS_FIX_POSBUF) { /* allocate memory for the position buffer */ if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), chip->num_streams * 8, &chip->posbuf)) < 0) { snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); goto errout; } 
/* allocate memory for the position buffer */ if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), chip->num_streams * 8, &chip->posbuf)) < 0) { snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); goto errout; 
static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,				int posfix, int driver_type,				azx_t **rchip){	azx_t *chip;	int err = 0;	static snd_device_ops_t ops = {		.dev_free = azx_dev_free,	};	*rchip = NULL;		if ((err = pci_enable_device(pci)) < 0)		return err;	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);		if (NULL == chip) {		snd_printk(KERN_ERR SFX "cannot allocate chip\n");		pci_disable_device(pci);		return -ENOMEM;	}	spin_lock_init(&chip->reg_lock);	init_MUTEX(&chip->open_mutex);	chip->card = card;	chip->pci = pci;	chip->irq = -1;	chip->driver_type = driver_type;	chip->position_fix = posfix;#if BITS_PER_LONG != 64	/* Fix up base address on ULI M5461 */	if (chip->driver_type == AZX_DRIVER_ULI) {		u16 tmp3;		pci_read_config_word(pci, 0x40, &tmp3);		pci_write_config_word(pci, 0x40, tmp3 | 0x10);		pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);	}#endif	if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) {		kfree(chip);		pci_disable_device(pci);		return err;	}	chip->addr = pci_resource_start(pci,0);	chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci,0));	if (chip->remap_addr == NULL) {		snd_printk(KERN_ERR SFX "ioremap error\n");		err = -ENXIO;		goto errout;	}	if (request_irq(pci->irq, azx_interrupt, SA_INTERRUPT|SA_SHIRQ,			"HDA Intel", (void*)chip)) {		snd_printk(KERN_ERR SFX "unable to grab IRQ %d\n", pci->irq);		err = -EBUSY;		goto errout;	}	chip->irq = pci->irq;	pci_set_master(pci);	synchronize_irq(chip->irq);	switch (chip->driver_type) {	case AZX_DRIVER_ULI:		chip->playback_streams = ULI_NUM_PLAYBACK;		chip->capture_streams = ULI_NUM_CAPTURE;		chip->playback_index_offset = ULI_PLAYBACK_INDEX;		chip->capture_index_offset = ULI_CAPTURE_INDEX;		break;	default:		chip->playback_streams = ICH6_NUM_PLAYBACK;		chip->capture_streams = ICH6_NUM_CAPTURE;		chip->playback_index_offset = ICH6_PLAYBACK_INDEX;		chip->capture_index_offset = ICH6_CAPTURE_INDEX;		break;	}	chip->num_streams = chip->playback_streams + chip->capture_streams;	chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL);	if (! chip->azx_dev) {		snd_printk(KERN_ERR "cannot malloc azx_dev\n");		goto errout;	}	/* allocate memory for the BDL for each stream */	if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),				       BDL_SIZE, &chip->bdl)) < 0) {		snd_printk(KERN_ERR SFX "cannot allocate BDL\n");		goto errout;	}	if (chip->position_fix == POS_FIX_POSBUF) {		/* allocate memory for the position buffer */		if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),					       chip->num_streams * 8, &chip->posbuf)) < 0) {			snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");			goto errout;		}	}	/* allocate CORB/RIRB */	if ((err = azx_alloc_cmd_io(chip)) < 0)		goto errout;	/* initialize streams */	azx_init_stream(chip);	/* initialize chip */	azx_init_chip(chip);	chip->initialized = 1;	/* codec detection */	if (! chip->codec_mask) {		snd_printk(KERN_ERR SFX "no codecs found!\n");		err = -ENODEV;		goto errout;	}	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) <0) {		snd_printk(KERN_ERR SFX "Error creating device [card]!\n");		goto errout;	}	strcpy(card->driver, "HDA-Intel");	strcpy(card->shortname, driver_short_names[chip->driver_type]);	sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq);	*rchip = chip;	return 0; errout:	azx_free(chip);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0be3b5d3fb94c36c517655d18a936681d7108667/hda_intel.c/clean/sound/pci/hda/hda_intel.c