diff options
-rw-r--r-- | cputemp2maxfreq.c | 12 |
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); |