From: Mike Yuan Date: Mon, 23 Oct 2023 13:19:29 +0000 (+0800) Subject: sleep-config: check sleep mode only when hibernation X-Git-Tag: v255-rc1~158^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F29681%2Fhead;p=thirdparty%2Fsystemd.git sleep-config: check sleep mode only when hibernation With the previous change, this should only be used when doing hibernation. --- diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 03d04775e61..b63071a6928 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -309,15 +309,15 @@ static int sleep_supported_internal( return false; } - r = sleep_mode_supported(sleep_config->modes[operation]); - if (r < 0) - return r; - if (r == 0) { - *ret_support = SLEEP_STATE_OR_MODE_NOT_SUPPORTED; - return false; - } - if (IN_SET(operation, SLEEP_HIBERNATE, SLEEP_HYBRID_SLEEP)) { + r = sleep_mode_supported(sleep_config->modes[operation]); + if (r < 0) + return r; + if (r == 0) { + *ret_support = SLEEP_STATE_OR_MODE_NOT_SUPPORTED; + return false; + } + r = hibernation_is_safe(); if (r == -ENOTRECOVERABLE) { *ret_support = SLEEP_RESUME_NOT_SUPPORTED; @@ -329,7 +329,8 @@ static int sleep_supported_internal( } if (r < 0) return r; - } + } else + assert(!sleep_config->modes[operation]); *ret_support = SLEEP_SUPPORTED; return true;