mirror of
https://github.com/apache/nuttx.git
synced 2026-10-04 12:48:09 +00:00
sched/clock: Keep RTC synchronized with timekeeping.
Move RTC synchronization outside the non-timekeeping branch so setting CLOCK_REALTIME also updates the RTC when CONFIG_CLOCK_TIMEKEEPING is enabled. This prevents corrected wall time from reverting to an older RTC value after restart. Preserve the existing low-priority work queue path for RTC drivers that may block while updating hardware. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
parent
36c0dce6d1
commit
c02024b45d
1 changed files with 10 additions and 9 deletions
|
|
@ -89,12 +89,16 @@ static void nxclock_set_realtime(FAR const struct timespec *tp)
|
|||
|
||||
spin_unlock_irqrestore(&g_basetime_lock, flags);
|
||||
|
||||
#else
|
||||
clock_timekeeping_set_wall_time(tp);
|
||||
#endif
|
||||
|
||||
/* Setup the RTC (lo- or high-res) */
|
||||
|
||||
# ifdef CONFIG_RTC
|
||||
#ifdef CONFIG_RTC
|
||||
if (g_rtc_enabled)
|
||||
{
|
||||
# ifdef CONFIG_SCHED_LPWORK
|
||||
# ifdef CONFIG_SCHED_LPWORK
|
||||
/* Setting the current time in RTC may be a blocking operation (driver
|
||||
* needs to wait for oscillator stabilization after reset and so on).
|
||||
* This may cause the unwanted effect of clock_settime blocking the
|
||||
|
|
@ -109,19 +113,16 @@ static void nxclock_set_realtime(FAR const struct timespec *tp)
|
|||
g_rtc_to_set = *tp;
|
||||
work_queue(LPWORK, &g_rtc_work, rtc_worker,
|
||||
(FAR void *)&g_rtc_to_set, 0);
|
||||
# else
|
||||
# else
|
||||
up_rtc_settime(tp);
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifdef CONFIG_CLOCK_ADJTIME
|
||||
#if defined(CONFIG_CLOCK_ADJTIME) && !defined(CONFIG_CLOCK_TIMEKEEPING)
|
||||
/* Cancel any ongoing adjustment */
|
||||
|
||||
adjtime(&zerodelta, NULL);
|
||||
# endif
|
||||
#else
|
||||
clock_timekeeping_set_wall_time(tp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue