diff mbox

[OPW,kernel] Tiny kernel: Make writing time to RTC optional.

Message ID 20141007184637.GA19068@winterfell
State New, archived
Headers show

Commit Message

Iulia Manda Oct. 7, 2014, 6:46 p.m. UTC
This patch makes writing to hardware clock configurable for x86.

It removes mach_set_rtc_mmss and rtc_cmos_write, which implement
writing to the RTC.

Also, by making these functions empty, RTC_LIB is not needed,
therefore it is not compiled.

bloat-o-meter output:

add/remove: 0/9 grow/shrink: 0/2 up/down: 0/-1651 (-1651)
function                                     old     new   delta
rtc_days_in_month                             12       -     -12
rtc_tm_to_ktime                               26       -     -26
rtc_ydays                                     52       -     -52
rtc_tm_to_time                                80       -     -80
rtc_month_days                                85       -     -85
rtc_ktime_to_tm                               96       -     -96
rtc_cmos_write                               110       2    -108
rtc_year_days                                109       -    -109
rtc_valid_tm                                 183       -    -183
rtc_time_to_tm                               414       -    -414
mach_set_rtc_mmss                            489       3    -486

---
 arch/x86/Kconfig      |    2 +-
 arch/x86/kernel/rtc.c |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3632743..9337d5e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -127,7 +127,7 @@  config X86
 	select OLD_SIGSUSPEND3 if X86_32 || IA32_EMULATION
 	select OLD_SIGACTION if X86_32
 	select COMPAT_OLD_SIGACTION if IA32_EMULATION
-	select RTC_LIB
+	select RTC_LIB if RTC_ENABLE_WRITE
 	select HAVE_DEBUG_STACKOVERFLOW
 	select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
 	select HAVE_CC_STACKPROTECTOR
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index ca9622a..12bdf95 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -40,6 +40,7 @@  EXPORT_SYMBOL(rtc_lock);
  */
 int mach_set_rtc_mmss(const struct timespec *now)
 {
+#ifdef CONFIG_RTC_ENABLE_WRITE
 	unsigned long nowtime = now->tv_sec;
 	struct rtc_time tm;
 	int retval = 0;
@@ -57,6 +58,9 @@  int mach_set_rtc_mmss(const struct timespec *now)
 		retval = -EINVAL;
 	}
 	return retval;
+#else
+	return 0;
+#endif
 }
 
 void mach_get_cmos_time(struct timespec *now)
@@ -128,10 +132,12 @@  EXPORT_SYMBOL(rtc_cmos_read);
 
 void rtc_cmos_write(unsigned char val, unsigned char addr)
 {
+#ifdef CONFIG_RTC_ENABLE_WRITE
 	lock_cmos_prefix(addr);
 	outb(addr, RTC_PORT(0));
 	outb(val, RTC_PORT(1));
 	lock_cmos_suffix(addr);
+#endif
 }
 EXPORT_SYMBOL(rtc_cmos_write);