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
This commit is contained in:
Zhao Wei Liew
2018-11-02 00:33:14 +00:00
committed by Michael Bestas
parent 7ff6620596
commit f87f9daa0c
3 changed files with 15 additions and 18 deletions

View File

@@ -57,17 +57,16 @@ static int video_encode_hint_sent;
static void process_video_encode_hint(void* metadata);
/**
* If target is SDM630/SDM455:
* return true
* else:
* return false
* Returns true if the target is SDM630/SDM455.
*/
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 || soc_id == 385) is_SDM630 = true;
is_SDM630 = soc_id == 318 || soc_id == 327 || soc_id == 385;
return is_SDM630;
}

View File

@@ -56,17 +56,16 @@ static int video_encode_hint_sent;
static void process_video_encode_hint(void* metadata);
/**
* 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;
}

View File

@@ -57,17 +57,16 @@ static int video_encode_hint_sent;
static void process_video_encode_hint(void* metadata);
/**
* 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;
}