power: Keep boostpulse fd opened
No one else should be writing to this, so keep the fd
opened.
Change-Id: I4258f7f7d69250f4832a67807031ab3faa9ff586
diff --git a/power/power.c b/power/power.c
index 35946db..12b3440 100644
--- a/power/power.c
+++ b/power/power.c
@@ -62,7 +62,6 @@
};
static enum power_profile_e current_power_profile = PROFILE_BALANCED;
-static bool boostpulse_warned = false;
/**********************************************************
*** HELPER FUNCTIONS
@@ -140,29 +139,32 @@
close(fd);
}
+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));
+ }
+}
+
+static void send_boostpulse(int boostpulse_fd)
+{
+ int len;
+
+ if (boostpulse_fd < 0) {
+ return;
+ }
+
+ len = write(boostpulse_fd, "1", 1);
+ if (len < 0) {
+ ALOGE("Error writing to %s: %s", BOOSTPULSE_PATH, strerror(errno));
+ }
+}
+
/**********************************************************
*** POWER FUNCTIONS
**********************************************************/
-/* You need to request the powerhal lock before calling this function */
-static int boostpulse_open(struct samsung_power_module *samsung_pwr)
-{
- char errno_str[64];
-
- 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;
- }
- }
- }
-
- return samsung_pwr->boostpulse_fd;
-}
-
static void set_power_profile(struct samsung_power_module *samsung_pwr,
int profile)
{
@@ -413,16 +415,7 @@
}
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: {