From: Nicholas Mc Guire Date: Sun, 8 Mar 2015 10:02:38 +0000 (-0400) Subject: ASoC: wm8996: ensure lower bounds of 1 for timeout X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=159366ea38706402e8ebd0f55eef52931333deac;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git ASoC: wm8996: ensure lower bounds of 1 for timeout wait_for_completion_timeout can be called with timeout == 0 due to msecs_to_jiffies(2) == 1 for HZ < 1000 and usecs_to_jiffies(300) == 1 for all reasonable values of HZ, thus the following timeout /= 2; sets timeout to 0. This patch simply adds a lower-bounds of 1. Signed-off-by: Nicholas Mc Guire Acked-by: Charles Keepax Signed-off-by: Mark Brown --- diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 7a2b96959589..308748a022c5 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -2110,7 +2110,8 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, if (i2c->irq) timeout *= 10; else - timeout /= 2; + /* ensure timeout of atleast 1 jiffies */ + timeout = timeout/2 ? : 1; for (retry = 0; retry < 10; retry++) { time_left = wait_for_completion_timeout(&wm8996->fll_lock,