snd_printk("unable to grab IRQ %d\n", pci->irq); 
snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 
static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,				       int dev, cmipci_t **rcmipci){	cmipci_t *cm;	int err;	static snd_device_ops_t ops = {		.dev_free =	snd_cmipci_dev_free,	};	unsigned int val = 0;	long iomidi;	int integrated_midi;	int pcm_index, pcm_spdif_index;	static struct pci_device_id intel_82437vx[] = {		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) },		{ },	};	*rcmipci = NULL;	if ((err = pci_enable_device(pci)) < 0)		return err;	cm = kzalloc(sizeof(*cm), GFP_KERNEL);	if (cm == NULL) {		pci_disable_device(pci);		return -ENOMEM;	}	spin_lock_init(&cm->reg_lock);	init_MUTEX(&cm->open_mutex);	cm->device = pci->device;	cm->card = card;	cm->pci = pci;	cm->irq = -1;	cm->channel[0].ch = 0;	cm->channel[1].ch = 1;	cm->channel[0].is_dac = cm->channel[1].is_dac = 1; /* dual DAC mode */	if ((err = pci_request_regions(pci, card->driver)) < 0) {		kfree(cm);		pci_disable_device(pci);		return err;	}	cm->iobase = pci_resource_start(pci, 0);	if (request_irq(pci->irq, snd_cmipci_interrupt, SA_INTERRUPT|SA_SHIRQ, card->driver, (void *)cm)) {		snd_printk("unable to grab IRQ %d\n", pci->irq);		snd_cmipci_free(cm);		return -EBUSY;	}	cm->irq = pci->irq;	pci_set_master(cm->pci);	/*	 * check chip version, max channels and capabilities	 */	cm->chip_version = 0;	cm->max_channels = 2;	cm->do_soft_ac3 = soft_ac3[dev];	if (pci->device != PCI_DEVICE_ID_CMEDIA_CM8338A &&	    pci->device != PCI_DEVICE_ID_CMEDIA_CM8338B)		query_chip(cm);	/* added -MCx suffix for chip supporting multi-channels */	if (cm->can_multi_ch)		sprintf(cm->card->driver + strlen(cm->card->driver),			"-MC%d", cm->max_channels);	else if (cm->can_ac3_sw)		strcpy(cm->card->driver + strlen(cm->card->driver), "-SWIEC");	cm->dig_status = SNDRV_PCM_DEFAULT_CON_SPDIF;	cm->dig_pcm_status = SNDRV_PCM_DEFAULT_CON_SPDIF;#if CM_CH_PLAY == 1	cm->ctrl = CM_CHADC0;	/* default FUNCNTRL0 */#else	cm->ctrl = CM_CHADC1;	/* default FUNCNTRL0 */#endif	/* initialize codec registers */	snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0);	/* disable ints */	snd_cmipci_ch_reset(cm, CM_CH_PLAY);	snd_cmipci_ch_reset(cm, CM_CH_CAPT);	snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0);	/* disable channels */	snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0);	snd_cmipci_write(cm, CM_REG_CHFORMAT, 0);	snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC|CM_N4SPK3D);#if CM_CH_PLAY == 1	snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC);#else	snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC);#endif	/* Set Bus Master Request */	snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_BREQ);	/* Assume TX and compatible chip set (Autodetection required for VX chip sets) */	switch (pci->device) {	case PCI_DEVICE_ID_CMEDIA_CM8738:	case PCI_DEVICE_ID_CMEDIA_CM8738B:		if (!pci_dev_present(intel_82437vx)) 			snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_TXVX);		break;	default:		break;	}	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops)) < 0) {		snd_cmipci_free(cm);		return err;	}	integrated_midi = snd_cmipci_read_b(cm, CM_REG_MPU_PCI) != 0xff;	if (integrated_midi)		iomidi = cm->iobase + CM_REG_MPU_PCI;	else {		iomidi = mpu_port[dev];		switch (iomidi) {		case 0x320: val = CM_VMPU_320; break;		case 0x310: val = CM_VMPU_310; break;		case 0x300: val = CM_VMPU_300; break;		case 0x330: val = CM_VMPU_330; break;		default:			    iomidi = 0; break;		}		if (iomidi > 0) {			snd_cmipci_write(cm, CM_REG_LEGACY_CTRL, val);			/* enable UART */			snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN);		}	}	if ((err = snd_cmipci_create_fm(cm, fm_port[dev])) < 0)		return err;	/* reset mixer */	snd_cmipci_mixer_write(cm, 0, 0);	snd_cmipci_proc_init(cm);	/* create pcm devices */	pcm_index = pcm_spdif_index = 0;	if ((err = snd_cmipci_pcm_new(cm, pcm_index)) < 0)		return err;	pcm_index++;	if (cm->has_dual_dac) {		if ((err = snd_cmipci_pcm2_new(cm, pcm_index)) < 0)			return err;		pcm_index++;	}	if (cm->can_ac3_hw || cm->can_ac3_sw) {		pcm_spdif_index = pcm_index;		if ((err = snd_cmipci_pcm_spdif_new(cm, pcm_index)) < 0)			return err;	}	/* create mixer interface & switches */	if ((err = snd_cmipci_mixer_new(cm, pcm_spdif_index)) < 0)		return err;	if (iomidi > 0) {		if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,					       iomidi, integrated_midi,					       cm->irq, 0, &cm->rmidi)) < 0) {			printk(KERN_ERR "cmipci: no UART401 device at 0x%lx\n", iomidi);		}	}#ifdef USE_VAR48KRATE	for (val = 0; val < ARRAY_SIZE(rates); val++)		snd_cmipci_set_pll(cm, rates[val], val);	/*	 * (Re-)Enable external switch spdo_48k	 */	snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K|CM_SPDF_AC97);#endif /* USE_VAR48KRATE */	if (snd_cmipci_create_gameport(cm, dev) < 0)		snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);	snd_card_set_dev(card, &pci->dev);	*rcmipci = cm;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/99b359ba10a582148c6725f428a33ba5356dd993/cmipci.c/buggy/sound/pci/cmipci.c