Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b9e4a73 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

Merge branch 'topic/cvt-dev-prints' into for-next

This merges the bunch of changes over pci and usb sound drivers to
convert to dev_err() and co.
parents e8b99a1d e3b3757b
Loading
Loading
Loading
Loading
+33 −12
Original line number Diff line number Diff line
@@ -214,6 +214,12 @@ static void update_power_regs(struct snd_ac97 *ac97);
#define ac97_is_power_save_mode(ac97) 0
#endif

#define ac97_err(ac97, fmt, args...)	\
	dev_err((ac97)->bus->card->dev, fmt, ##args)
#define ac97_warn(ac97, fmt, args...)	\
	dev_warn((ac97)->bus->card->dev, fmt, ##args)
#define ac97_dbg(ac97, fmt, args...)	\
	dev_dbg((ac97)->bus->card->dev, fmt, ##args)

/*
 *  I/O routines
@@ -1673,7 +1679,7 @@ static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97)
	int err, idx;

	/*
	printk(KERN_DEBUG "AC97_GPIO_CFG = %x\n",
	ac97_dbg(ac97, "AC97_GPIO_CFG = %x\n",
	       snd_ac97_read(ac97,AC97_GPIO_CFG));
	*/
	snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH));
@@ -1963,7 +1969,7 @@ static int snd_ac97_dev_register(struct snd_device *device)
		     ac97->bus->card->number, ac97->num,
		     snd_ac97_get_short_name(ac97));
	if ((err = device_register(&ac97->dev)) < 0) {
		snd_printk(KERN_ERR "Can't register ac97 bus\n");
		ac97_err(ac97, "Can't register ac97 bus\n");
		ac97->dev.bus = NULL;
		return err;
	}
@@ -2089,7 +2095,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
						      msecs_to_jiffies(500), 1);
		}
		if (err < 0) {
			snd_printk(KERN_WARNING "AC'97 %d does not respond - RESET\n", ac97->num);
			ac97_warn(ac97, "AC'97 %d does not respond - RESET\n",
				 ac97->num);
			/* proceed anyway - it's often non-critical */
		}
	}
@@ -2098,7 +2105,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
	ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2);
	if (! (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) &&
	    (ac97->id == 0x00000000 || ac97->id == 0xffffffff)) {
		snd_printk(KERN_ERR "AC'97 %d access is not valid [0x%x], removing mixer.\n", ac97->num, ac97->id);
		ac97_err(ac97,
			 "AC'97 %d access is not valid [0x%x], removing mixer.\n",
			 ac97->num, ac97->id);
		snd_ac97_free(ac97);
		return -EIO;
	}
@@ -2131,7 +2140,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,

	if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) {
		if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM)))
			snd_printk(KERN_ERR "AC'97 %d access error (not audio or modem codec)\n", ac97->num);
			ac97_err(ac97,
				 "AC'97 %d access error (not audio or modem codec)\n",
				 ac97->num);
		snd_ac97_free(ac97);
		return -EACCES;
	}
@@ -2156,7 +2167,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
				goto __ready_ok;
			schedule_timeout_uninterruptible(1);
		} while (time_after_eq(end_time, jiffies));
		snd_printk(KERN_WARNING "AC'97 %d analog subsections not ready\n", ac97->num);
		ac97_warn(ac97,
			  "AC'97 %d analog subsections not ready\n", ac97->num);
	}

	/* FIXME: add powerdown control */
@@ -2188,7 +2200,10 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
				goto __ready_ok;
			schedule_timeout_uninterruptible(1);
		} while (time_after_eq(end_time, jiffies));
		snd_printk(KERN_WARNING "MC'97 %d converters and GPIO not ready (0x%x)\n", ac97->num, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
		ac97_warn(ac97,
			  "MC'97 %d converters and GPIO not ready (0x%x)\n",
			  ac97->num,
			  snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
	}
	
      __ready_ok:
@@ -2723,7 +2738,7 @@ static int tune_ad_sharing(struct snd_ac97 *ac97)
{
	unsigned short scfg;
	if ((ac97->id & 0xffffff00) != 0x41445300) {
		snd_printk(KERN_ERR "ac97_quirk AD_SHARING is only for AD codecs\n");
		ac97_err(ac97, "ac97_quirk AD_SHARING is only for AD codecs\n");
		return -EINVAL;
	}
	/* Turn on OMS bit to route microphone to back panel */
@@ -2739,7 +2754,8 @@ AC97_SINGLE("Jack Detect", AC97_ALC650_CLOCK, 5, 1, 0);
static int tune_alc_jack(struct snd_ac97 *ac97)
{
	if ((ac97->id & 0xffffff00) != 0x414c4700) {
		snd_printk(KERN_ERR "ac97_quirk ALC_JACK is only for Realtek codecs\n");
		ac97_err(ac97,
			 "ac97_quirk ALC_JACK is only for Realtek codecs\n");
		return -EINVAL;
	}
	snd_ac97_update_bits(ac97, 0x7a, 0x20, 0x20); /* select jack detect function */
@@ -2899,7 +2915,8 @@ int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, cons
	if (override && strcmp(override, "-1") && strcmp(override, "default")) {
		result = apply_quirk_str(ac97, override);
		if (result < 0)
			snd_printk(KERN_ERR "applying quirk type %s failed (%d)\n", override, result);
			ac97_err(ac97, "applying quirk type %s failed (%d)\n",
				 override, result);
		return result;
	}

@@ -2913,10 +2930,14 @@ int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, cons
		    quirk->subdevice == (quirk->mask & ac97->subsystem_device)) {
			if (quirk->codec_id && quirk->codec_id != ac97->id)
				continue;
			snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device);
			ac97_dbg(ac97, "ac97 quirk for %s (%04x:%04x)\n",
				 quirk->name, ac97->subsystem_vendor,
				 ac97->subsystem_device);
			result = apply_quirk(ac97, quirk->type);
			if (result < 0)
				snd_printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result);
				ac97_err(ac97,
					 "applying quirk type %d for %s failed (%d)\n",
					 quirk->type, quirk->name, result);
			return result;
		}
	}
+2 −1
Original line number Diff line number Diff line
@@ -3477,7 +3477,8 @@ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,

		sctl = snd_ac97_find_mixer_ctl(ac97, *s);
		if (!sctl) {
			snd_printdd("Cannot find slave %s, skipped\n", *s);
			dev_dbg(ac97->bus->card->dev,
				"Cannot find slave %s, skipped\n", *s);
			continue;
		}
		err = snd_ctl_add_slave(kctl, sctl);
+11 −4
Original line number Diff line number Diff line
@@ -604,7 +604,9 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
		}
		if (!ok_flag) {
			spin_unlock_irq(&pcm->bus->bus_lock);
			snd_printk(KERN_ERR "cannot find configuration for AC97 slot %i\n", i);
			dev_err(bus->card->dev,
				"cannot find configuration for AC97 slot %i\n",
				i);
			err = -EAGAIN;
			goto error;
		}
@@ -618,15 +620,20 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
			if (pcm->r[r].rslots[cidx] & (1 << i)) {
				reg = get_slot_reg(pcm, cidx, i, r);
				if (reg == 0xff) {
					snd_printk(KERN_ERR "invalid AC97 slot %i?\n", i);
					dev_err(bus->card->dev,
						"invalid AC97 slot %i?\n", i);
					continue;
				}
				if (reg_ok[cidx] & (1 << (reg - AC97_PCM_FRONT_DAC_RATE)))
					continue;
				//printk(KERN_DEBUG "setting ac97 reg 0x%x to rate %d\n", reg, rate);
				dev_dbg(bus->card->dev,
					"setting ac97 reg 0x%x to rate %d\n",
					reg, rate);
				err = snd_ac97_set_rate(pcm->r[r].codec[cidx], reg, rate);
				if (err < 0)
					snd_printk(KERN_ERR "error in snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d, err=%d\n", cidx, reg, rate, err);
					dev_err(bus->card->dev,
						"error in snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d, err=%d\n",
						cidx, reg, rate, err);
				else
					reg_ok[cidx] |= (1 << (reg - AC97_PCM_FRONT_DAC_RATE));
			}
+15 −17
Original line number Diff line number Diff line
@@ -77,9 +77,6 @@ MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
#define DEVNAME "ad1889"
#define PFX	DEVNAME ": "

