Skip to contentSkip to conversation

rtc: Add fallbacks for dm functions

PATCH Superseded Sean Anderson 2 participants 2 messages Oct 11, 2022 – Oct 22, 2022

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rtc: Add fallbacks for dm functions

This adds fallbacks for the various dm_rtc_* functions. This allows common code to use these functions without ifdefs.

Fixes c8ce7ba87d1 ("misc: Add support for nvmem cells")

---

Changes in v2:
- Include linux/errno.h for ENOSYS. This is needed for some mips boards when CONFIG_BLK is enabled for whatever reason.

 include/rtc.h | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
include/rtc.h +29 -3
index 10104e3bf5a..b6fdbb60dc2 100644
@@ -15,13 +15,12 @@
 
 #include <bcd.h>
 #include <rtc_def.h>
+#include <linux/errno.h>
 
 typedef int64_t time64_t;
-
-#ifdef CONFIG_DM_RTC
-
 struct udevice;
 
+#if CONFIG_IS_ENABLED(DM_RTC)
 struct rtc_ops {
 	/**
 	 * get() - get the current time
@@ -222,6 +221,33 @@ int rtc_enable_32khz_output(int busnum, int chip_addr);
 #endif
 
 #else
+static inline int dm_rtc_get(struct udevice *dev, struct rtc_time *time)
+{
+	return -ENOSYS;
+}
+
+static inline int dm_rtc_set(struct udevice *dev, struct rtc_time *time)
+{
+	return -ENOSYS;
+}
+
+static inline int dm_rtc_reset(struct udevice *dev)
+{
+	return -ENOSYS;
+}
+
+static inline int dm_rtc_read(struct udevice *dev, unsigned int reg, u8 *buf,
+			      unsigned int len)
+{
+	return -ENOSYS;
+}
+
+static inline int dm_rtc_write(struct udevice *dev, unsigned int reg,
+			       const u8 *buf, unsigned int len)
+{
+	return -ENOSYS;
+}
+
 int rtc_get (struct rtc_time *);
 int rtc_set (struct rtc_time *);
 void rtc_reset (void);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#1 lore raw
Quoted 6 lines · Sean Anderson

This adds fallbacks for the various dm_rtc_* functions. This allows common code to use these functions without ifdefs.

Fixes c8ce7ba87d1 ("misc: Add support for nvmem cells")
Quoted 8 lines

---

Changes in v2:
- Include linux/errno.h for ENOSYS. This is needed for some mips boards when CONFIG_BLK is enabled for whatever reason.

 include/rtc.h | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

Almost there, this just breaks chromebook_coral now, but nothing else.

Signature · 1 line
Tom