diff options
author | Corinna Vinschen <xda@vinschen.de> | 2018-04-10 11:57:37 +0200 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-10-23 01:12:56 +0300 |
commit | 71c7488ae10003c7d2f28fb68bd1188b1a426793 (patch) | |
tree | f40b4829b79a17a0386e87f1d3906db954effc43 | |
parent | 7dbfef3f4f963a5b05655346d0b4db2a0d27044a (diff) | |
download | android_vendor_qcom_opensource_power-71c7488ae10003c7d2f28fb68bd1188b1a426793.tar.gz android_vendor_qcom_opensource_power-71c7488ae10003c7d2f28fb68bd1188b1a426793.tar.bz2 android_vendor_qcom_opensource_power-71c7488ae10003c7d2f28fb68bd1188b1a426793.zip |
power: fix sysfs_read/sysfs_write usage
* The incoming path to sysfs_read/sysfs_write should be const, as in
open(2) call.
* Redefine scaling_gov_path as const pointer array.
* Since sysfs_read works on a simple absolute path anyway, make sure
the scaling_gov_path paths *are* absolute. Otherwise the code only
works if Power HAL has / as CWD, which is a bit fragile.
Change-Id: I70c08f8137842569514bcb3f6e0617d46044e6ab
Signed-off-by: Corinna Vinschen <xda@vinschen.de>
-rw-r--r-- | power-8916.c | 8 | ||||
-rw-r--r-- | utils.c | 12 | ||||
-rw-r--r-- | utils.h | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/power-8916.c b/power-8916.c index 3774418..4bf8c0c 100644 --- a/power-8916.c +++ b/power-8916.c @@ -51,10 +51,10 @@ #define MIN_FREQ_CPU0_DISP_OFF 400000 #define MIN_FREQ_CPU0_DISP_ON 960000 -char scaling_min_freq[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", - "sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq", - "sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq", - "sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq"}; +const char* scaling_min_freq[4] = {"/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", + "/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq", + "/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq", + "/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq"}; static int slack_node_rw_failed = 0; @@ -46,10 +46,10 @@ #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", - "sys/devices/system/cpu/cpu2/cpufreq/scaling_governor", - "sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"}; +const char* scaling_gov_path[4] = {"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"}; #define PERF_HAL_PATH "libqti-perfd-client.so" static void* qcopt_handle; @@ -117,7 +117,7 @@ static void __attribute__((destructor)) cleanup(void) { } } -int sysfs_read(char* path, char* s, int num_bytes) { +int sysfs_read(const char* path, char* s, int num_bytes) { char buf[80]; int count; int ret = 0; @@ -144,7 +144,7 @@ int sysfs_read(char* path, char* s, int num_bytes) { return ret; } -int sysfs_write(char* path, char* s) { +int sysfs_write(const char* path, char* s) { char buf[80]; int len; int ret = 0; @@ -29,8 +29,8 @@ #include <cutils/properties.h> -int sysfs_read(char* path, char* s, int num_bytes); -int sysfs_write(char* path, char* s); +int sysfs_read(const char* path, char* s, int num_bytes); +int sysfs_write(const char* path, char* s); int get_scaling_governor(char governor[], int size); int get_scaling_governor_check_cores(char governor[], int size, int core_num); int is_interactive_governor(char*); |