]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep: introduce sleep_operation_is_hibernation
authorMike Yuan <me@yhndnzj.com>
Thu, 26 Oct 2023 12:27:12 +0000 (20:27 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 27 Oct 2023 09:57:03 +0000 (17:57 +0800)
src/shared/sleep-config.c
src/shared/sleep-config.h
src/sleep/sleep.c

index ab095303557e46631c474a75a9d23e960ee8f3f8..77b5ee5b841c20082b28cc54d337bebc09097792 100644 (file)
@@ -305,7 +305,7 @@ static int sleep_supported_internal(
                 return false;
         }
 
-        if (IN_SET(operation, SLEEP_HIBERNATE, SLEEP_HYBRID_SLEEP)) {
+        if (sleep_operation_is_hibernation(operation)) {
                 r = sleep_mode_supported(sleep_config->modes[operation]);
                 if (r < 0)
                         return r;
index bc10a5b39bbf6a629a6598f2f77f7e172e913631..bc5aeb91bd62f78d80cadf43c3a4c58ae0b66320 100644 (file)
@@ -20,6 +20,10 @@ typedef enum SleepOperation {
 const char* sleep_operation_to_string(SleepOperation s) _const_;
 SleepOperation sleep_operation_from_string(const char *s) _pure_;
 
+static inline bool sleep_operation_is_hibernation(SleepOperation operation) {
+        return IN_SET(operation, SLEEP_HIBERNATE, SLEEP_HYBRID_SLEEP);
+}
+
 typedef struct SleepConfig {
         bool allow[_SLEEP_OPERATION_MAX];
 
index 8bfc9ee6cc7b7683426d2644e00c1487e62d73cd..354044c67c84fb6cecb949345ef0e53926e9dbea 100644 (file)
@@ -284,7 +284,7 @@ static int execute(
         setvbuf(f, NULL, _IONBF, 0);
 
         /* Configure hibernation settings if we are supposed to hibernate */
-        if (!strv_isempty(modes)) {
+        if (sleep_operation_is_hibernation(operation)) {
                 bool resume_set;
 
                 r = find_suitable_hibernation_device(&hibernation_device);