diff options
author | 2021-02-02 14:21:31 -0800 | |
---|---|---|
committer | 2021-02-02 14:21:31 -0800 | |
commit | d1e1355aefcc0cbda750a8931e93e1e04a5b0b6a (patch) | |
tree | f43b81751cb5c5736268057ecdbcdb99dd00e826 /drivers/rtc/rtc-mc146818-lib.c | |
parent | Merge branch 'rework-the-memory-barrier-for-scrq-entry' (diff) | |
parent | Merge tag 'clang-format-for-linux-v5.11-rc7' of git://github.com/ojeda/linux (diff) | |
download | wireguard-linux-d1e1355aefcc0cbda750a8931e93e1e04a5b0b6a.tar.xz wireguard-linux-d1e1355aefcc0cbda750a8931e93e1e04a5b0b6a.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/rtc/rtc-mc146818-lib.c')
-rw-r--r-- | drivers/rtc/rtc-mc146818-lib.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index 972a5b9a629d..f83c13818af3 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -21,6 +21,13 @@ unsigned int mc146818_get_time(struct rtc_time *time) again: spin_lock_irqsave(&rtc_lock, flags); + /* Ensure that the RTC is accessible. Bit 0-6 must be 0! */ + if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x7f) != 0)) { + spin_unlock_irqrestore(&rtc_lock, flags); + memset(time, 0xff, sizeof(*time)); + return 0; + } + /* * Check whether there is an update in progress during which the * readout is unspecified. The maximum update time is ~2ms. Poll |