Commit b875d650527e1980cc88b2731ac4c209d2e4a0ca
Committed by
Jaroslav Kysela
1 parent
56f91585b4
Exists in
master
and in
7 other branches
[ALSA] Fix thinko in cs4231 mce down check
The last patches to replace with schedule_timeout() don't work as expected. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Showing 2 changed files with 14 additions and 12 deletions Side-by-side Diff
sound/isa/cs423x/cs4231_lib.c
... | ... | @@ -313,6 +313,7 @@ |
313 | 313 | void snd_cs4231_mce_down(struct snd_cs4231 *chip) |
314 | 314 | { |
315 | 315 | unsigned long flags; |
316 | + unsigned long end_time; | |
316 | 317 | int timeout; |
317 | 318 | |
318 | 319 | snd_cs4231_busy_wait(chip); |
319 | 320 | |
320 | 321 | |
321 | 322 | |
322 | 323 | |
323 | 324 | |
... | ... | @@ -344,28 +345,28 @@ |
344 | 345 | snd_printdd("(1) jiffies = %lu\n", jiffies); |
345 | 346 | |
346 | 347 | /* check condition up to 250 ms */ |
347 | - timeout = msecs_to_jiffies(250); | |
348 | + end_time = jiffies + msecs_to_jiffies(250); | |
348 | 349 | while (snd_cs4231_in(chip, CS4231_TEST_INIT) & |
349 | 350 | CS4231_CALIB_IN_PROGRESS) { |
350 | 351 | |
351 | - if (timeout <= 0) { | |
352 | + if (time_after(jiffies, end_time)) { | |
352 | 353 | snd_printk(KERN_ERR "mce_down - " |
353 | 354 | "auto calibration time out (2)\n"); |
354 | 355 | return; |
355 | 356 | } |
356 | - timeout = schedule_timeout(timeout); | |
357 | + msleep(1); | |
357 | 358 | } |
358 | 359 | |
359 | 360 | snd_printdd("(2) jiffies = %lu\n", jiffies); |
360 | 361 | |
361 | 362 | /* check condition up to 100 ms */ |
362 | - timeout = msecs_to_jiffies(100); | |
363 | + end_time = jiffies + msecs_to_jiffies(100); | |
363 | 364 | while (cs4231_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) { |
364 | - if (timeout <= 0) { | |
365 | + if (time_after(jiffies, end_time)) { | |
365 | 366 | snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n"); |
366 | 367 | return; |
367 | 368 | } |
368 | - timeout = schedule_timeout(timeout); | |
369 | + msleep(1); | |
369 | 370 | } |
370 | 371 | |
371 | 372 | snd_printdd("(3) jiffies = %lu\n", jiffies); |
sound/sparc/cs4231.c
... | ... | @@ -401,6 +401,7 @@ |
401 | 401 | static void snd_cs4231_mce_down(struct snd_cs4231 *chip) |
402 | 402 | { |
403 | 403 | unsigned long flags; |
404 | + unsigned long end_time; | |
404 | 405 | int timeout; |
405 | 406 | |
406 | 407 | spin_lock_irqsave(&chip->lock, flags); |
407 | 408 | |
408 | 409 | |
409 | 410 | |
410 | 411 | |
411 | 412 | |
... | ... | @@ -431,30 +432,30 @@ |
431 | 432 | msleep(1); |
432 | 433 | |
433 | 434 | /* check condition up to 250ms */ |
434 | - timeout = msecs_to_jiffies(250); | |
435 | + end_time = jiffies + msecs_to_jiffies(250); | |
435 | 436 | while (snd_cs4231_in(chip, CS4231_TEST_INIT) & |
436 | 437 | CS4231_CALIB_IN_PROGRESS) { |
437 | 438 | |
438 | 439 | spin_unlock_irqrestore(&chip->lock, flags); |
439 | - if (timeout <= 0) { | |
440 | + if (time_after(jiffies, end_time)) { | |
440 | 441 | snd_printk("mce_down - " |
441 | 442 | "auto calibration time out (2)\n"); |
442 | 443 | return; |
443 | 444 | } |
444 | - timeout = schedule_timeout(timeout); | |
445 | + msleep(1); | |
445 | 446 | spin_lock_irqsave(&chip->lock, flags); |
446 | 447 | } |
447 | 448 | |
448 | 449 | /* check condition up to 100ms */ |
449 | - timeout = msecs_to_jiffies(100); | |
450 | + end_time = jiffies + msecs_to_jiffies(100); | |
450 | 451 | while (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) { |
451 | 452 | spin_unlock_irqrestore(&chip->lock, flags); |
452 | - if (timeout <= 0) { | |
453 | + if (time_after(jiffies, end_time)) { | |
453 | 454 | snd_printk("mce_down - " |
454 | 455 | "auto calibration time out (3)\n"); |
455 | 456 | return; |
456 | 457 | } |
457 | - timeout = schedule_timeout(timeout); | |
458 | + msleep(1); | |
458 | 459 | spin_lock_irqsave(&chip->lock, flags); |
459 | 460 | } |
460 | 461 | spin_unlock_irqrestore(&chip->lock, flags); |