diff options
| author | Zhao Wei Liew <zhaoweiliew@gmail.com> | 2018-11-02 00:33:14 +0000 |
|---|---|---|
| committer | Michael Bestas <mkbestas@lineageos.org> | 2019-10-23 01:12:56 +0300 |
| commit | 9bb7f33948807f7c1c6b3131b22a15e21b2a8e61 (patch) | |
| tree | 3af8c06044bee5b037b5d93912d598337a4e12fc /power-8952.c | |
| parent | c836c7344bfc3dd16a6aed674309575e0a23b0a9 (diff) | |
| download | vendor_qcom_opensource_power-9bb7f33948807f7c1c6b3131b22a15e21b2a8e61.tar.gz vendor_qcom_opensource_power-9bb7f33948807f7c1c6b3131b22a15e21b2a8e61.tar.bz2 vendor_qcom_opensource_power-9bb7f33948807f7c1c6b3131b22a15e21b2a8e61.zip | |
power: Cache SOC ID checks for future queries
Currently, get_soc_id() is queried on every SOC ID check in the
SDM660, MSM8916, MSM8952, MSM8953 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
Diffstat (limited to 'power-8952.c')
| -rw-r--r-- | power-8952.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/power-8952.c b/power-8952.c index 2fb3b19..d666700 100644 --- a/power-8952.c +++ b/power-8952.c @@ -58,17 +58,16 @@ static int display_fd; #define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr" /** - * If target is SDM439/429: - * return true - * else: - * return false + * Returns true if the target is SDM439/SDM429. */ static bool is_target_SDM439(void) { - static bool is_SDM439 = false; + static int is_SDM439 = -1; int soc_id; + if (is_SDM439 >= 0) return is_SDM439; + soc_id = get_soc_id(); - if (soc_id == 353 || soc_id == 363 || soc_id == 354 || soc_id == 364) is_SDM439 = true; + is_SDM439 = soc_id == 353 || soc_id == 363 || soc_id == 354 || soc_id == 364; return is_SDM439; } |
