To allow using the RTC API in files that may optionally be compiled with RTC support disabled, add dummy stubs. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/linux/rtc.h | 13 +++++++++++++ include/rtc.h | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 3c5bb8c8dfc1..4fa999723de1 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -19,6 +19,8 @@ #include <linux/nvmem-provider.h> #include <rtc.h> +struct rtc_time; + extern int rtc_month_days(unsigned int month, unsigned int year); extern int rtc_valid_tm(struct rtc_time *tm); extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); @@ -40,8 +42,19 @@ struct rtc_class_ops { extern int rtc_register(struct rtc_device *rtcdev); +#ifdef CONFIG_RTC_CLASS extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); +#else +static inline int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) +{ + return -ENOSYS; +} +static inline int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) +{ + return -ENOSYS; +} +#endif static inline bool is_leap_year(unsigned int year) { diff --git a/include/rtc.h b/include/rtc.h index d7e103d163bc..0766f0408216 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -10,6 +10,8 @@ #ifndef _RTC_H_ #define _RTC_H_ +#include <linux/err.h> + /* * The struct used to pass data from the generic interface code to * the hardware dependend low-level code ande vice versa. Identical @@ -40,7 +42,15 @@ void to_tm (int, struct rtc_time *); unsigned long mktime (unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); +struct rtc_device; +#ifdef CONFIG_RTC_CLASS extern struct rtc_device *rtc_lookup(const char *name); +#else +static inline struct rtc_device *rtc_lookup(const char *name) +{ + return ERR_PTR(-ENODEV); +} +#endif const char *time_str(struct rtc_time *tm); -- 2.39.2