[ALSA] ac97_codec - trivial fix for bit update functions
authorJames C Georgas <jgeorgas@rogers.com>
Thu, 7 Dec 2006 07:10:57 +0000 (08:10 +0100)
committerJaroslav Kysela <perex@server.perex.cz>
Wed, 20 Dec 2006 07:56:10 +0000 (08:56 +0100)
This patch fixes a couple of bit update functions in
alsa-kernel/pci/ac97/ac97_codec.c, which could possibly corrupt bits not
in the given mask.
Specifically, it'll clobber unset bits in the target that are not in the
mask, when the corresponding bit in the given new value is set.

Signed-off-by: James C Georgas <jgeorgas@rogers.com>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/pci/ac97/ac97_codec.c

index 7abcb10b2754c01b5c156006ff92504c2c75134b..91d8ceb4e9c22f0db28481ee2b4ab7539b86b9d9 100644 (file)
@@ -382,7 +382,7 @@ int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
        unsigned short old, new;
 
        old = snd_ac97_read_cache(ac97, reg);
        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;
        change = old != new;
        if (change) {
                ac97->regs[reg] = new;
@@ -399,7 +399,7 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
 
        mutex_lock(&ac97->page_mutex);
        old = ac97->spec.ad18xx.pcmreg[codec];
 
        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);
        change = old != new;
        if (change) {
                mutex_lock(&ac97->reg_mutex);