/* let's use the global sound debug interfaces */
#define ad1889_debug(fmt, arg...) snd_printd(KERN_DEBUG fmt, ## arg)

/* keep track of some hw registers */
struct ad1889_register_state {
	u16 reg;	/* reg setup */
@@ -264,11 +261,11 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip)
			&& --retry)
		mdelay(1);
	if (!retry) {
		snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n",
		dev_err(chip->card->dev, "[%s] Link is not ready.\n",
			__func__);
		return -EIO;
	}
	ad1889_debug("[%s] ready after %d ms\n", __func__, 400 - retry);
	dev_dbg(chip->card->dev, "[%s] ready after %d ms\n", __func__, 400 - retry);

	return 0;
}
@@ -405,9 +402,9 @@ snd_ad1889_playback_prepare(struct snd_pcm_substream *ss)
	
	spin_unlock_irq(&chip->lock);
	
	ad1889_debug("prepare playback: addr = 0x%x, count = %u, "
			"size = %u, reg = 0x%x, rate = %u\n", chip->wave.addr,
			count, size, reg, rt->rate);
	dev_dbg(chip->card->dev,
		"prepare playback: addr = 0x%x, count = %u, size = %u, reg = 0x%x, rate = %u\n",
		chip->wave.addr, count, size, reg, rt->rate);
	return 0;
}

@@ -452,9 +449,9 @@ snd_ad1889_capture_prepare(struct snd_pcm_substream *ss)
	
	spin_unlock_irq(&chip->lock);
	
	ad1889_debug("prepare capture: addr = 0x%x, count = %u, "
			"size = %u, reg = 0x%x, rate = %u\n", chip->ramc.addr,
			count, size, reg, rt->rate);
	dev_dbg(chip->card->dev,
		"prepare capture: addr = 0x%x, count = %u, size = %u, reg = 0x%x, rate = %u\n",
		chip->ramc.addr, count, size, reg, rt->rate);
	return 0;
}

@@ -614,7 +611,8 @@ snd_ad1889_interrupt(int irq, void *dev_id)
		return IRQ_NONE;

	if (st & (AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI))
		ad1889_debug("Unexpected master or target abort interrupt!\n");
		dev_dbg(chip->card->dev,
			"Unexpected master or target abort interrupt!\n");

	if ((st & AD_DMA_DISR_WAVI) && chip->psubs)
		snd_pcm_period_elapsed(chip->psubs);
@@ -656,7 +654,7 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm)
						BUFFER_BYTES_MAX);

	if (err < 0) {
		snd_printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
		dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
		return err;
	}
	
@@ -912,7 +910,7 @@ snd_ad1889_create(struct snd_card *card,
	/* check PCI availability (32bit DMA) */
	if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
	    pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
		printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n");
		dev_err(card->dev, "error setting 32-bit DMA mask.\n");
		pci_disable_device(pci);
		return -ENXIO;
	}
@@ -935,7 +933,7 @@ snd_ad1889_create(struct snd_card *card,
	chip->bar = pci_resource_start(pci, 0);
	chip->iobase = pci_ioremap_bar(pci, 0);
	if (chip->iobase == NULL) {
		printk(KERN_ERR PFX "unable to reserve region.\n");
		dev_err(card->dev, "unable to reserve region.\n");
		err = -EBUSY;
		goto free_and_ret;
	}
@@ -946,7 +944,7 @@ snd_ad1889_create(struct snd_card *card,

	if (request_irq(pci->irq, snd_ad1889_interrupt,
			IRQF_SHARED, KBUILD_MODNAME, chip)) {
		printk(KERN_ERR PFX "cannot obtain IRQ %d\n", pci->irq);
		dev_err(card->dev, "cannot obtain IRQ %d\n", pci->irq);
		snd_ad1889_free(chip);
		return -EBUSY;
	}
+68 −80
Original line number Diff line number Diff line
@@ -64,18 +64,6 @@ static bool enable;
module_param(enable, bool, 0444);


/*
 *  Debug part definitions
 */

/* #define ALI_DEBUG */

#ifdef ALI_DEBUG
#define snd_ali_printk(format, args...) printk(KERN_DEBUG format, ##args);
#else
#define snd_ali_printk(format, args...)
#endif

/*
 *  Constants definition
 */
@@ -321,7 +309,7 @@ static int snd_ali_codec_ready(struct snd_ali *codec,
	}

	snd_ali_5451_poke(codec, port, res & ~0x8000);
	snd_printdd("ali_codec_ready: codec is not ready.\n ");
	dev_dbg(codec->card->dev, "ali_codec_ready: codec is not ready.\n ");
	return -EIO;
}

@@ -342,7 +330,7 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
		schedule_timeout_uninterruptible(1);
	}

	snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n");
	dev_err(codec->card->dev, "ali_stimer_read: stimer is not ready.\n");
	return -EIO;
}

