diff mbox series

[5.10.y-cip,16/31] rtc: expose correction feature

Message ID 20230816142017.147173-17-biju.das.jz@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series Add Renesas PMIC RAA215300 driver and builtin RTC support | expand

Commit Message

Biju Das Aug. 16, 2023, 2:20 p.m. UTC
From: Alexandre Belloni <alexandre.belloni@bootlin.com>

commit 2268551935dbf1abcbb4d4fb7b1ad74dbe0d1be0 upstream.

Add a new feature for RTCs able to correct the oscillator imprecision. This
is also called offset or trimming. Such drivers have a .set_offset callback,
use that to set the feature bit from the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211018151933.76865-4-alexandre.belloni@bootlin.com
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/rtc/class.c      | 3 +++
 include/uapi/linux/rtc.h | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index edd84ee38005..f521b90fa182 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -398,6 +398,9 @@  int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 	if (!rtc->ops->set_alarm)
 		clear_bit(RTC_FEATURE_ALARM, rtc->features);
 
+	if (rtc->ops->set_offset)
+		set_bit(RTC_FEATURE_CORRECTION, rtc->features);
+
 	rtc->owner = owner;
 	rtc_device_get_offset(rtc);
 
diff --git a/include/uapi/linux/rtc.h b/include/uapi/linux/rtc.h
index f4037c541925..ef5113d061c4 100644
--- a/include/uapi/linux/rtc.h
+++ b/include/uapi/linux/rtc.h
@@ -116,7 +116,8 @@  struct rtc_pll_info {
 #define RTC_FEATURE_NEED_WEEK_DAY	2
 #define RTC_FEATURE_ALARM_RES_2S	3
 #define RTC_FEATURE_UPDATE_INTERRUPT	4
-#define RTC_FEATURE_CNT			5
+#define RTC_FEATURE_CORRECTION		5
+#define RTC_FEATURE_CNT			6
 
 #define RTC_MAX_FREQ	8192