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

ASoC: tlv320aic26: Use snd_soc_update_bits()

Use snd_soc_update_bits() rather than open coding. Since the register cache
is currently only used where update_bits() is used this means the current
register cache can be removed entirely.

Signed-off-by: Mark Brown <broonie@linaro.org>

+13 -38
+13 -38
sound/soc/codecs/tlv320aic26.c
··· 74 74 return value; 75 75 } 76 76 77 - static unsigned int aic26_reg_read_cache(struct snd_soc_codec *codec, 78 - unsigned int reg) 79 - { 80 - u16 *cache = codec->reg_cache; 81 - 82 - if (reg >= AIC26_NUM_REGS) { 83 - WARN_ON_ONCE(1); 84 - return 0; 85 - } 86 - 87 - return cache[reg]; 88 - } 89 - 90 77 static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg, 91 78 unsigned int value) 92 79 { ··· 182 195 snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); 183 196 184 197 /* Audio Control 3 (master mode, fsref rate) */ 185 - reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3); 186 - reg &= ~0xf800; 187 198 if (aic26->master) 188 - reg |= 0x0800; 199 + reg = 0x0800; 189 200 if (fsref == 48000) 190 - reg |= 0x2000; 191 - snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); 201 + reg = 0x2000; 202 + snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); 192 203 193 204 /* Audio Control 1 (FSref divisor) */ 194 - reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1); 195 - reg &= ~0x0fff; 196 - reg |= wlen | aic26->datfm | (divisor << 3) | divisor; 197 - snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg); 205 + reg = wlen | aic26->datfm | (divisor << 3) | divisor; 206 + snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); 198 207 199 208 return 0; 200 209 } ··· 202 219 { 203 220 struct snd_soc_codec *codec = dai->codec; 204 221 struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); 205 - u16 reg = aic26_reg_read_cache(codec, AIC26_REG_DAC_GAIN); 222 + u16 reg; 206 223 207 224 dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", 208 225 dai, mute); 209 226 210 227 if (mute) 211 - reg |= 0x8080; 228 + reg = 0x8080; 212 229 else 213 - reg &= ~0x8080; 214 - snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg); 230 + reg = 0; 231 + snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg); 215 232 216 233 return 0; 217 234 } ··· 329 346 struct aic26 *aic26 = dev_get_drvdata(dev); 330 347 int val, amp, freq, len; 331 348 332 - val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); 349 + val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2); 333 350 amp = (val >> 12) & 0x7; 334 351 freq = (125 << ((val >> 8) & 0x7)) >> 1; 335 352 len = 2 * (1 + ((val >> 4) & 0xf)); ··· 343 360 const char *buf, size_t count) 344 361 { 345 362 struct aic26 *aic26 = dev_get_drvdata(dev); 346 - int val; 347 363 348 - val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); 349 - val |= 0x8000; 350 - snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val); 364 + snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2, 365 + 0x8000, 0x800); 351 366 352 367 return count; 353 368 } ··· 358 377 static int aic26_probe(struct snd_soc_codec *codec) 359 378 { 360 379 struct aic26 *aic26 = dev_get_drvdata(codec->dev); 361 - int ret, i, reg; 380 + int ret, reg; 362 381 363 382 aic26->codec = codec; 364 383 ··· 374 393 reg |= 0x0800; /* set master mode */ 375 394 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); 376 395 377 - /* Fill register cache */ 378 - for (i = 0; i < codec->driver->reg_cache_size; i++) 379 - snd_soc_read(codec, i); 380 - 381 396 /* Register the sysfs files for debugging */ 382 397 /* Create SysFS files */ 383 398 ret = device_create_file(codec->dev, &dev_attr_keyclick); ··· 387 410 .probe = aic26_probe, 388 411 .read = aic26_reg_read, 389 412 .write = aic26_reg_write, 390 - .reg_cache_size = AIC26_NUM_REGS, 391 - .reg_word_size = sizeof(u16), 392 413 .controls = aic26_snd_controls, 393 414 .num_controls = ARRAY_SIZE(aic26_snd_controls), 394 415 .dapm_widgets = tlv320aic26_dapm_widgets,