mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] rtc: add stubs for when CONFIG_RTC_CLASS is disabled
@ 2024-07-16 12:03 Ahmad Fatoum
  2024-07-16 12:03 ` [PATCH 2/2] rtc: return first RTC when rtc_lookup(NULL) is called Ahmad Fatoum
  2024-07-19  6:35 ` [PATCH 1/2] rtc: add stubs for when CONFIG_RTC_CLASS is disabled Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-07-16 12:03 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-19  6:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-16 12:03 [PATCH 1/2] rtc: add stubs for when CONFIG_RTC_CLASS is disabled Ahmad Fatoum
2024-07-16 12:03 ` [PATCH 2/2] rtc: return first RTC when rtc_lookup(NULL) is called Ahmad Fatoum
2024-07-19  6:35 ` [PATCH 1/2] rtc: add stubs for when CONFIG_RTC_CLASS is disabled Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox