summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-29 15:24:40 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-04-05 16:17:39 +0100
commit3fa49e3ad9ac20b15edfb0c51bbad36e45a84b17 (patch)
tree17c81c5b8f5178ca807c07f4edacbcbfb2672ff0 /sound
parentb5442a75deee293d10c2ab8f4a77013973c4c9e0 (diff)
downloadlinux-stable-3fa49e3ad9ac20b15edfb0c51bbad36e45a84b17.tar.gz
linux-stable-3fa49e3ad9ac20b15edfb0c51bbad36e45a84b17.tar.bz2
linux-stable-3fa49e3ad9ac20b15edfb0c51bbad36e45a84b17.zip
ASoC: Avoid wraparound in wm_hubs DC servo correction
If the correction wraps around then a substantial offset would be introduced. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm_hubs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 486bdd21a98a..3729a12b151f 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -113,13 +113,15 @@ static void calibrate_dc_servo(struct snd_soc_codec *codec)
/* HPOUT1L */
reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1) &
WM8993_DCS_INTEG_CHAN_0_MASK;;
- reg += hubs->dcs_codes;
+ if (reg + hubs->dcs_codes > 0 && reg + hubs->dcs_codes < 0xff)
+ reg += hubs->dcs_codes;
dcs_cfg = reg << WM8993_DCS_DAC_WR_VAL_1_SHIFT;
/* HPOUT1R */
reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2) &
WM8993_DCS_INTEG_CHAN_1_MASK;
- reg += hubs->dcs_codes;
+ if (reg + hubs->dcs_codes > 0 && reg + hubs->dcs_codes < 0xff)
+ reg += hubs->dcs_codes;
dcs_cfg |= reg;
/* Do it */