From: Mike Yuan Date: Thu, 26 Oct 2023 12:27:12 +0000 (+0800) Subject: sleep: introduce sleep_operation_is_hibernation X-Git-Tag: v255-rc1~108^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e024cdd270469371013a8f821aea30e5ab5a1065;p=thirdparty%2Fsystemd.git sleep: introduce sleep_operation_is_hibernation --- diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index ab095303557..77b5ee5b841 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -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; diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h index bc10a5b39bb..bc5aeb91bd6 100644 --- a/src/shared/sleep-config.h +++ b/src/shared/sleep-config.h @@ -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]; diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index 8bfc9ee6cc7..354044c67c8 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -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);