From 878b5aa809f72baa3bcb816998b4ff3c46281ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 28 Jan 2024 07:49:18 +0100 Subject: [PATCH] Update powerkit_cpu.cpp --- src/powerkit_cpu.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/powerkit_cpu.cpp b/src/powerkit_cpu.cpp index 93e6a04..81908b4 100644 --- a/src/powerkit_cpu.cpp +++ b/src/powerkit_cpu.cpp @@ -127,10 +127,10 @@ const QStringList PowerCpu::getFrequencies() return result; } -// Legacy, remove? const QStringList PowerCpu::getAvailableFrequency() { QStringList result; + if (hasPState()) { return result; } QFile gov(QString("%1/cpu%2/%3/%4") .arg(LINUX_CPU_SYS) .arg(0) @@ -178,19 +178,20 @@ int PowerCpu::getScalingFrequency(int cpu, int scale) return result; } -// Legacy, remove? bool PowerCpu::frequencyExists(const QString &freq) { + if (hasPState()) { return false; } if (freq.isEmpty()) { return false; } return getAvailableFrequency().contains(freq); } bool PowerCpu::setFrequency(const QString &freq, int cpu) { - /*if (!frequencyExists(freq)) { return false; } + if (hasPState()) { return false; } + if (!frequencyExists(freq)) { return false; } if (getGovernor(cpu) != "userspace") { if (!setGovernor("userspace", cpu)) { return false; } - }*/ + } QString val = freq; int freqMin = getMinFrequency(); int freqMax = getMaxFrequency(); @@ -204,14 +205,15 @@ bool PowerCpu::setFrequency(const QString &freq, int cpu) QTextStream out(&file); out << val; file.close(); - if (val == getFrequency(cpu)) { return true; } // this might not work properly? + if (val == getFrequency(cpu)) { return true; } } return false; } bool PowerCpu::setFrequency(const QString &freq) { - //if (!frequencyExists(freq)) { return false; } + if (hasPState()) { return false; } + if (!frequencyExists(freq)) { return false; } bool failed = false; for (int i=0;i