[alsa-devel] [PATCH] ad1838/cs4231 -- fix MCE timeout upon initial load

Rene Herman rene.herman at gmail.com
Tue Sep 18 10:17:43 CEST 2007


On 09/18/2007 10:02 AM, Krzysztof Helt wrote:

>> +	timeout = jiffies + msecs_to_jiffies(250);
>> +	do {
>>  		spin_unlock_irqrestore(&chip->reg_lock, flags);
>> -		if (time_after(jiffies, end_time)) {
>> -			snd_printk(KERN_ERR "mce_down - auto calibration time out (2)\n");
>> -			return;
>> -		}
>>  		msleep(1);
>>  		spin_lock_irqsave(&chip->reg_lock, flags);
>> -	}
>> -
>> -	snd_printdd("(3) jiffies = %lu\n", jiffies);
>> -
>> -	end_time = jiffies + msecs_to_jiffies(100);
>> -	while (inb(AD1848P(chip, REGSEL)) & AD1848_INIT) {
>> -		spin_unlock_irqrestore(&chip->reg_lock, flags);
>> -		if (time_after(jiffies, end_time)) {
>> -			snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n");
>> -			return;
>> -		}
>> -		msleep(1);
>> -		spin_lock_irqsave(&chip->reg_lock, flags);
>> -	}
>> -	spin_unlock_irqrestore(&chip->reg_lock, flags);
>> +		regsel = snd_ad1848_in(chip, AD1848_TEST_INIT);
>> +	} while ((regsel & AD1848_CALIB_IN_PROGRESS) && time_before(jiffies, timeout));
> 
> Break this long line. You may calculate "regsel & AD1848_CALIB_IN_PROGRESS"
> inside the loop and use it in the condition outside the loop too.

Or just break out directly with a goto:

		regsel = snd_ad1848_in();
		if (!(regsel & AD1848_CALIB_IN_PROGRESS))
			goto out;
	while (time_before(jiffies, timeout));

	snd_printk(KERN_ERR "mce_down - auto calibration time out (2)\n")
out:
	spin_unlock_irqrestore()
	snd_printd()
	return;
}

Have grown to like those best generally -= falling off a timeout-loop means 
you've timed out, and if not, you jump over the error handling for that.

But I'm quite sure we'll be able to get religious over that. We're four 
people patching the same little function over and over again, so we're 
pretty daft anyway :-)

Rene.



More information about the Alsa-devel mailing list