rtc: expose correction feature
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 18 Oct 2021 15:19:29 +0000 (17:19 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 18 Oct 2021 15:20:50 +0000 (17:20 +0200)
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
drivers/rtc/class.c
include/uapi/linux/rtc.h

index dbccd71589b9d06653c1146eb104d744c13272f9..2e0cbc190a8ae5703da55f6d319b7bdf255a0660 100644 (file)
@@ -389,6 +389,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);
 
index 3241f9ecc6391ccbc7d94cabd594c25ec5ea4671..c83bb9a4fa4f018de25f6ec9853ee3df23099cec 100644 (file)
@@ -131,7 +131,8 @@ struct rtc_param {
 #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
 
 /* parameter list */
 #define RTC_PARAM_FEATURES             0