@@ -354,7 +342,8 @@ static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
	unsigned int port;

	if (reg >= 0x80) {
		snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg);
		dev_err(codec->card->dev,
			"ali_codec_poke: reg(%xh) invalid.\n", reg);
		return;
	}

@@ -385,7 +374,8 @@ static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
	unsigned int port;

	if (reg >= 0x80) {
		snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg);
		dev_err(codec->card->dev,
			"ali_codec_peek: reg(%xh) invalid.\n", reg);
		return ~0;
	}

@@ -417,7 +407,7 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
{
	struct snd_ali *codec = ac97->private_data;

	snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val);
	dev_dbg(codec->card->dev, "codec_write: reg=%xh data=%xh.\n", reg, val);
	if (reg == AC97_GPIO_STATUS) {
		outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE,
		     ALI_REG(codec, ALI_AC97_GPIO));
@@ -433,7 +423,7 @@ static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97,
{
	struct snd_ali *codec = ac97->private_data;

	snd_ali_printk("codec_read reg=%xh.\n", reg);
	dev_dbg(codec->card->dev, "codec_read reg=%xh.\n", reg);
	return snd_ali_codec_peek(codec, ac97->num, reg);
}

@@ -474,7 +464,7 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
	}

	/* non-fatal if you have a non PM capable codec */
	/* snd_printk(KERN_WARNING "ali5451: reset time out\n"); */
	/* dev_warn(codec->card->dev, "ali5451: reset time out\n"); */
	return 0;
}

@@ -528,7 +518,7 @@ static void snd_ali_disable_voice_irq(struct snd_ali *codec,
	unsigned int mask;
	struct snd_ali_channel_control *pchregs = &(codec->chregs);

	snd_ali_printk("disable_voice_irq channel=%d\n",channel);
	dev_dbg(codec->card->dev, "disable_voice_irq channel=%d\n", channel);

	mask = 1 << (channel & 0x1f);
	pchregs->data.ainten  = inl(ALI_REG(codec, pchregs->regs.ainten));
@@ -541,7 +531,7 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
	unsigned int idx =  channel & 0x1f;

	if (codec->synth.chcnt >= ALI_CHANNELS){
		snd_printk(KERN_ERR
		dev_err(codec->card->dev,
			   "ali_alloc_pcm_channel: no free channels.\n");
		return -1;
	}
@@ -549,7 +539,7 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
	if (!(codec->synth.chmap & (1 << idx))) {
		codec->synth.chmap |= 1 << idx;
		codec->synth.chcnt++;
		snd_ali_printk("alloc_pcm_channel no. %d.\n",idx);
		dev_dbg(codec->card->dev, "alloc_pcm_channel no. %d.\n", idx);
		return idx;
	}
	return -1;
@@ -560,7 +550,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
	int idx;
	int result = -1;

	snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm");
	dev_dbg(codec->card->dev,
		"find_free_channel: for %s\n", rec ? "rec" : "pcm");

	/* recording */
	if (rec) {
@@ -575,8 +566,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
		if (result >= 0)
			return result;
		else {
			snd_printk(KERN_ERR "ali_find_free_channel: "
				   "record channel is busy now.\n");
			dev_err(codec->card->dev,
				"ali_find_free_channel: record channel is busy now.\n");
			return -1;
		}
	}
@@ -590,8 +581,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
		if (result >= 0)
			return result;
		else
			snd_printk(KERN_ERR "ali_find_free_channel: "
				   "S/PDIF out channel is in busy now.\n");
			dev_err(codec->card->dev,
				"ali_find_free_channel: S/PDIF out channel is in busy now.\n");
	}

	for (idx = 0; idx < ALI_CHANNELS; idx++) {
@@ -599,7 +590,7 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
		if (result >= 0)
			return result;
	}
	snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n");
	dev_err(codec->card->dev, "ali_find_free_channel: no free channels.\n");
	return -1;
}

@@ -607,14 +598,15 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
{
	unsigned int idx = channel & 0x0000001f;

	snd_ali_printk("free_channel_pcm channel=%d\n",channel);
	dev_dbg(codec->card->dev, "free_channel_pcm channel=%d\n", channel);

	if (channel < 0 || channel >= ALI_CHANNELS)
		return;

	if (!(codec->synth.chmap & (1 << idx))) {
		snd_printk(KERN_ERR "ali_free_channel_pcm: "
			   "channel %d is not in use.\n", channel);
		dev_err(codec->card->dev,
			"ali_free_channel_pcm: channel %d is not in use.\n",
			channel);
		return;
	} else {
		codec->synth.chmap &= ~(1 << idx);
@@ -626,7 +618,7 @@ static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
{
	unsigned int mask = 1 << (channel & 0x1f);

	snd_ali_printk("stop_voice: channel=%d\n",channel);
	dev_dbg(codec->card->dev, "stop_voice: channel=%d\n", channel);
	outl(mask, ALI_REG(codec, codec->chregs.regs.stop));
}

@@ -667,7 +659,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
	}

	if (count > 50000) {
		snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n");
		dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
		return;
	}

@@ -682,7 +674,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
	}

	if (count > 50000) {
		snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n");
		dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
		return;
	}

@@ -857,9 +849,6 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
	struct snd_ali_voice *pvoice;
	struct snd_ali_channel_control *pchregs;
	unsigned int old, mask;
#ifdef ALI_DEBUG
	unsigned int temp, cspf;
#endif

	pchregs = &(codec->chregs);

@@ -877,14 +866,11 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel)

	if (pvoice->pcm && pvoice->substream) {
		/* pcm interrupt */
#ifdef ALI_DEBUG
		outb((u8)(pvoice->number), ALI_REG(codec, ALI_GC_CIR));
		temp = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
		cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
#endif
		if (pvoice->running) {
			snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",
				       (u16)temp, cspf);
			dev_dbg(codec->card->dev,
				"update_ptr: cso=%4.4x cspf=%d.\n",
				inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)),
				(inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask);
			spin_unlock(&codec->reg_lock);
			snd_pcm_period_elapsed(pvoice->substream);
			spin_lock(&codec->reg_lock);
@@ -940,14 +926,14 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
	struct snd_ali_voice *pvoice;
	int idx;

	snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec);
	dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec);

	spin_lock_irq(&codec->voice_alloc);
	if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
		idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
			snd_ali_find_free_channel(codec,rec);
		if (idx < 0) {
			snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
			dev_err(codec->card->dev, "ali_alloc_voice: err.\n");
			spin_unlock_irq(&codec->voice_alloc);
			return NULL;
		}
@@ -970,7 +956,7 @@ static void snd_ali_free_voice(struct snd_ali * codec,
	void (*private_free)(void *);
	void *private_data;

	snd_ali_printk("free_voice: channel=%d\n",pvoice->number);
	dev_dbg(codec->card->dev, "free_voice: channel=%d\n", pvoice->number);
	if (!pvoice->use)
		return;
	snd_ali_clear_voices(codec, pvoice->number, pvoice->number);
@@ -1153,7 +1139,7 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
	outl(val, ALI_REG(codec, ALI_AINTEN));
	if (do_start)
		outl(what, ALI_REG(codec, ALI_START));
	snd_ali_printk("trigger: what=%xh whati=%xh\n", what, whati);
	dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati);
	spin_unlock(&codec->reg_lock);

	return 0;
@@ -1239,7 +1225,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
	unsigned int VOL;
	unsigned int EC;
	
	snd_ali_printk("playback_prepare ...\n");
	dev_dbg(codec->card->dev, "playback_prepare ...\n");

	spin_lock_irq(&codec->reg_lock);	
	
