diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-10-12 13:39:51 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-10-12 13:39:51 +0000 |
commit | 25399137b2049d8c660c7d2d02a0588cfd2d0581 (patch) | |
tree | 3e927df3dc1e168a17ba7778f1c06eb5e5c276c7 /sys/kern | |
parent | 4557e0d8a16da274ab74684f9f41d28bfca45095 (diff) |
Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.
This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.
ok cheloha@, patrick@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_time.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 7745cd88782..45911a3867d 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.157 2022/08/14 01:58:27 jsg Exp $ */ +/* $OpenBSD: kern_time.c,v 1.158 2022/10/12 13:39:50 kettenis Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -951,7 +951,9 @@ resettodr(void) void todr_attach(struct todr_chip_handle *todr) { - todr_handle = todr; + if (todr_handle == NULL || + todr->todr_quality > todr_handle->todr_quality) + todr_handle = todr; } #define RESETTODR_PERIOD 1800 |