@@ -102,7 +102,7 @@ static int rtc_resume(struct device *dev)
struct timespec64 sleep_time;
int err;
- if (has_persistent_clock())
+ if (timekeeping_sleeptime_injected())
return 0;
rtc_hctosys_ret = -ENODEV;
@@ -225,6 +225,7 @@ static inline void timekeeping_clocktai(struct timespec *ts)
/*
* RTC specific
*/
+extern bool timekeeping_sleeptime_injected(void);
extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
/*
@@ -1125,12 +1125,26 @@ static void
__timekeeping_inject_sleeptime(struct timekeeper *tk,
tk_debug_account_sleep_time(delta);
}
+static bool sleeptime_inject;
+
+#if defined(CONFIG_RTC_CLASS) && \
+ defined(CONFIG_PM_SLEEP) && \
+ defined(CONFIG_RTC_HCTOSYS_DEVICE)
+/**
+ * Used by rtc_resume().
+ */
+bool timekeeping_sleeptime_injected(void)
+{
+ return sleeptime_inject;
+}
+
/**
* timekeeping_inject_sleeptime64 - Adds suspend interval to
timeekeeping values
* @delta: pointer to a timespec64 delta value
*
* This hook is for architectures that cannot support read_persistent_clock
- * because their RTC/persistent clock is only accessible when irqs are enabled.
+ * because their RTC/persistent clock is only accessible when irqs are enabled,
+ * and also don't have an effective nonstop clocksource.
*