[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241122101031.68916-2-maxime.chevallier@bootlin.com>
Date: Fri, 22 Nov 2024 11:10:29 +0100
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: Alexandre Belloni <alexandre.belloni@...tlin.com>,
Artem Panfilov <panfilov.artyom@...il.com>
Cc: Maxime Chevallier <maxime.chevallier@...tlin.com>,
linux-rtc@...r.kernel.org,
linux-kernel@...r.kernel.org,
Alexis Lothoré <alexis.lothore@...tlin.com>,
thomas.petazzoni@...tlin.com
Subject: [PATCH 1/2] rtc: ab-eoz9: check the lowest voltage threshold first
When checking the internal status flags for time validity, 2 different
voltage thresholds are verified :
VLOW1 is at 2.1V and indicates that temperature monitoring isn't
possible at that voltage. This stops any temperature compensation and
can cause time deviations
VLOW2 is at 1.3V, below that voltage no timekeeping is possible.
In both cases, we consider the reported time to be unreliable and print
a warning.
The current code checks for VLOW1 undervoltage first, but as it is higher
than VLOW2 it will always trigger before the VLOW2 threshold is hit.
Make sure we first check the VLOW2 condition when checking time
validity.
Fixes: 67075b63cce2 ("rtc: add AB-RTCMC-32.768kHz-EOZ9 RTC support")
Signed-off-by: Maxime Chevallier <maxime.chevallier@...tlin.com>
---
drivers/rtc/rtc-ab-eoz9.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-ab-eoz9.c b/drivers/rtc/rtc-ab-eoz9.c
index 02f7d0711287..85853da258d2 100644
--- a/drivers/rtc/rtc-ab-eoz9.c
+++ b/drivers/rtc/rtc-ab-eoz9.c
@@ -116,15 +116,15 @@ static int abeoz9_check_validity(struct device *dev)
return -EINVAL;
}
- if (val & ABEOZ9_REG_CTRL_STATUS_V1F) {
+ if (val & ABEOZ9_REG_CTRL_STATUS_V2F) {
dev_warn(dev,
- "voltage drops below VLOW1 threshold, date is invalid\n");
+ "voltage drops below VLOW2 threshold, date is invalid\n");
return -EINVAL;
}
- if ((val & ABEOZ9_REG_CTRL_STATUS_V2F)) {
+ if ((val & ABEOZ9_REG_CTRL_STATUS_V1F)) {
dev_warn(dev,
- "voltage drops below VLOW2 threshold, date is invalid\n");
+ "voltage drops below VLOW1 threshold, date is invalid\n");
return -EINVAL;
}
--
2.47.0
Powered by blists - more mailing lists