/* NOTE: This routine must follow the query_event_num function in the interrupt.  */
int ec_get_event_num(void)
/* NOTE: This routine must follow the query_event_num function in the interrupt.  */
int ec_get_event_num(void)
{
	int timeout = 100;
	unsigned char value;
	unsigned char status;
	udelay(EC_REG_DELAY);
	status = inb(EC_STS_PORT);
	udelay(EC_REG_DELAY);
	while (timeout-- && !(status & (1 << 0))) {
		status = inb(EC_STS_PORT);
		udelay(EC_REG_DELAY);
	}
	if (timeout <= 0) {
		pr_info("%s: get event number timeout.\n", __func__);
		return -EINVAL;
	}
	value = inb(EC_DAT_PORT);
	udelay(EC_REG_DELAY);
	return value;
}