@@ -1266,7 +1252,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
	/* set target ESO for channel */
	pvoice->eso = runtime->buffer_size; 

	snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",
	dev_dbg(codec->card->dev, "playback_prepare: eso=%xh count=%xh\n",
		       pvoice->eso, pvoice->count);

	/* set ESO to capture first MIDLP interrupt */
@@ -1278,8 +1264,9 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
	PAN = 0;
	VOL = 0;
	EC = 0;
	snd_ali_printk("playback_prepare:\n");
	snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
	dev_dbg(codec->card->dev, "playback_prepare:\n");
	dev_dbg(codec->card->dev,
		"ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
		       pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
	snd_ali_write_voice_regs(codec,
				 pvoice->number,
@@ -1332,7 +1319,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)

	spin_lock_irq(&codec->reg_lock);

	snd_ali_printk("ali_prepare...\n");
	dev_dbg(codec->card->dev, "ali_prepare...\n");

	snd_ali_enable_special_channel(codec,pvoice->number);

@@ -1351,15 +1338,16 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)

		rate = snd_ali_get_spdif_in_rate(codec);
		if (rate == 0) {
			snd_printk(KERN_WARNING "ali_capture_preapre: "
				   "spdif rate detect err!\n");
			dev_warn(codec->card->dev,
				 "ali_capture_preapre: spdif rate detect err!\n");
			rate = 48000;
		}
		spin_lock_irq(&codec->reg_lock);
		bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL));
		if (bValue & 0x10) {
			outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL));
			printk(KERN_WARNING "clear SPDIF parity error flag.\n");
			dev_warn(codec->card->dev,
				 "clear SPDIF parity error flag.\n");
		}

		if (rate != 48000)
