From 556ae44baf9ad0d6b9ee0daabc850e0dbf9e2bd3 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 23 Sep 2017 10:31:33 +0100 Subject: rtc: pre-register hook Add a pre-register hook to allow RTC drivers to adjust the default set_offset_nsec value. Signed-off-by: Russell King --- drivers/rtc/class.c | 3 +++ include/linux/rtc.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 4b460c61f1d8..e0a29b252630 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -404,6 +404,9 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc) if (!err && !rtc_valid_tm(&alrm.time)) rtc_initialize_alarm(rtc, &alrm); + if (rtc->ops->pre_register) + rtc->ops->pre_register(rtc); + rtc_dev_prepare(rtc); err = cdev_device_add(&rtc->char_dev, &rtc->dev); diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 47fd1c2d3a57..e864cf861bb4 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -44,6 +44,8 @@ static inline time64_t rtc_tm_sub(struct rtc_time *lhs, struct rtc_time *rhs) extern struct class *rtc_class; +struct rtc_device; + /* * For these RTC methods the device parameter is the physical device * on whatever bus holds the hardware (I2C, Platform, SPI, etc), which @@ -68,6 +70,7 @@ struct rtc_class_ops { int (*set_offset)(struct device *, long offset); int (*param_get)(struct device *, struct rtc_param *param); int (*param_set)(struct device *, struct rtc_param *param); + void (*pre_register)(struct rtc_device *); }; struct rtc_device; -- cgit