From 4727beff4df11caddc1bfa1c84f4e1b0693f296d Mon Sep 17 00:00:00 2001 From: dojha Date: Thu, 31 Mar 2016 16:12:44 +0530 Subject: ASoC: codec: micb ref count decrement check In SSR with recording, race condition which reduces micb_ref to -1 is seen. SSR sets micb_ref to 0, further recording widgets power down can reduce it to -1. During power up, it is increased to 0, micbias is not getting enabled for recording since micb_ref is 0. To prevent this micb_ref is checked for non zero value before decrementing it. CRs-Fixed: 994268 Change-Id: I6ea23fdf8b119cfd178c4f5b79b9d1c01c267a82 Signed-off-by: dojha --- sound/soc/codecs/wcd9335.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index 13933a078e43..18dc404ac31d 100755 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -1389,7 +1389,8 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); break; case MICB_PULLUP_DISABLE: - tasha->pullup_ref[micb_index]--; + if (tasha->pullup_ref[micb_index] > 0) + tasha->pullup_ref[micb_index]--; if ((tasha->pullup_ref[micb_index] == 0) && (tasha->micb_ref[micb_index] == 0)) snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); @@ -1407,7 +1408,8 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, post_dapm_on, &tasha->mbhc); break; case MICB_DISABLE: - tasha->micb_ref[micb_index]--; + if (tasha->micb_ref[micb_index] > 0) + tasha->micb_ref[micb_index]--; if ((tasha->micb_ref[micb_index] == 0) && (tasha->pullup_ref[micb_index] > 0)) snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); -- cgit v1.2.3