int main(int argc, char* argv[]) { _cleanup_strv_free_ char **standby = strv_new("standby", NULL), **mem = strv_new("mem", NULL), **disk = strv_new("disk", NULL), **suspend = strv_new("suspend", NULL), **reboot = strv_new("reboot", NULL), **platform = strv_new("platform", NULL), **shutdown = strv_new("shutdown", NULL), **freez = strv_new("freeze", NULL); log_info("Can Standby: %s", yes_no(can_sleep_state(standby) > 0)); log_info("Can Suspend: %s", yes_no(can_sleep_state(mem) > 0)); log_info("Can Hibernate: %s", yes_no(can_sleep_state(disk) > 0)); log_info("Can Hibernate+Suspend (Hybrid-Sleep): %s", yes_no(can_sleep_disk(suspend) > 0)); log_info("Can Hibernate+Reboot: %s", yes_no(can_sleep_disk(reboot) > 0)); log_info("Can Hibernate+Platform: %s", yes_no(can_sleep_disk(platform) > 0)); log_info("Can Hibernate+Shutdown: %s", yes_no(can_sleep_disk(shutdown) > 0)); log_info("Can Freeze: %s", yes_no(can_sleep_disk(freez) > 0)); log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0)); log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0)); log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0)); return 0; }
static void test_sleep(void) { _cleanup_strv_free_ char **standby = strv_new("standby", NULL), **mem = strv_new("mem", NULL), **disk = strv_new("disk", NULL), **suspend = strv_new("suspend", NULL), **reboot = strv_new("reboot", NULL), **platform = strv_new("platform", NULL), **shutdown = strv_new("shutdown", NULL), **freez = strv_new("freeze", NULL); int r; log_info("/* configuration */"); log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0)); log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0)); log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0)); log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0)); log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0)); log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0)); log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0)); log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0)); log_info("/* running system */"); r = can_sleep("suspend"); log_info("Suspend configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); r = can_sleep("hibernate"); log_info("Hibernation configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); r = can_sleep("hybrid-sleep"); log_info("Hybrid-sleep configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); r = can_sleep("suspend-then-hibernate"); log_info("Suspend-then-Hibernate configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); }
static void serial_asleep(struct hci_uart *hu) { struct brcm_struct *lbrcm = (struct brcm_struct *)hu->priv; unsigned long flags; if (lbrcm->hcibrcm_state_serial == HCIBRCM_ASLEEP) return; lbrcm->inactive_period_serial += TIMER_PERIOD; if (lbrcm->inactive_period_serial < HOST_CONTROLLER_IDLE_TSH_SERIAL) return; if (!can_sleep(hu)) return; spin_lock_irqsave(&lbrcm->hcibrcm_lock, flags); __brcm_msm_serial_clock_request_off(hu->tty); lbrcm->hcibrcm_state_serial = HCIBRCM_ASLEEP; spin_unlock_irqrestore(&lbrcm->hcibrcm_lock, flags); BT_DBG("bluetooth serial clock off"); }