/* It's hard to assign blame to either the controller or the codec because both were made by C-Media ...  */
void oxygen_write_ac97(struct oxygen *chip, unsigned int codec, unsigned int index, u16 data)
/* It's hard to assign blame to either the controller or the codec because both were made by C-Media ...  */
void oxygen_write_ac97(struct oxygen *chip, unsigned int codec, unsigned int index, u16 data)
{
	unsigned int count, succeeded;
	u32 reg;
	reg = data;
	reg |= index << OXYGEN_AC97_REG_ADDR_SHIFT;
	reg |= OXYGEN_AC97_REG_DIR_WRITE;
	reg |= codec << OXYGEN_AC97_REG_CODEC_SHIFT;
	succeeded = 0;
	for (count = 5; count > 0; --count) {
		udelay(5);
		oxygen_write32(chip, OXYGEN_AC97_REGS, reg);
		if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_WRITE_DONE) >= 0 &&
		    ++succeeded >= 2) {
			chip->saved_ac97_registers[codec][index / 2] = data;
			return;
		}
	}
	snd_printk(KERN_ERR "AC'97 write timeout\n");
}