Skip to content

Commit ebb22a0

Browse files
committed
rtc: mc146818: Dont test for bit 0-5 in Register D
The recent change to validate the RTC turned out to be overly tight. While it cures the problem on the reporters machine it breaks machines with Intel chipsets which use bit 0-5 of the D register. So check only for bit 6 being 0 which is the case on these Intel machines as well. Fixes: 211e5db ("rtc: mc146818: Detect and handle broken RTCs") Reported-by: Serge Belyshev <[email protected]> Reported-by: Dirk Gouders <[email protected]> Reported-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Dirk Gouders <[email protected]> Tested-by: Len Brown <[email protected]> Tested-by: Borislav Petkov <[email protected]> Acked-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 211e5db commit ebb22a0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/rtc/rtc-cmos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
805805

806806
spin_lock_irq(&rtc_lock);
807807

808-
/* Ensure that the RTC is accessible. Bit 0-6 must be 0! */
809-
if ((CMOS_READ(RTC_VALID) & 0x7f) != 0) {
808+
/* Ensure that the RTC is accessible. Bit 6 must be 0! */
809+
if ((CMOS_READ(RTC_VALID) & 0x40) != 0) {
810810
spin_unlock_irq(&rtc_lock);
811811
dev_warn(dev, "not accessible\n");
812812
retval = -ENXIO;

drivers/rtc/rtc-mc146818-lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ unsigned int mc146818_get_time(struct rtc_time *time)
2121

2222
again:
2323
spin_lock_irqsave(&rtc_lock, flags);
24-
/* Ensure that the RTC is accessible. Bit 0-6 must be 0! */
25-
if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x7f) != 0)) {
24+
/* Ensure that the RTC is accessible. Bit 6 must be 0! */
25+
if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x40) != 0)) {
2626
spin_unlock_irqrestore(&rtc_lock, flags);
2727
memset(time, 0xff, sizeof(*time));
2828
return 0;

0 commit comments

Comments
 (0)