/* NOTE: The caller is responsible for locking the cache_lock prior to calling this function.  */
static int release_cached_info(int spu_index)
/* NOTE: The caller is responsible for locking the cache_lock prior to calling this function.  */
static int release_cached_info(int spu_index)
{
	int index, end;
	if (spu_index == RELEASE_ALL) {
		end = num_spu_nodes;
		index = 0;
	} else {
		if (spu_index >= num_spu_nodes) {
			printk(KERN_ERR "SPU_PROF: "
				"%s, line %d: "
				"Invalid index %d into spu info cache\n",
				__func__, __LINE__, spu_index);
			goto out;
		}
		end = spu_index + 1;
		index = spu_index;
	}
	for (; index < end; index++) {
		if (spu_info[index]) {
			kref_put(&spu_info[index]->cache_ref,
				 destroy_cached_info);
			spu_info[index] = NULL;
		}
	}
out:
	return 0;
}