ac97_codec.c bit update mask fix
/**
* snd_ac97_update_bits - update the bits on the given register
* @ac97: the ac97 instance
* @reg: the register to change
* @mask: the bit-mask to change
* @value: the value to set
*
* Updates the masked-bits on the given register only when the value
* is changed.
*
* Returns 1 if the bits are changed, 0 if no change, or a negative
* code on failure.
*/
If the intent is to update _only_ the bits given in the mask, as the comment seems to suggest, then the current code won't do it.
Specifically, it'll clobber unset bits that are _not_ in the mask, if the new bit is set. Here's a fix:
pci/ac97/ac97_codec.c Fri Dec 1 02:04:30 2006 -0500 renamed from pci/ac97/ac97_codec.c Wed Nov 29 15:29:40 2006 +0100 +2 -2
@@ -389,7 +389,7 @@ int snd_ac97_update_bits_nolock(struct s unsigned short old, new; old = snd_ac97_read_cache(ac97, reg); - new = (old & ~mask) | value; + new = (old & ~mask) | (value & mask); change = old != new; if (change) { ac97->regs[reg] = new;
@@ -406,7 +406,7 @@ static int snd_ac97_ad18xx_update_pcm_bi mutex_lock(&ac97->page_mutex); old = ac97->spec.ad18xx.pcmreg[codec]; - new = (old & ~mask) | value; + new = (old & ~mask) | (value & mask); change = old != new; if (change) { mutex_lock(&ac97->reg_mutex);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 34 lines · James C Georgas
/**
*snd_ac97_update_bits- update the bits on the given register
* @ac97: the ac97 instance
* @reg: the register to change
* @mask: the bit-mask to change
* @value: the value to set
*
* Updates the masked-bits on the given register only when the value
* is changed.
*
* Returns 1 if the bits are changed, 0 if no change, or a negative
* code on failure.
*/If the intent is to update _only_ the bits given in the mask, as the comment seems to suggest, then the current code won't do it.
Specifically, it'll clobber unset bits that are _not_ in the mask, if the new bit is set. Here's a fix:
diff -r
bc7ef767d0cfpci/ac97/ac97_codec.cpci/ac97/ac97_codec.c Fri Dec 1 02:04:30 2006 -0500 renamed from pci/ac97/ac97_codec.c Wed Nov 29 15:29:40 2006 +0100 +1
-1@@ -389,7 +389,7 @@ int snd_ac97_update_bits_nolock(struct s unsigned short old, new; old = snd_ac97_read_cache(ac97, reg); - new = (old & ~mask) | value; + new = (old & ~mask) | (value & mask); change = old != new; if (change) { ac97->regs[reg] = new;
pci/ac97/ac97_codec.c Fri Dec 1 02:04:30 2006 -0500 static int snd_ac97_ad18xx_update_pcm_bi · line 412
Quoted 8 lines
pci/ac97/ac97_codec.c Fri Dec 1 02:04:30 2006 -0500 renamed from pci/ac97/ac97_codec.c Wed Nov 29 15:29:40 2006 +0100 +1
-1@@ -406,7 +406,7 @@ static int snd_ac97_ad18xx_update_pcm_bi mutex_lock(&ac97->page_mutex); old = ac97->spec.ad18xx.pcmreg[codec]; - new = (old & ~mask) | value; + new = (old & ~mask) | (value & mask); change = old != new; if (change) { mutex_lock(&ac97->reg_mutex);
bump...
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV