/* Wait until gpio_get_value(gpio) returns the requested value or until we time out. The timeout value is expressed in microseconds.  */
int gpio_wait_level_timeout(unsigned gpio, int value, int timeout)
/* Wait until gpio_get_value(gpio) returns the requested value or until we time out. The timeout value is expressed in microseconds.  */
int gpio_wait_level_timeout(unsigned gpio, int value, int timeout)
{
	while (timeout-- > 0) {
		if (gpio_get_value(gpio) == value) {
			timeout = 1;
			break;
		}
		udelay(1);
	}
	return timeout > 0 ? 0 : -ETIMEDOUT;
}