Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidSystemCore
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemCore
Commits
bfec1488
Commit
bfec1488
authored
8 years ago
by
Tim Murray
Committed by
Android (Google) Code Review
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Revert "libsuspend: move to exponential backoff"" into nyc-mr1-dev
parents
eec5e52e
23c8bab0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libsuspend/autosuspend_wakeup_count.c
+5
-19
5 additions, 19 deletions
libsuspend/autosuspend_wakeup_count.c
with
5 additions
and
19 deletions
libsuspend/autosuspend_wakeup_count.c
+
5
−
19
View file @
bfec1488
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include
<stddef.h>
#include
<stddef.h>
#include
<stdbool.h>
#include
<stdbool.h>
#include
<string.h>
#include
<string.h>
#include
<sys/param.h>
#include
<sys/stat.h>
#include
<sys/stat.h>
#include
<sys/types.h>
#include
<sys/types.h>
#include
<unistd.h>
#include
<unistd.h>
...
@@ -35,24 +34,12 @@
...
@@ -35,24 +34,12 @@
#define SYS_POWER_STATE "/sys/power/state"
#define SYS_POWER_STATE "/sys/power/state"
#define SYS_POWER_WAKEUP_COUNT "/sys/power/wakeup_count"
#define SYS_POWER_WAKEUP_COUNT "/sys/power/wakeup_count"
#define BASE_SLEEP_TIME 100000
static
int
state_fd
;
static
int
state_fd
;
static
int
wakeup_count_fd
;
static
int
wakeup_count_fd
;
static
pthread_t
suspend_thread
;
static
pthread_t
suspend_thread
;
static
sem_t
suspend_lockout
;
static
sem_t
suspend_lockout
;
static
const
char
*
sleep_state
=
"mem"
;
static
const
char
*
sleep_state
=
"mem"
;
static
void
(
*
wakeup_func
)(
bool
success
)
=
NULL
;
static
void
(
*
wakeup_func
)(
bool
success
)
=
NULL
;
static
int
sleep_time
=
BASE_SLEEP_TIME
;
static
void
update_sleep_time
(
bool
success
)
{
if
(
success
)
{
sleep_time
=
BASE_SLEEP_TIME
;
return
;
}
// double sleep time after each failure up to one minute
sleep_time
=
MIN
(
sleep_time
*
2
,
60000000
);
}
static
void
*
suspend_thread_func
(
void
*
arg
__attribute__
((
unused
)))
static
void
*
suspend_thread_func
(
void
*
arg
__attribute__
((
unused
)))
{
{
...
@@ -60,12 +47,10 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
...
@@ -60,12 +47,10 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
char
wakeup_count
[
20
];
char
wakeup_count
[
20
];
int
wakeup_count_len
;
int
wakeup_count_len
;
int
ret
;
int
ret
;
bool
success
=
true
;
bool
success
;
while
(
1
)
{
while
(
1
)
{
update_sleep_time
(
success
);
usleep
(
100000
);
usleep
(
sleep_time
);
success
=
false
;
ALOGV
(
"%s: read wakeup_count
\n
"
,
__func__
);
ALOGV
(
"%s: read wakeup_count
\n
"
,
__func__
);
lseek
(
wakeup_count_fd
,
0
,
SEEK_SET
);
lseek
(
wakeup_count_fd
,
0
,
SEEK_SET
);
wakeup_count_len
=
TEMP_FAILURE_RETRY
(
read
(
wakeup_count_fd
,
wakeup_count
,
wakeup_count_len
=
TEMP_FAILURE_RETRY
(
read
(
wakeup_count_fd
,
wakeup_count
,
...
@@ -89,6 +74,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
...
@@ -89,6 +74,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
continue
;
continue
;
}
}
success
=
true
;
ALOGV
(
"%s: write %*s to wakeup_count
\n
"
,
__func__
,
wakeup_count_len
,
wakeup_count
);
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
));
ret
=
TEMP_FAILURE_RETRY
(
write
(
wakeup_count_fd
,
wakeup_count
,
wakeup_count_len
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -97,8 +83,8 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
...
@@ -97,8 +83,8 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
}
else
{
}
else
{
ALOGV
(
"%s: write %s to %s
\n
"
,
__func__
,
sleep_state
,
SYS_POWER_STATE
);
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
)));
ret
=
TEMP_FAILURE_RETRY
(
write
(
state_fd
,
sleep_state
,
strlen
(
sleep_state
)));
if
(
ret
>=
0
)
{
if
(
ret
<
0
)
{
success
=
tru
e
;
success
=
fals
e
;
}
}
void
(
*
func
)(
bool
success
)
=
wakeup_func
;
void
(
*
func
)(
bool
success
)
=
wakeup_func
;
if
(
func
!=
NULL
)
{
if
(
func
!=
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment