From 9bb7f33948807f7c1c6b3131b22a15e21b2a8e61 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liew Date: Fri, 2 Nov 2018 00:33:14 +0000 Subject: 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 --- power-8953.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'power-8953.c') diff --git a/power-8953.c b/power-8953.c index cd372d7..3b85a04 100644 --- a/power-8953.c +++ b/power-8953.c @@ -62,17 +62,16 @@ static int display_fd; #define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr" /** - * If target is SDM632: - * return true - * else: - * return false + * Returns true if the target is SDM632. */ static bool is_target_SDM632(void) { - static bool is_SDM632 = false; + static int is_SDM632 = -1; int soc_id; + if (is_SDM632 >= 0) return is_SDM632; + soc_id = get_soc_id(); - if (soc_id == 349 || soc_id == 350) is_SDM632 = true; + is_SDM632 = soc_id == 349 || soc_id == 350; return is_SDM632; } -- cgit v1.2.3