diff mbox

[v2] rtc: Add some dummy static inline functions

Message ID 1a8cf6da9924b566aef1d00a31414e46e7f7fb71.1473302325.git.baolin.wang@linaro.org
State Superseded
Headers show

Commit Message

Baolin Wang Sept. 8, 2016, 2:41 a.m. UTC
The patch (commit id: a0a6e06d545a753740c9d8d5ce2c4fdd3ab1c021) adding
tracepoints for alarmtimers will build failed on S390 platform, due to
S390 defconfig did not define CONFIG_RTC_LIB macro to define the
rtc_ktime_to_tm() function which is used in this patch. Thus we should
add dummy static inline functions in case CONFIG_RTC_LIB is not defined.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Fixes: a0a6e06d545a ("time: alarmtimer: Add tracepoints for alarmtimers")
---
Changes since v1:
 - Modify the commit log.
---
 include/linux/rtc.h |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

Comments

Thomas Gleixner Sept. 9, 2016, 3:14 p.m. UTC | #1
On Thu, 8 Sep 2016, Baolin Wang wrote:

> The patch (commit id: a0a6e06d545a753740c9d8d5ce2c4fdd3ab1c021) adding
> tracepoints for alarmtimers will build failed on S390 platform, due to
> S390 defconfig did not define CONFIG_RTC_LIB macro to define the
> rtc_ktime_to_tm() function which is used in this patch. Thus we should
> add dummy static inline functions in case CONFIG_RTC_LIB is not defined.

I doubt this is a good idea. It will paper over usage of rtc lib functions
in generic code which will then lead to weird results on builds with
RTC_LIB=n.

Johns variant of making it conditional in the tracepoint is way safer.

Thanks

	tglx
diff mbox

Patch

diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index b693ada..521f752 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -16,13 +16,60 @@ 
 #include <linux/interrupt.h>
 #include <uapi/linux/rtc.h>
 
+#ifdef CONFIG_RTC_LIB
 extern int rtc_month_days(unsigned int month, unsigned int year);
-extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year);
+extern int rtc_year_days(unsigned int day, unsigned int month,
+			 unsigned int year);
 extern int rtc_valid_tm(struct rtc_time *tm);
 extern time64_t rtc_tm_to_time64(struct rtc_time *tm);
 extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm);
 ktime_t rtc_tm_to_ktime(struct rtc_time tm);
 struct rtc_time rtc_ktime_to_tm(ktime_t kt);
+#else
+static inline int rtc_month_days(unsigned int month, unsigned int year)
+{
+	return 0;
+}
+
+static inline int rtc_year_days(unsigned int day, unsigned int month,
+				unsigned int year)
+{
+	return 0;
+}
+
+static inline int rtc_valid_tm(struct rtc_time *tm)
+{
+	return 0;
+}
+
+static inline time64_t rtc_tm_to_time64(struct rtc_time *tm)
+{
+	time64_t ret;
+
+	memset(&ret, 0, sizeof(time64_t));
+	return ret;
+}
+
+static inline void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
+{
+}
+
+static inline ktime_t rtc_tm_to_ktime(struct rtc_time tm)
+{
+	ktime_t ret;
+
+	memset(&ret, 0, sizeof(ktime_t));
+	return ret;
+}
+
+static inline struct rtc_time rtc_ktime_to_tm(ktime_t kt)
+{
+	struct rtc_time ret;
+
+	memset(&ret, 0, sizeof(struct rtc_time));
+	return ret;
+}
+#endif
 
 /*
  * rtc_tm_sub - Return the difference in seconds.