diff --git a/power/power_bacon.c b/power/power_bacon.c index 7f0a53cf9..d537bac2f 100644 --- a/power/power_bacon.c +++ b/power/power_bacon.c @@ -42,14 +42,11 @@ #define SLEEP_USEC_BETWN_RETRY 200 #define LOW_POWER_MAX_FREQ "729600" #define LOW_POWER_MIN_FREQ "300000" -#define NORMAL_MAX_FREQ "1958400" -#define ABS_MAX_FREQ "2457600" +#define NORMAL_MAX_FREQ "2457600" #define UEVENT_STRING "online@/devices/system/cpu/" #define CPU_INPUT_BOOST_PATH "/sys/kernel/cpu_input_boost/userspace_minfreq" -#define MAXFREQ_SAVE_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" static struct pollfd pfd; -static char saved_maxfreq[20]; static char *cpu_path_min[] = { "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", "/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq", @@ -89,34 +86,6 @@ static int sysfs_write(const char *path, char *s) return 0; } -static int sysfs_read(char *path, char *s, int num_bytes) -{ - char buf[200]; - int count, len, ret = 0; - int fd = open(path, O_RDONLY); - - if (fd < 0) { - strerror_r(errno, buf, sizeof(buf)); - return -1; - } - - if ((count = read(fd, s, num_bytes - 1)) < 0) { - strerror_r(errno, buf, sizeof(buf)); - ret = -1; - } else - s[count] = '\0'; - - close(fd); - - if (!ret) { - len = strlen(s) - 1; - while (len >= 0 && (s[len] == '\n' || s[len] == '\r')) - s[len--] = '\0'; - } - - return ret; -} - static int uevent_event() { char msg[UEVENT_MSG_LEN]; @@ -144,7 +113,6 @@ static int uevent_event() pthread_mutex_lock(&low_power_mode_lock); if (low_power_mode && !freq_set[cpu]) { - sysfs_read(MAXFREQ_SAVE_PATH, saved_maxfreq, sizeof(saved_maxfreq)); sysfs_write(CPU_INPUT_BOOST_PATH, LOW_POWER_MIN_FREQ); while (retry) { sysfs_write(cpu_path_min[cpu], LOW_POWER_MIN_FREQ); @@ -159,9 +127,7 @@ static int uevent_event() } else if (!low_power_mode && freq_set[cpu]) { sysfs_write(CPU_INPUT_BOOST_PATH, "0"); while (retry) { - if (strncmp(saved_maxfreq, NORMAL_MAX_FREQ, sizeof(saved_maxfreq))) - strncpy(saved_maxfreq, ABS_MAX_FREQ, sizeof(saved_maxfreq)); - ret = sysfs_write(cpu_path_max[cpu], saved_maxfreq); + ret = sysfs_write(cpu_path_max[cpu], NORMAL_MAX_FREQ); if (!ret) { freq_set[cpu] = false; break; @@ -237,7 +203,6 @@ static void power_hint( __attribute__((unused)) struct power_module *module, pthread_mutex_lock(&low_power_mode_lock); if (data) { low_power_mode = true; - sysfs_read(MAXFREQ_SAVE_PATH, saved_maxfreq, sizeof(saved_maxfreq)); sysfs_write(CPU_INPUT_BOOST_PATH, LOW_POWER_MIN_FREQ); for (cpu = 0; cpu < TOTAL_CPUS; cpu++) { sysfs_write(cpu_path_min[cpu], LOW_POWER_MIN_FREQ); @@ -249,10 +214,8 @@ static void power_hint( __attribute__((unused)) struct power_module *module, } else { low_power_mode = false; sysfs_write(CPU_INPUT_BOOST_PATH, "0"); - if (strncmp(saved_maxfreq, NORMAL_MAX_FREQ, sizeof(saved_maxfreq))) - strncpy(saved_maxfreq, ABS_MAX_FREQ, sizeof(saved_maxfreq)); for (cpu = 0; cpu < TOTAL_CPUS; cpu++) { - ret = sysfs_write(cpu_path_max[cpu], saved_maxfreq); + ret = sysfs_write(cpu_path_max[cpu], NORMAL_MAX_FREQ); if (!ret) { freq_set[cpu] = false; }