summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Wei Liew <zhaoweiliew@gmail.com>2018-11-02 00:33:14 +0000
committerBruno Martins <bgcngm@gmail.com>2018-11-07 17:46:07 +0100
commit143f8079c5a81ff669fba1496e7c98fcd42a1d24 (patch)
treec1bc57c8acac8a5213a178ee95b73cd7421035ad
parent591f59036fdb29c49139dfde1f5447517e9748b6 (diff)
downloadandroid_hardware_qcom_power-143f8079c5a81ff669fba1496e7c98fcd42a1d24.tar.gz
android_hardware_qcom_power-143f8079c5a81ff669fba1496e7c98fcd42a1d24.tar.bz2
android_hardware_qcom_power-143f8079c5a81ff669fba1496e7c98fcd42a1d24.zip
Cache SOC ID checks for future queries
Currently, get_soc_id() is queried on every SOC ID check in the SDM660, MSM8916, and MSM8974-family HALs. This results in extraneous file operations on every SOC ID check. Cache the result of get_soc_id() during the first query to reduce the number of file operations being made. This also brings back the behaviour in LineageOS 15.1 when the HALs were still stored in device/qcom/common. Change-Id: Ic17dbf12e7f9ecdb47b73a580f467df9ad630aa0
-rw-r--r--power-660.c13
-rw-r--r--power-8916.c13
-rw-r--r--power-8974.c13
3 files changed, 18 insertions, 21 deletions
diff --git a/power-660.c b/power-660.c
index ac1137e..0bec132 100644
--- a/power-660.c
+++ b/power-660.c
@@ -140,19 +140,18 @@ static int set_power_profile(int profile)
}
/**
- * If target is SDM630:
- * return true
- * else:
- * return false
+ * Returns true if the target is SDM630.
*/
static bool is_target_SDM630(void)
{
- static bool is_SDM630 = false;
+ static int is_SDM630 = -1;
int soc_id;
+ if (is_SDM630 >= 0)
+ return is_SDM630;
+
soc_id = get_soc_id();
- if (soc_id == 318 || soc_id == 327)
- is_SDM630 = true;
+ is_SDM630 = soc_id == 318 || soc_id == 327;
return is_SDM630;
}
diff --git a/power-8916.c b/power-8916.c
index 190b336..66b57e7 100644
--- a/power-8916.c
+++ b/power-8916.c
@@ -60,19 +60,18 @@ const char *scaling_min_freq[4] = {
};
/**
- * If target is 8916:
- * return true
- * else:
- * return false
+ * Returns true if the target is MSM8916.
*/
static bool is_target_8916(void)
{
- static bool is_8916 = false;
+ static int is_8916 = -1;
int soc_id;
+ if (is_8916 >= 0)
+ return is_8916;
+
soc_id = get_soc_id();
- if (soc_id == 206 || (soc_id >= 247 && soc_id <= 250))
- is_8916 = true;
+ is_8916 = soc_id == 206 || (soc_id >= 247 && soc_id <= 250);
return is_8916;
}
diff --git a/power-8974.c b/power-8974.c
index adad79e..94d4125 100644
--- a/power-8974.c
+++ b/power-8974.c
@@ -53,19 +53,18 @@
static int first_display_off_hint;
/**
- * If target is 8974pro:
- * return true
- * else:
- * return false
+ * Returns true if the target is MSM8974AB or MSM8974AC.
*/
static bool is_target_8974pro(void)
{
- static bool is_8974pro = false;
+ static int is_8974pro = -1;
int soc_id;
+ if (is_8974pro >= 0)
+ return is_8974pro;
+
soc_id = get_soc_id();
- if (soc_id == 194 || (soc_id >= 208 && soc_id <= 218))
- is_8974pro = true;
+ is_8974pro = soc_id == 194 || (soc_id >= 208 && soc_id <= 218);
return is_8974pro;
}