Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: wm8990: Convert to snd_soc_cache_sync for sync reg_cache with the hardware

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
416a0ce5 a92f1394

+19 -13
+19 -13
sound/soc/codecs/wm8990.c
··· 36 36 unsigned int pcmclk; 37 37 }; 38 38 39 + static int wm8990_volatile_register(struct snd_soc_codec *codec, 40 + unsigned int reg) 41 + { 42 + switch (reg) { 43 + case WM8990_RESET: 44 + return 1; 45 + default: 46 + return 0; 47 + } 48 + } 49 + 39 50 /* 40 51 * wm8990 register cache. Note that register 0 is not included in the 41 52 * cache. ··· 1167 1156 static int wm8990_set_bias_level(struct snd_soc_codec *codec, 1168 1157 enum snd_soc_bias_level level) 1169 1158 { 1159 + int ret; 1170 1160 u16 val; 1171 1161 1172 1162 switch (level) { ··· 1183 1171 1184 1172 case SND_SOC_BIAS_STANDBY: 1185 1173 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 1174 + ret = snd_soc_cache_sync(codec); 1175 + if (ret < 0) { 1176 + dev_err(codec->dev, "Failed to sync cache: %d\n", ret); 1177 + return ret; 1178 + } 1179 + 1186 1180 /* Enable all output discharge bits */ 1187 1181 snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | 1188 1182 WM8990_DIS_RLINE | WM8990_DIS_OUT3 | ··· 1337 1319 1338 1320 static int wm8990_resume(struct snd_soc_codec *codec) 1339 1321 { 1340 - int i; 1341 - u8 data[2]; 1342 - u16 *cache = codec->reg_cache; 1343 - 1344 - /* Sync reg_cache with the hardware */ 1345 - for (i = 0; i < ARRAY_SIZE(wm8990_reg); i++) { 1346 - if (i + 1 == WM8990_RESET) 1347 - continue; 1348 - data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001); 1349 - data[1] = cache[i] & 0x00ff; 1350 - codec->hw_write(codec->control_data, data, 2); 1351 - } 1352 - 1353 1322 wm8990_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1354 1323 return 0; 1355 1324 } ··· 1397 1392 .reg_cache_size = ARRAY_SIZE(wm8990_reg), 1398 1393 .reg_word_size = sizeof(u16), 1399 1394 .reg_cache_default = wm8990_reg, 1395 + .volatile_register = wm8990_volatile_register, 1400 1396 }; 1401 1397 1402 1398 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)