Re: rtc-cmos.c: Build fix

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Carlos R. Mafra
Date: Tuesday, May 6, 2008 - 11:51 am

> since you seem to be interested in HPET topics, what do you think about 

I think I've found the problem. After fixing the rtc-cmos.o build your
.config produced yet another failure later on:

  LD      .tmp_vmlinux1
drivers/built-in.o: In function `v4l2_i2c_drv_attach_legacy':
tuner-core.c:(.text+0xc5a31): undefined reference to `v4l2_i2c_attach'
drivers/built-in.o: In function `tuner_command':
tuner-core.c:(.text+0xc6dc2): undefined reference to `v4l_printk_ioctl'
make: *** [.tmp_vmlinux1] Error 1

But this one I left untouched for the moment.


With the inclusion of hpet.h we don't have the "do-nothing stubs" for
the case !HPET_EMULATE_RTC as they are defined inside rtc.c
and rtc-cmos.c. However hpet_rtc_interrupt() is missing in those
stubs because it was removed with akpm's patch. So I added it.

My explanation for the build failure is as follows.

Your .config did not have HPET_EMULATE_RTC enabled but the code
in rtc-cmos.c wanted to use hpet_rtc_interrupt() anyways. But
looking in arch/x86/kernel/hpet.c this function is inside a

#ifdef CONFIG_HPET_EMULATE_RTC <-- line 465
hpet_rtc_interrupt() <--- line 679
#endif <--- line 716

so it should be used if and only if HPET_EMULATE_RTC is defined.

And the code in question which makes the build fail is inside a 
  if(is_hpet_enabled()) {
  ...
  rtc_cmos_int_handler = hpet_rtc_interrupt;
  ...
  }
and this would never be executed because with !HPET_EMULATE_RTC (as
in your .config) is_hpet_enabled() is defined to return 0.

So I think Andrew's patch should be the one below (I've folded
my correction into his patch, so I am Cc:ing him also), where my
modification is the adition inside the #ifndef CONFIG_HPET_EMULATE_RTC
(which I took from rtc.c)


I think one could do that too as a cleanup (to remove the do-nothing stubs
from rtc.c and rtc-cmos.c), but I am afraid to make a mistake which would
cause other build failures afterwards. So now I just wanted to understand
and fix the issue you suggested to me (for which I thank you).

Furthermore, the modification in rtc.c is ok because it was used only
if CONFIG_HPET_EMULATE_RTC is defined, but that can only happen if
CONFIG_HPET_TIMER is also defined (due to 'depends on HPET_TIMER' in 
the Kconfig), in which case the inclusion of hpet.h is effective.

I hope this is ok for now.


From a9852384bcf423493ecdf8be83c3fc72d4b9959d Mon Sep 17 00:00:00 2001
From: Carlos R. Mafra <crmafra@ift.unesp.br>
Date: Tue, 6 May 2008 13:58:04 -0300
Subject: [PATCH] rtc-cmos.c: Build fix

The function hpet_rtc_interrupt(..) is to be used only if CONFIG_HPET_EMULATE_RTC
is defined (see arch/x86/kernel/hpet.c), so we define it to return 0 when
!CONFIG_HPET_EMULATE_RTC to avoid build failures. 

This function will never be used anyways when !CONFIG_HPET_EMULATE_RTC because 
it is inside a if(is_hpet_enabled()) which is never true when
!CONFIG_HPET_EMULATE_RTC.

Signed-off-by: Carlos R. Mafra <crmafra@ift.unesp.br>
---
 drivers/char/rtc.c     |    2 --
 drivers/rtc/rtc-cmos.c |    5 ++++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 5f80a9d..31d09ea 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -119,8 +119,6 @@ static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
 	return 0;
 }
 #endif
-#else
-extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
 #endif
 
 /*
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index d060a06..12046bb 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -52,7 +52,10 @@
 #define hpet_rtc_timer_init() 			do { } while (0)
 #define hpet_register_irq_handler(h) 		0
 #define hpet_unregister_irq_handler(h)		do { } while (0)
-extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
+static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
+{
+	return 0;
+}
 #endif
 
 struct cmos_rtc {
-- 
1.5.4.3


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
x86: Clean up computation of HPET .mult variables, Carlos R. Mafra, (Mon May 5, 4:11 pm)
Re: x86: Clean up computation of HPET .mult variables, Daniel Walker, (Mon May 5, 4:58 pm)
Re: x86: Clean up computation of HPET .mult variables, Carlos R. Mafra, (Mon May 5, 7:13 pm)
Re: x86: Clean up computation of HPET .mult variables, Daniel Walker, (Mon May 5, 8:23 pm)
Re: x86: Clean up computation of HPET .mult variables, Carlos R. Mafra, (Tue May 6, 5:59 am)
Re: x86: Clean up computation of HPET .mult variables, Carlos R. Mafra, (Tue May 6, 6:13 am)
Re: x86: Clean up computation of HPET .mult variables, Daniel Walker, (Tue May 6, 9:21 am)
Re: rtc-cmos.c: Build fix, Carlos R. Mafra, (Tue May 6, 11:51 am)
Re: x86: Clean up computation of HPET .mult variables, Carlos R. Mafra, (Tue May 6, 1:50 pm)
Re: x86: Clean up computation of HPET .mult variables, Daniel Walker, (Tue May 6, 7:17 pm)
Re: x86: Clean up computation of HPET .mult variables, Carlos R. Mafra, (Tue May 6, 8:39 pm)
Re: x86: Clean up computation of HPET .mult variables, Daniel Walker, (Tue May 6, 9:21 pm)
Re: rtc-cmos.c: Build fix, Ingo Molnar, (Wed May 7, 12:10 am)
Re: x86: Clean up computation of HPET .mult variables, Ingo Molnar, (Wed May 7, 12:13 am)
Re: rtc-cmos.c: Build fix, Andrew Morton, (Wed May 7, 2:31 pm)
Re: rtc-cmos.c: Build fix, Ingo Molnar, (Fri May 9, 1:32 am)
Re: rtc-cmos.c: Build fix, Carlos R. Mafra, (Fri May 9, 5:33 am)