aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPA4WDH2024-07-26 19:03:30 +0200
committerPA4WDH2024-07-26 19:03:30 +0200
commit1391d88489774d705c411a52bc4ee3ede56af059 (patch)
tree505ab45f59a6708501965cf6618fb4124e972bdf
parentFix generate_version_h.sh (diff)
downloadcputemp2maxfreq-1391d88489774d705c411a52bc4ee3ede56af059.tar.gz
cputemp2maxfreq-1391d88489774d705c411a52bc4ee3ede56af059.tar.bz2
cputemp2maxfreq-1391d88489774d705c411a52bc4ee3ede56af059.zip
Only increase/decrease if the diff>1000
-rw-r--r--cputemp2maxfreq.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c
index ad27062..5b84e70 100644
--- a/cputemp2maxfreq.c
+++ b/cputemp2maxfreq.c
@@ -184,11 +184,12 @@ int main(int argc,char **argv)
}
if (config.csvfile!=NULL) csvlog_write();
+ diff=config.max_temp-cpudata.cur_temp;
+
// Check if we should increase
- if ((cpudata.cur_temp<config.max_temp) && (cpudata.scale_max<cpudata.max_freq))
+ if ((diff>=1000) && (cpudata.scale_max<cpudata.max_freq))
{
- diff=(config.max_temp-cpudata.cur_temp)/1000;
- newfreq=cpudata.scale_max+(config.freq_step*diff);
+ newfreq=cpudata.scale_max+(config.freq_step*(diff/1000));
if (newfreq>cpudata.max_freq) newfreq=cpudata.max_freq;
DEBUG1_MAIN("Increase to %ld\n",newfreq);
config.logger("Increase scaling_max_freq to %ld",newfreq);
@@ -208,10 +209,9 @@ int main(int argc,char **argv)
}
// Check if we should decrease
- if ((cpudata.cur_temp>config.max_temp) && (cpudata.scale_max>cpudata.min_freq))
+ if ((diff<=-1000) && (cpudata.scale_max>cpudata.min_freq))
{
- diff=(cpudata.cur_temp-config.max_temp)/1000;
- newfreq=cpudata.scale_max-(config.freq_step*diff);
+ newfreq=cpudata.scale_max+(config.freq_step*(diff/1000));
if (newfreq<cpudata.min_freq) newfreq=cpudata.min_freq;
DEBUG1_MAIN("Decrease to %ld\n",newfreq);
config.logger("Decrease scaling_max_freq to %ld",newfreq);