power_hikey: Cleanup interactive boostpulse logic
am: 64b54ca01d
Change-Id: I57aba226b9b28b089447a218d4229d54eb908f0b
diff --git a/power/power_hikey.c b/power/power_hikey.c
index 2ac5576..bcfe473 100644
--- a/power/power_hikey.c
+++ b/power/power_hikey.c
@@ -121,37 +121,30 @@
ALOGV("power_set_interactive: %d done\n", on);
}
-static int interactive_boostpulse_open(struct hikey_power_module *hikey)
-{
- char buf[80];
- int len;
-
- if (hikey->boostpulse_fd < 0) {
- hikey->boostpulse_fd = open(BOOSTPULSE_PATH, O_WRONLY);
-
- if (hikey->boostpulse_fd < 0) {
- if (!hikey->boostpulse_warned) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error opening %s: %s\n", BOOSTPULSE_PATH, buf);
- hikey->boostpulse_warned = 1;
- }
- }
- }
- return hikey->boostpulse_fd;
-}
-
static int interactive_boostpulse(struct hikey_power_module *hikey)
{
char buf[80];
int len;
- if (interactive_boostpulse_open(hikey) >= 0) {
- len = write(hikey->boostpulse_fd, "1", 1);
+ if (hikey->boostpulse_fd < 0)
+ hikey->boostpulse_fd = open(BOOSTPULSE_PATH, O_WRONLY);
- if (len < 0) {
+ if (hikey->boostpulse_fd < 0) {
+ if (!hikey->boostpulse_warned) {
strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error writing to %s: %s\n", BOOSTPULSE_PATH, buf);
+ ALOGE("Error opening %s: %s\n", BOOSTPULSE_PATH,
+ buf);
+ hikey->boostpulse_warned = 1;
}
+ return hikey->boostpulse_fd;
+ }
+
+ len = write(hikey->boostpulse_fd, "1", 1);
+ if (len < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error writing to %s: %s\n",
+ BOOSTPULSE_PATH, buf);
+ return -1;
}
return 0;
}