mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] rtc: add stubs for when CONFIG_RTC_CLASS is disabled
Date: Tue, 16 Jul 2024 14:03:29 +0200	[thread overview]
Message-ID: <20240716120330.1988495-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2024-07-16 12:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 12:03 Ahmad Fatoum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240716120330.1988495-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox