summaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authorZhao Wei Liew <zhaoweiliew@gmail.com>2016-07-19 19:57:06 +0800
committerMichael Bestas <mkbestas@lineageos.org>2019-10-23 01:12:56 +0300
commit71131ea4e0f0a05a51443571970e4f74cb14de65 (patch)
tree5956a90ba3cd005f4c6a82e8a354cbb435dbb370 /utils.c
parentb989cae4900c6647bd5fddfd9930c01e999025ea (diff)
downloadvendor_qcom_opensource_power-71131ea4e0f0a05a51443571970e4f74cb14de65.tar.gz
vendor_qcom_opensource_power-71131ea4e0f0a05a51443571970e4f74cb14de65.tar.bz2
vendor_qcom_opensource_power-71131ea4e0f0a05a51443571970e4f74cb14de65.zip
power: Simplify soc_id checks
- Get soc_id in a common util function - Return boolean values for the target-specific soc_id checks Change-Id: I038c435d28855859f36566de7acf881037d070f2
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 57ffc91..6c769e6 100644
--- a/utils.c
+++ b/utils.c
@@ -43,6 +43,9 @@
#define LOG_TAG "QTI PowerHAL"
#include <log/log.h>
+#define SOC_ID_0 "/sys/devices/soc0/soc_id"
+#define SOC_ID_1 "/sys/devices/system/soc/soc0/id"
+
char scaling_gov_path[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
"sys/devices/system/cpu/cpu1/cpufreq/scaling_governor",
"sys/devices/system/cpu/cpu2/cpufreq/scaling_governor",
@@ -327,3 +330,24 @@ void undo_initial_hint_action() {
}
}
}
+
+int get_soc_id(void) {
+ int fd;
+ int soc_id = -1;
+ char buf[10] = {0};
+
+ if (!access(SOC_ID_0, F_OK))
+ fd = open(SOC_ID_0, O_RDONLY);
+ else
+ fd = open(SOC_ID_1, O_RDONLY);
+
+ if (fd >= 0) {
+ if (read(fd, buf, sizeof(buf) - 1) == -1)
+ ALOGW("Unable to read soc_id");
+ else
+ soc_id = atoi(buf);
+ }
+
+ close(fd);
+ return soc_id;
+}