summaryrefslogtreecommitdiffstats
path: root/libsuspend/autosuspend_wakeup_count.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsuspend/autosuspend_wakeup_count.c')
-rw-r--r--libsuspend/autosuspend_wakeup_count.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libsuspend/autosuspend_wakeup_count.c b/libsuspend/autosuspend_wakeup_count.c
index ee4ebe7..23a0290 100644
--- a/libsuspend/autosuspend_wakeup_count.c
+++ b/libsuspend/autosuspend_wakeup_count.c
@@ -19,6 +19,7 @@
#include <pthread.h>
#include <semaphore.h>
#include <stddef.h>
+#include <stdbool.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -38,7 +39,7 @@ static int wakeup_count_fd;
static pthread_t suspend_thread;
static sem_t suspend_lockout;
static const char *sleep_state = "mem";
-static void (*wakeup_func)(void) = NULL;
+static void (*wakeup_func)(bool success) = NULL;
static void *suspend_thread_func(void *arg __attribute__((unused)))
{
@@ -46,6 +47,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
char wakeup_count[20];
int wakeup_count_len;
int ret;
+ bool success;
while (1) {
usleep(100000);
@@ -72,6 +74,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
continue;
}
+ success = true;
ALOGV("%s: write %*s to wakeup_count\n", __func__, wakeup_count_len, wakeup_count);
ret = TEMP_FAILURE_RETRY(write(wakeup_count_fd, wakeup_count, wakeup_count_len));
if (ret < 0) {
@@ -81,13 +84,11 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
ALOGV("%s: write %s to %s\n", __func__, sleep_state, SYS_POWER_STATE);
ret = TEMP_FAILURE_RETRY(write(state_fd, sleep_state, strlen(sleep_state)));
if (ret < 0) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error writing to %s: %s\n", SYS_POWER_STATE, buf);
- } else {
- void (*func)(void) = wakeup_func;
- if (func != NULL) {
- (*func)();
- }
+ success = false;
+ }
+ void (*func)(bool success) = wakeup_func;
+ if (func != NULL) {
+ (*func)(success);
}
}
@@ -139,7 +140,7 @@ static int autosuspend_wakeup_count_disable(void)
return ret;
}
-void set_wakeup_callback(void (*func)(void))
+void set_wakeup_callback(void (*func)(bool success))
{
if (wakeup_func != NULL) {
ALOGE("Duplicate wakeup callback applied, keeping original");