blob: fec00e81be1d795e91aa0ecd3d7e46c105217500 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "cputemp2maxfreq.h"
#include "cpufreq.h"
extern struct s_cpudata cpudata;
extern struct s_config config;
void failsafe(int code)
{
// First try to set the CPU to it's minimum frequency
if (cpufreq_set_long_int("scaling_max_freq",cpudata.min_freq,100)>0)
{
printf("Set scaling frequency to CPU's minimum frequency.\n");
exit(code);
}
printf("Failed to set scaling frequency to CPU's minimum frequency, error: %d (%s).\n",errno,strerror(errno));
// If that failed, try the fallback frequency
if (cpufreq_set_long_int("scaling_max_freq",config.fallback_freq,100)>0)
{
printf("Set scaling frequency to fallback frequency.\n");
exit(code);
}
printf("Failed to set scaling frequency to fallback frequency, error: %d (%s).\n",errno,strerror(errno));
// Everything failed, issue a warning
printf("All safety measures failed, watch out not to fry your hardware.\n");
exit(code);
}
|