diff --git a/power/power.c b/power/power.c index 35946db5..12b3440b 100644 --- a/power/power.c +++ b/power/power.c @@ -62,7 +62,6 @@ enum power_profile_e { }; static enum power_profile_e current_power_profile = PROFILE_BALANCED; -static bool boostpulse_warned = false; /********************************************************** *** HELPER FUNCTIONS @@ -140,29 +139,32 @@ static void boost(int32_t duration_us) close(fd); } -/********************************************************** - *** POWER FUNCTIONS - **********************************************************/ +static void boostpulse_open(struct samsung_power_module *samsung_pwr) +{ + samsung_pwr->boostpulse_fd = open(BOOSTPULSE_PATH, O_WRONLY); + if (samsung_pwr->boostpulse_fd < 0) { + ALOGE("Error opening %s: %s\n", BOOSTPULSE_PATH, strerror(errno)); + } +} -/* You need to request the powerhal lock before calling this function */ -static int boostpulse_open(struct samsung_power_module *samsung_pwr) +static void send_boostpulse(int boostpulse_fd) { - char errno_str[64]; + int len; - if (samsung_pwr->boostpulse_fd < 0) { - samsung_pwr->boostpulse_fd = open(BOOSTPULSE_PATH, O_WRONLY); - if (samsung_pwr->boostpulse_fd < 0) { - if (!boostpulse_warned) { - strerror_r(errno, errno_str, sizeof(errno_str)); - ALOGE("Error opening %s: %s", BOOSTPULSE_PATH, errno_str); - boostpulse_warned = true; - } - } + if (boostpulse_fd < 0) { + return; } - return samsung_pwr->boostpulse_fd; + len = write(boostpulse_fd, "1", 1); + if (len < 0) { + ALOGE("Error writing to %s: %s", BOOSTPULSE_PATH, strerror(errno)); + } } +/********************************************************** + *** POWER FUNCTIONS + **********************************************************/ + static void set_power_profile(struct samsung_power_module *samsung_pwr, int profile) { @@ -413,16 +415,7 @@ static void samsung_power_hint(struct power_module *module, } ALOGV("%s: POWER_HINT_INTERACTION", __func__); - - if (boostpulse_open(samsung_pwr) >= 0) { - len = write(samsung_pwr->boostpulse_fd, "1", 1); - - if (len < 0) { - strerror_r(errno, errno_str, sizeof(errno_str)); - ALOGE("Error writing to %s: %s", BOOSTPULSE_PATH, errno_str); - } - } - + send_boostpulse(samsung_pwr->boostpulse_fd); break; } case POWER_HINT_VSYNC: {