Skip to content

Commit

Permalink
ASoC: wm8996: ensure lower bounds of 1 for timeout
Browse files Browse the repository at this point in the history
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 <hofrat@osadl.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Nicholas Mc Guire authored and Mark Brown committed Mar 9, 2015
1 parent 62c76fe commit 159366e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/soc/codecs/wm8996.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 159366e

Please sign in to comment.