[alsa-devel] ASoC: PATCH: wm8731 - reinitialize regmap cache after hardware reset

Sergey Kiselev skiselev at gmail.com
Thu May 28 18:34:09 CEST 2015


Hi,

I am working on a machine driver that uses wm8731 codec and I've
noticed that it will not work after rmmod/modprobe of that machine
driver. The issue is that wm8731_probe() resets the hardware, but it
doesn't reinitialize the regmap cache to the default values.

The patch below fixes this issue.

I also skimmed through other codecs, and some of them might have
similar issue (wm8510.c, wm8711.c, wm8750.c, wm8753.c, wm8940.c,
wm8960.c, wm8971.c, wm8974.c, wm8988.c, wm8990.c)

Another way to avoid this issue might be resetting the codec in the
*_spi_probe()/*_i2c_probe(), so that it only gets reset once when
codec is loading.

Thanks in advance for any comments/suggestions on the patch.

Thanks,
Sergey

Signed-off-by: Sergey Kiselev <skiselev at gmail.com>

diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 2245b6a..76af75b 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -84,7 +84,7 @@ static bool wm8731_writeable(struct device *dev,
unsigned int reg)
  return reg <= WM8731_RESET;
 }

-#define wm8731_reset(c) snd_soc_write(c, WM8731_RESET, 0)
+static int wm8731_reset(struct snd_soc_codec *codec);

 static const char *wm8731_input_select[] = {"Line In", "Mic"};

@@ -665,6 +665,21 @@ static const struct regmap_config wm8731_regmap = {
  .num_reg_defaults = ARRAY_SIZE(wm8731_reg_defaults),
 };

+static int wm8731_reset(struct snd_soc_codec *codec)
+{
+ int ret;
+ struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
+
+ ret = snd_soc_write(codec, WM8731_RESET, 0);
+
+ if (ret != 0)
+ return ret;
+
+ regmap_reinit_cache(wm8731->regmap, &wm8731_regmap);
+
+ return 0;
+}
+
 #if defined(CONFIG_SPI_MASTER)
 static int wm8731_spi_probe(struct spi_device *spi)
 {


More information about the Alsa-devel mailing list