Skip to content

Commit

Permalink
ASoC: codecs: max98088: Fix register cache incoherency
Browse files Browse the repository at this point in the history
The multi-component patch(commit f0fba2a) moved the allocation of the
register cache from the driver to the ASoC core. Most drivers where adjusted to
this, but the max98088 driver still uses its own register cache for its
private functions, while functions from the ASoC core use the generic cache.
Thus we end up with two from each other incoherent caches, which can lead to
undefined behaviour.
This patch fixes the issue by changing the max98088 driver to use the
generic register cache in its private functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Hsiang <Peter.Hsiang@maxim-ic.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@kernel.org (for 2.6.37 only)
  • Loading branch information
Lars-Peter Clausen authored and Mark Brown committed Dec 28, 2010
1 parent 7f984b5 commit d24eb0d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sound/soc/codecs/max98088.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct max98088_cdata {
};

struct max98088_priv {
u8 reg_cache[M98088_REG_CNT];
enum max98088_type devtype;
void *control_data;
struct max98088_pdata *pdata;
Expand Down Expand Up @@ -1588,7 +1587,7 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,

static void max98088_sync_cache(struct snd_soc_codec *codec)
{
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
u16 *reg_cache = codec->reg_cache;
int i;

if (!codec->cache_sync)
Expand All @@ -1599,14 +1598,14 @@ static void max98088_sync_cache(struct snd_soc_codec *codec)
/* write back cached values if they're writeable and
* different from the hardware default.
*/
for (i = 1; i < ARRAY_SIZE(max98088->reg_cache); i++) {
for (i = 1; i < codec->driver->reg_cache_size; i++) {
if (!max98088_access[i].writable)
continue;

if (max98088->reg_cache[i] == max98088_reg[i])
if (reg_cache[i] == max98088_reg[i])
continue;

snd_soc_write(codec, i, max98088->reg_cache[i]);
snd_soc_write(codec, i, reg_cache[i]);
}

codec->cache_sync = 0;
Expand Down Expand Up @@ -1951,7 +1950,6 @@ static int max98088_probe(struct snd_soc_codec *codec)
int ret = 0;

codec->cache_sync = 1;
memcpy(codec->reg_cache, max98088_reg, sizeof(max98088_reg));

ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
if (ret != 0) {
Expand Down

0 comments on commit d24eb0d

Please sign in to comment.