示例#1
0
文件: pcibr_ate.c 项目: 274914765/C
/*
 * alloc_ate_resource:  Allocate the requested number of ATEs.
 */
static inline int alloc_ate_resource(struct ate_resource *ate_resource,
                     int ate_needed)
{
    int start_index;

    /*
     * Check for ate exhaustion.
     */
    if (ate_resource->lowest_free_index < 0)
        return -1;

    /*
     * Find the required number of free consecutive ates.
     */
    start_index =
        find_free_ate(ate_resource, ate_resource->lowest_free_index,
              ate_needed);
    if (start_index >= 0)
        mark_ate(ate_resource, start_index, ate_needed, ate_needed);

    ate_resource->lowest_free_index =
        find_free_ate(ate_resource, ate_resource->lowest_free_index, 1);

    return start_index;
}
static inline int alloc_ate_resource(struct ate_resource *ate_resource,
				     int ate_needed)
{
	int start_index;

	/*
                             
  */
	if (ate_resource->lowest_free_index < 0)
		return -1;

	/*
                                                      
  */
	start_index =
	    find_free_ate(ate_resource, ate_resource->lowest_free_index,
			  ate_needed);
	if (start_index >= 0)
		mark_ate(ate_resource, start_index, ate_needed, ate_needed);

	ate_resource->lowest_free_index =
	    find_free_ate(ate_resource, ate_resource->lowest_free_index, 1);

	return start_index;
}