/* returns zero if a bit matches, or a negative error code.  */
static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg, unsigned char mask, unsigned char bit, int time, unsigned char *read)
/* returns zero if a bit matches, or a negative error code.  */
static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg, unsigned char mask, unsigned char bit, int time, unsigned char *read)
{
	int i = 0;
	unsigned long end_time = jiffies + (time * HZ + 999) / 1000;
	do {
		*read = PCXHR_INPB(mgr, reg);
		if ((*read & mask) == bit) {
			if (i > 100)
				snd_printdd("ATTENTION! check_reg(%x) "
					    "loopcount=%d\n",
					    reg, i);
			return 0;
		}
		i++;
	} while (time_after_eq(end_time, jiffies));
	snd_printk(KERN_ERR
		   "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=%x\n",
		   reg, mask, *read);
	return -EIO;
}