richardphibel / rpms / systemd

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