diff options
author | Zhao Wei Liew <zhaoweiliew@gmail.com> | 2016-07-19 19:57:06 +0800 |
---|---|---|
committer | Zhao Wei Liew <zhaoweiliew@gmail.com> | 2016-07-23 09:12:34 +0800 |
commit | 9e40a0e0c47b38455d515df4900e24a547a6863f (patch) | |
tree | 6857825ca226c0b022d8cbaaf72a3bbd579ffe0d /power/utils.c | |
parent | 8485af000a94e46a759560b795fdb834d9c2d46e (diff) |
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 'power/utils.c')
-rw-r--r-- | power/utils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/power/utils.c b/power/utils.c index c1ea78a..202b718 100644 --- a/power/utils.c +++ b/power/utils.c @@ -42,6 +42,9 @@ #define LOG_TAG "QCOM PowerHAL" #include <utils/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", @@ -388,3 +391,24 @@ void start_prefetch(int pid, const char* packageName) { } } +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; +} |