]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep-config: check sleep mode only when hibernation 29681/head
authorMike Yuan <me@yhndnzj.com>
Mon, 23 Oct 2023 13:19:29 +0000 (21:19 +0800)
committerMike Yuan <me@yhndnzj.com>
Mon, 23 Oct 2023 15:12:27 +0000 (23:12 +0800)
With the previous change, this should only be used when
doing hibernation.

src/shared/sleep-config.c

index 03d04775e611c7b16919df13ac8f30e4e64a8b98..b63071a6928ed213f62890f315ee0c4395a0b38b 100644 (file)
@@ -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;