5080cc6737b74ee4578b92fd24cc970f3b02e545
[openembedded.git] /
1 From d24eb0db9c8a7ceecae860bdc636ed1e8a86943a Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Tue, 28 Dec 2010 21:37:56 +0100
4 Subject: [PATCH 18/66] ASoC: codecs: max98088: Fix register cache incoherency
5
6 The multi-component patch(commit f0fba2ad1) moved the allocation of the
7 register cache from the driver to the ASoC core. Most drivers where adjusted to
8 this, but the max98088 driver still uses its own register cache for its
9 private functions, while functions from the ASoC core use the generic cache.
10 Thus we end up with two from each other incoherent caches, which can lead to
11 undefined behaviour.
12 This patch fixes the issue by changing the max98088 driver to use the
13 generic register cache in its private functions.
14
15 Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
16 Cc: Peter Hsiang <Peter.Hsiang@maxim-ic.com>
17 Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
18 Cc: stable@kernel.org (for 2.6.37 only)
19 ---
20  sound/soc/codecs/max98088.c |   10 ++++------
21  1 files changed, 4 insertions(+), 6 deletions(-)
22
23 diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
24 index d63e287..6447dbb 100644
25 --- a/sound/soc/codecs/max98088.c
26 +++ b/sound/soc/codecs/max98088.c
27 @@ -40,7 +40,6 @@ struct max98088_cdata {
28  };
29  
30  struct max98088_priv {
31 -       u8 reg_cache[M98088_REG_CNT];
32         enum max98088_type devtype;
33         void *control_data;
34         struct max98088_pdata *pdata;
35 @@ -1588,7 +1587,7 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,
36  
37  static void max98088_sync_cache(struct snd_soc_codec *codec)
38  {
39 -       struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
40 +       u16 *reg_cache = codec->reg_cache;
41         int i;
42  
43         if (!codec->cache_sync)
44 @@ -1599,14 +1598,14 @@ static void max98088_sync_cache(struct snd_soc_codec *codec)
45         /* write back cached values if they're writeable and
46          * different from the hardware default.
47          */
48 -       for (i = 1; i < ARRAY_SIZE(max98088->reg_cache); i++) {
49 +       for (i = 1; i < codec->driver->reg_cache_size; i++) {
50                 if (!max98088_access[i].writable)
51                         continue;
52  
53 -               if (max98088->reg_cache[i] == max98088_reg[i])
54 +               if (reg_cache[i] == max98088_reg[i])
55                         continue;
56  
57 -               snd_soc_write(codec, i, max98088->reg_cache[i]);
58 +               snd_soc_write(codec, i, reg_cache[i]);
59         }
60  
61         codec->cache_sync = 0;
62 @@ -1951,7 +1950,6 @@ static int max98088_probe(struct snd_soc_codec *codec)
63         int ret = 0;
64  
65         codec->cache_sync = 1;
66 -       memcpy(codec->reg_cache, max98088_reg, sizeof(max98088_reg));
67  
68         ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
69         if (ret != 0) {
70 -- 
71 1.6.6.1
72