/* find_free_ate: Find the first free ate index starting from the given index for the desired consecutive count.  */
static int find_free_ate(struct ate_resource *ate_resource, int start, int count)
/* find_free_ate: Find the first free ate index starting from the given index for the desired consecutive count.  */
static int find_free_ate(struct ate_resource *ate_resource, int start, int count)
{
	u64 *ate = ate_resource->ate;
	int index;
	int start_free;
	for (index = start; index < ate_resource->num_ate;) {
		if (!ate[index]) {
			int i;
			int free;
			free = 0;
			start_free = index;
			for (i = start_free; i < ate_resource->num_ate; i++) {
				if (!ate[i]) {
					if (++free == count)
						return start_free;
				} else {
					index = i + 1;
					break;
				}
			}
			if (i >= ate_resource->num_ate)
				return -1;
		} else
			index++;
	}
	return -1;
}