[alsa-devel] [PATCH 1/3] ASoC: alc5623: Convert codec->hw_read to regmap_read

Axel Lin axel.lin at gmail.com
Fri Oct 14 01:29:33 CEST 2011


2011/10/14 Mark Brown <broonie at opensource.wolfsonmicro.com>:
> On Fri, Oct 14, 2011 at 06:39:43AM +0800, Axel Lin wrote:
>> 2011/10/14 Mark Brown <broonie at opensource.wolfsonmicro.com>:
>
>> > Probably the best thing here is to convert all these drivers to use
>> > cache_bypass to read directly through the cache - the same thing will
>> > then work with direct regmap usage.
>
>> I don't complete understand "use cache_bypass to read directly through
>> the cache".
>
> Set the cache_bypass flag in the device struct.
>
Sorry. I still don't get it.

I check the regmap code, it seems cache_bypsss is only set
if map->cache_type == REGCACHE_NONE or by regcache_cache_bypass().

I'm wondering if we can fix it this way:

diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index 557b3af..9e43bb9 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -51,10 +51,15 @@ static void alc5623_fill_cache(struct snd_soc_codec *codec)
 {
        int i, step = codec->driver->reg_cache_step;
        u16 *cache = codec->reg_cache;
+       unsigned int val;

        /* not really efficient ... */
-       for (i = 0 ; i < codec->driver->reg_cache_size ; i += step)
-               cache[i] = codec->hw_read(codec, i);
+       regcache_cache_bypass(codec->control_data, true);
+       for (i = 0 ; i < codec->driver->reg_cache_size ; i += step) {
+               regmap_read(codec->control_data, i, &val);
+               cache[i] = val;
+       }
+       regcache_cache_bypass(codec->control_data, false);
 }

 static inline int alc5623_reset(struct snd_soc_codec *codec)


More information about the Alsa-devel mailing list