FreeBSD/sys/kern/kern_cpu.c
/*
 * Expand a group of relative settings, creating derived levels from them.
 */
Expand a group of relative settings, creating derived levels from them.
Expand a group of relative settings creating derived levels from them .
static int
cpufreq_expand_set(struct cpufreq_softc *sc, struct cf_setting_array *set_arr)
{
	struct cf_level *fill, *search;
	struct cf_setting *set;
	int i;
	CF_MTX_ASSERT(&sc->lock);
	TAILQ_FOREACH_REVERSE(search, &sc->all_levels, cf_level_lst, link) {
		for (i = 0; i < set_arr->count; i++) {
			set = &set_arr->sets[i];
			fill = search;
			if (set->freq < 10000) {
				fill = cpufreq_dup_set(sc, search, set);
				if (fill == NULL)
					break;
			}
			KASSERT(fill->rel_count < MAX_SETTINGS,
			    ("cpufreq: too many relative drivers (%d)",
			    MAX_SETTINGS));
			fill->rel_set[fill->rel_count] = *set;
			fill->rel_count++;
			CF_DEBUG(
			"expand set added rel setting %d%% to %d level\n",
			    set->freq / 100, fill->total_set.freq);
		}
	}
	return (0);
}
static int cpufreq_expand_set ( struct cpufreq_softc * sc , struct cf_setting_array * set_arr ) { struct cf_level * fill , * search ; struct cf_setting * set ; int i ; CF_MTX_ASSERT ( & sc -> lock ) ; TAILQ_FOREACH_REVERSE ( search , & sc -> all_levels , cf_level_lst , link ) { for ( i = 0 ; i < set_arr -> count ; i ++ ) { set = & set_arr -> sets [ i ] ; fill = search ; if ( set -> freq < 10000 ) { fill = cpufreq_dup_set ( sc , search , set ) ; if ( fill == NULL ) break ; } KASSERT ( fill -> rel_count < MAX_SETTINGS , ( " " , MAX_SETTINGS ) ) ; fill -> rel_set [ fill -> rel_count ] = * set ; fill -> rel_count ++ ; CF_DEBUG ( " \n " , set -> freq / 100 , fill -> total_set . freq ) ; } } return ( 0 ) ; }
Expand a group of relative settings, creating derived levels from them.
Expand a group of relative settings creating derived levels from them .
/*
	 * Walk the set of all existing levels in reverse.  This is so we
	 * create derived states from the lowest absolute settings first
	 * and discard duplicates created from higher absolute settings.
	 * For instance, a level of 50 Mhz derived from 100 Mhz + 50% is
	 * preferable to 200 Mhz + 25% because absolute settings are more
	 * efficient since they often change the voltage as well.
	 */ /* Add each setting to the level, duplicating if necessary. */ /*
			 * If this setting is less than 100%, split the level
			 * into two and add this setting to the new level.
			 */ /*
				 * The new level was a duplicate of an existing
				 * level or its absolute setting is too high
				 * so we freed it.  For example, we discard a
				 * derived level of 1000 MHz/25% if a level
				 * of 500 MHz/100% already exists.
				 */ /* Add this setting to the existing or new level. */