/* Returns the register contents in case the expected value was found in the appropriate register bits, or -ETIMEDOUT on timeout.  */
static int tis_wait_reg(struct tpm_tis_lpc_priv *priv, u32 *reg, u8 mask, u8 expected)
/* Returns the register contents in case the expected value was found in the appropriate register bits, or -ETIMEDOUT on timeout.  */
static int tis_wait_reg(struct tpm_tis_lpc_priv *priv, u32 *reg, u8 mask, u8 expected)
{
	u32 time_us = MAX_DELAY_US;
	while (time_us > 0) {
		u32 value = tpm_read_word(priv, reg);
		if ((value & mask) == expected)
			return value;
		udelay(1);
		time_us--;
	}
	return -ETIMEDOUT;
}