teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0210-sleep-rename-hibernate_delay_sec-_usec.patch

2aacef
From 51a4778726edd7dfad18e7354bda1d77730c8dd8 Mon Sep 17 00:00:00 2001
2aacef
From: Yu Watanabe <watanabe.yu+github@gmail.com>
2aacef
Date: Sun, 13 Nov 2022 23:59:49 +0900
2aacef
Subject: [PATCH] sleep: rename hibernate_delay_sec -> _usec
2aacef
2aacef
(cherry picked from commit 3d23df005e06b3616049686be82deff55788d3c4)
2aacef
2aacef
Related: #2151612
2aacef
---
2aacef
 src/shared/sleep-config.c | 6 +++---
2aacef
 src/shared/sleep-config.h | 2 +-
2aacef
 src/sleep/sleep.c         | 2 +-
2aacef
 3 files changed, 5 insertions(+), 5 deletions(-)
2aacef
2aacef
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
2aacef
index efc066c4f2..359d293fd0 100644
2aacef
--- a/src/shared/sleep-config.c
2aacef
+++ b/src/shared/sleep-config.c
2aacef
@@ -82,7 +82,7 @@ int parse_sleep_config(SleepConfig **ret_sleep_config) {
2aacef
                 { "Sleep", "HybridSleepMode",           config_parse_strv,     0, sc->modes + SLEEP_HYBRID_SLEEP  },
2aacef
                 { "Sleep", "HybridSleepState",          config_parse_strv,     0, sc->states + SLEEP_HYBRID_SLEEP },
2aacef
 
2aacef
-                { "Sleep", "HibernateDelaySec",         config_parse_sec,      0, &sc->hibernate_delay_sec        },
2aacef
+                { "Sleep", "HibernateDelaySec",         config_parse_sec,      0, &sc->hibernate_delay_usec       },
2aacef
                 {}
2aacef
         };
2aacef
 
2aacef
@@ -113,8 +113,8 @@ int parse_sleep_config(SleepConfig **ret_sleep_config) {
2aacef
                 sc->modes[SLEEP_HYBRID_SLEEP] = strv_new("suspend", "platform", "shutdown");
2aacef
         if (!sc->states[SLEEP_HYBRID_SLEEP])
2aacef
                 sc->states[SLEEP_HYBRID_SLEEP] = strv_new("disk");
2aacef
-        if (sc->hibernate_delay_sec == 0)
2aacef
-                sc->hibernate_delay_sec = 2 * USEC_PER_HOUR;
2aacef
+        if (sc->hibernate_delay_usec == 0)
2aacef
+                sc->hibernate_delay_usec = 2 * USEC_PER_HOUR;
2aacef
 
2aacef
         /* ensure values set for all required fields */
2aacef
         if (!sc->states[SLEEP_SUSPEND] || !sc->modes[SLEEP_HIBERNATE]
2aacef
diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h
2aacef
index 6645c3e596..226fab4b9f 100644
2aacef
--- a/src/shared/sleep-config.h
2aacef
+++ b/src/shared/sleep-config.h
2aacef
@@ -19,7 +19,7 @@ typedef struct SleepConfig {
2aacef
         bool allow[_SLEEP_OPERATION_MAX];
2aacef
         char **modes[_SLEEP_OPERATION_MAX];
2aacef
         char **states[_SLEEP_OPERATION_MAX];
2aacef
-        usec_t hibernate_delay_sec;
2aacef
+        usec_t hibernate_delay_usec;
2aacef
 } SleepConfig;
2aacef
 
2aacef
 SleepConfig* free_sleep_config(SleepConfig *sc);
2aacef
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
2aacef
index 3461d3e45f..7679f2e3be 100644
2aacef
--- a/src/sleep/sleep.c
2aacef
+++ b/src/sleep/sleep.c
2aacef
@@ -275,7 +275,7 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) {
2aacef
         while (battery_is_low() == 0) {
2aacef
                 _cleanup_close_ int tfd = -1;
2aacef
                 struct itimerspec ts = {};
2aacef
-                usec_t suspend_interval = sleep_config->hibernate_delay_sec, before_timestamp = 0, after_timestamp = 0, total_suspend_interval;
2aacef
+                usec_t suspend_interval = sleep_config->hibernate_delay_usec, before_timestamp = 0, after_timestamp = 0, total_suspend_interval;
2aacef
                 bool woken_by_timer;
2aacef
 
2aacef
                 tfd = timerfd_create(CLOCK_BOOTTIME_ALARM, TFD_NONBLOCK|TFD_CLOEXEC);