#include #include #include #include #include "cputemp2maxfreq.h" #include "cpufreq.h" extern struct s_cpudata cpudata; extern struct s_config config; void failsafe(int code) { printf("Failed to set governor, error %d (%s).\n",errno,strerror(errno)); // We failed to set the governor, try to fail safe. First try the CPU minimum // frequency, if that doesn't work out try the fallback frequency if (cpufreq_set_long_int("scaling_max_freq",cpudata.min_freq,100)==0) { printf("Set scaling frequency to CPU's minimum frequency."); exit(code); } printf("Failed to set scaling frequency to CPU's minimum frequency, error: %d (%s).\n",errno,strerror(errno)); if (cpufreq_set_long_int("scaling_max_freq",config.fallback_freq,100)==0) { printf("Set scaling frequency to fallback frequency."); exit(code); } printf("Failed to set scaling frequency to fallback frequency, error: %d (%s).\n",errno,strerror(errno)); printf("All safety measures failed, watch out not to fry your hardware.\n"); exit(code); }