@@ -1418,7 +1406,7 @@ snd_ali_playback_pointer(struct snd_pcm_substream *substream)
	outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
	cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
	spin_unlock(&codec->reg_lock);
	snd_ali_printk("playback pointer returned cso=%xh.\n", cso);
	dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso);

	return cso;
}
@@ -1685,7 +1673,8 @@ static int snd_ali_pcm(struct snd_ali *codec, int device,
	err = snd_pcm_new(codec->card, desc->name, device,
			  desc->playback_num, desc->capture_num, &pcm);
	if (err < 0) {
		snd_printk(KERN_ERR "snd_ali_pcm: err called snd_pcm_new.\n");
		dev_err(codec->card->dev,
			"snd_ali_pcm: err called snd_pcm_new.\n");
		return err;
	}
	pcm->private_data = codec;
@@ -1861,7 +1850,7 @@ static int snd_ali_mixer(struct snd_ali *codec)
		ac97.num = i;
		err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
		if (err < 0) {
			snd_printk(KERN_ERR
			dev_err(codec->card->dev,
				   "ali mixer %d creating error.\n", i);
			if (i == 0)
				return err;
@@ -1947,8 +1936,7 @@ static int ali_resume(struct device *dev)
	pci_set_power_state(pci, PCI_D0);
	pci_restore_state(pci);
	if (pci_enable_device(pci) < 0) {
		printk(KERN_ERR "ali5451: pci_enable_device failed, "
		       "disabling device\n");
		dev_err(dev, "pci_enable_device failed, disabling device\n");
		snd_card_disconnect(card);
		return -EIO;
	}
@@ -2013,10 +2001,10 @@ static int snd_ali_chip_init(struct snd_ali *codec)
	unsigned char temp;
	struct pci_dev *pci_dev;

	snd_ali_printk("chip initializing ... \n");
	dev_dbg(codec->card->dev, "chip initializing ...\n");

	if (snd_ali_reset_5451(codec)) {
		snd_printk(KERN_ERR "ali_chip_init: reset 5451 error.\n");
		dev_err(codec->card->dev, "ali_chip_init: reset 5451 error.\n");
		return -1;
	}

@@ -2062,7 +2050,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
		     ALI_REG(codec, ALI_SCTRL));
	}

	snd_ali_printk("chip initialize succeed.\n");
	dev_dbg(codec->card->dev, "chip initialize succeed.\n");
	return 0;

}
@@ -2088,7 +2076,7 @@ static int snd_ali_resources(struct snd_ali *codec)
{
	int err;

	snd_ali_printk("resources allocation ...\n");
	dev_dbg(codec->card->dev, "resources allocation ...\n");
	err = pci_request_regions(codec->pci, "ALI 5451");
	if (err < 0)
		return err;
@@ -2096,11 +2084,11 @@ static int snd_ali_resources(struct snd_ali *codec)

	if (request_irq(codec->pci->irq, snd_ali_card_interrupt,
			IRQF_SHARED, KBUILD_MODNAME, codec)) {
		snd_printk(KERN_ERR "Unable to request irq.\n");
		dev_err(codec->card->dev, "Unable to request irq.\n");
		return -EBUSY;
	}
	codec->irq = codec->pci->irq;
	snd_ali_printk("resources allocated.\n");
	dev_dbg(codec->card->dev, "resources allocated.\n");
	return 0;
}
static int snd_ali_dev_free(struct snd_device *device)
@@ -2125,7 +2113,7 @@ static int snd_ali_create(struct snd_card *card,

	*r_ali = NULL;

	snd_ali_printk("creating ...\n");
	dev_dbg(card->dev, "creating ...\n");

	/* enable PCI device */
	err = pci_enable_device(pci);
@@ -2134,8 +2122,8 @@ static int snd_ali_create(struct snd_card *card,
	/* check, if we can restrict PCI DMA transfers to 31 bits */
	if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 ||
	    pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) {
		snd_printk(KERN_ERR "architecture does not support "
			   "31bit PCI busmaster DMA\n");
		dev_err(card->dev,
			"architecture does not support 31bit PCI busmaster DMA\n");
		pci_disable_device(pci);
		return -ENXIO;
	}
@@ -2199,19 +2187,19 @@ static int snd_ali_create(struct snd_card *card,
	/* M1533: southbridge */
	codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
	if (!codec->pci_m1533) {
		snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
		dev_err(card->dev, "cannot find ALi 1533 chip.\n");
		snd_ali_free(codec);
		return -ENODEV;
	}
	/* M7101: power management */
	codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
	if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
		snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
		dev_err(card->dev, "cannot find ALi 7101 chip.\n");
		snd_ali_free(codec);
		return -ENODEV;
	}

	snd_ali_printk("snd_device_new is called.\n");
	dev_dbg(card->dev, "snd_device_new is called.\n");
	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
	if (err < 0) {
		snd_ali_free(codec);
@@ -2224,21 +2212,21 @@ static int snd_ali_create(struct snd_card *card,

	err = snd_ali_chip_init(codec);
	if (err < 0) {
		snd_printk(KERN_ERR "ali create: chip init error.\n");
		dev_err(card->dev, "ali create: chip init error.\n");
		return err;
	}

#ifdef CONFIG_PM_SLEEP
	codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
	if (!codec->image)
		snd_printk(KERN_WARNING "can't allocate apm buffer\n");
		dev_warn(card->dev, "can't allocate apm buffer\n");
#endif

	snd_ali_enable_address_interrupt(codec);
	codec->hw_initialized = 1;

	*r_ali = codec;
	snd_ali_printk("created.\n");
	dev_dbg(card->dev, "created.\n");
	return 0;
}

@@ -2249,7 +2237,7 @@ static int snd_ali_probe(struct pci_dev *pci,
	struct snd_ali *codec;
	int err;

	snd_ali_printk("probe ...\n");
	dev_dbg(&pci->dev, "probe ...\n");

	err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
	if (err < 0)
@@ -2260,12 +2248,12 @@ static int snd_ali_probe(struct pci_dev *pci,
		goto error;
	card->private_data = codec;

	snd_ali_printk("mixer building ...\n");
	dev_dbg(&pci->dev, "mixer building ...\n");
	err = snd_ali_mixer(codec);
	if (err < 0)
		goto error;
	
	snd_ali_printk("pcm building ...\n");
	dev_dbg(&pci->dev, "pcm building ...\n");
	err = snd_ali_build_pcms(codec);
	if (err < 0)
		goto error;
@@ -2278,7 +2266,7 @@ static int snd_ali_probe(struct pci_dev *pci,
	sprintf(card->longname, "%s at 0x%lx, irq %i",
		card->shortname, codec->port, codec->irq);

	snd_ali_printk("register card.\n");
	dev_dbg(&pci->dev, "register card.\n");
	err = snd_card_register(card);
	if (err < 0)
		goto error;
Loading