Re: [RFC][PATCH] Unify interface to persistent CMOS/RTC/whateverclock

From: Martin Schwidefsky
Date: Thu Aug 17 2006 - 05:17:48 EST


On Wed, 2006-08-16 at 15:45 -0700, john stultz wrote:
> My first pass at this can be found below. There are a few arches
> (specifically: m32r, s390, sparc, sparc64) where I just didn't know
> what
> to do, or where I suspect I didn't get it right, so I've CC'ed those
> maintainers for suggestions.

But it is sooo easy ;-)
See patch below.

--
blue skies,
Martin.

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

"Reality continues to ruin my life." - Calvin.

---

arch/s390/kernel/time.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)

diff -urpN linux-2.6/arch/s390/kernel/time.c linux-2.6-clock/arch/s390/kernel/time.c
--- linux-2.6/arch/s390/kernel/time.c 2006-08-17 10:34:58.000000000 +0200
+++ linux-2.6-clock/arch/s390/kernel/time.c 2006-08-17 11:05:28.000000000 +0200
@@ -40,6 +40,9 @@
#define USECS_PER_JIFFY ((unsigned long) 1000000/HZ)
#define CLK_TICKS_PER_JIFFY ((unsigned long) USECS_PER_JIFFY << 12)

+/* The value of the TOD clock for 1.1.1970. */
+#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
+
/*
* Create a small time difference between the timer interrupts
* on the different cpus to avoid lock contention.
@@ -343,8 +346,9 @@ extern void vtime_init(void);

unsigned long read_persistent_clock(void)
{
- /* XXX I have no clue here. s390 folks, help! */
- return 0;
+ __u64 tod = (get_clock() - TOD_UNIX_EPOCH) >> 12;
+ do_div(tod, 1000000);
+ return (unsigned long) tod;
}

/*
@@ -353,7 +357,6 @@ unsigned long read_persistent_clock(void
*/
void __init time_init(void)
{
- __u64 set_time_cc;
int cc;

/* kick the TOD clock */
@@ -378,9 +381,7 @@ void __init time_init(void)

/* set xtime */
xtime_cc = init_timer_cc + CLK_TICKS_PER_JIFFY;
- set_time_cc = init_timer_cc - 0x8126d60e46000000LL +
- (0x3c26700LL*1000000*4096);
- tod_to_timeval(set_time_cc, &xtime);
+ tod_to_timeval(init_timer_cc - TOD_UNIX_EPOCH, &xtime);
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/