Last active
February 9, 2022 05:36
-
-
Save Geobm/b7de5ccbeb067f59e42e54c6e94e9db0 to your computer and use it in GitHub Desktop.
linux kernel power source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
power_attr(pm_async); | |
#ifdef CONFIG_SUSPEND | |
static ssize_t mem_sleep_show(struct kobject *kobj, struct kobj_attribute *attr,char *buf){ | |
char *s = buf; | |
suspend_state_t i; | |
for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++) | |
if (mem_sleep_states[i]) { | |
const char *label = mem_sleep_states[i]; | |
if (mem_sleep_current == i) | |
s += sprintf(s, "[%s] ", label); | |
else | |
s += sprintf(s, "%s ", label); | |
} | |
if (s != buf) | |
*(s-1) = '\n'; | |
return (s - buf); | |
} | |
static suspend_state_t decode_suspend_state(const char *buf, size_t n){ | |
suspend_state_t state; | |
char *p; | |
int len; | |
p = memchr(buf, '\n', n); | |
len = p ? p - buf : n; | |
for (state = PM_SUSPEND_MIN; state < PM_SUSPEND_MAX; state++) { | |
const char *label = mem_sleep_states[state]; | |
if (label && len == strlen(label) && !strncmp(buf, label, len)) | |
return state; | |
} | |
return PM_SUSPEND_ON; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment