Skip to content

Commit 23d4635

Browse files
Krzysztof Heltperexg
authored andcommitted
[ALSA] cs4231-lib: improved waiting after mce_down
This patch replaces long msleeps in waiting loops with schedule_timeout() calls. Signed-off-by: Krzysztof Helt <krzysztof.h1 at wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
1 parent 503fc85 commit 23d4635

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎sound/isa/cs423x/cs4231_lib.c‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,26 +343,29 @@ void snd_cs4231_mce_down(struct snd_cs4231 *chip)
343343

344344
snd_printdd("(1) jiffies = %lu\n", jiffies);
345345

346-
/* in 10 ms increments, check condition, up to 250 ms */
347-
timeout = 25;
348-
while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) {
349-
if (--timeout < 0) {
350-
snd_printk("mce_down - auto calibration time out (2)\n");
346+
/* check condition up to 250 ms */
347+
timeout = msecs_to_jiffies(250);
348+
while (snd_cs4231_in(chip, CS4231_TEST_INIT) &
349+
CS4231_CALIB_IN_PROGRESS) {
350+
351+
if (timeout <= 0) {
352+
snd_printk(KERN_ERR "mce_down - "
353+
"auto calibration time out (2)\n");
351354
return;
352355
}
353-
msleep(10);
356+
timeout = schedule_timeout(timeout);
354357
}
355358

356359
snd_printdd("(2) jiffies = %lu\n", jiffies);
357360

358-
/* in 10 ms increments, check condition, up to 100 ms */
359-
timeout = 10;
361+
/* check condition up to 100 ms */
362+
timeout = msecs_to_jiffies(100);
360363
while (cs4231_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) {
361-
if (--timeout < 0) {
364+
if (timeout <= 0) {
362365
snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n");
363366
return;
364367
}
365-
msleep(10);
368+
timeout = schedule_timeout(timeout);
366369
}
367370

368371
snd_printdd("(3) jiffies = %lu\n", jiffies);

0 commit comments

Comments
 (0)