ASoC: au1x: psc-ac97: verify correct codec register was read
authorManuel Lauss <manuel.lauss@googlemail.com>
Mon, 19 Oct 2009 14:10:58 +0000 (16:10 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 19 Oct 2009 15:12:30 +0000 (16:12 +0100)
Verify that the correct register has been received from the codec.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/au1x/psc-ac97.c

index a521aa90ddee4ae05e7e8d3d8cfd96a7e360ffef..efe2afd4fe24ba60e1c87ce34369d9e1508dee57 100644 (file)
@@ -61,7 +61,8 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
 {
        /* FIXME */
        struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
-       unsigned short data, retry, tmo;
+       unsigned short retry, tmo;
+       unsigned long data;
 
        au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
        au_sync();
@@ -79,15 +80,19 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
                        && --tmo)
                        udelay(2);
 
-               data = au_readl(AC97_CDC(pscdata)) & 0xffff;
+               data = au_readl(AC97_CDC(pscdata));
 
                au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
                au_sync();
 
                mutex_unlock(&pscdata->lock);
+
+               if (reg != ((data >> 16) & 0x7f))
+                       tmo = 1;        /* wrong register, try again */
+
        } while (--retry && !tmo);
 
-       return retry ? data : 0xffff;
+       return retry ? data & 0xffff : 0xffff;
 }
 
 /* AC97 controller writes to codec register */