Skip to content

Commit cb0e996

Browse files
John StultzKAGA-KOKO
authored andcommitted
blackfin: Convert blackfin to use read/update_persistent_clock
This patch converts the blackfin architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future. I have not built or tested this patch, so help from arch maintainers would be appreciated. Signed-off-by: John Stultz <johnstul@us.ibm.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Andrew Morton <akpm@linux-foundation.org> LKML-Reference: <1267675049-12337-10-git-send-email-johnstul@us.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 6ffdc57 commit cb0e996

2 files changed

Lines changed: 13 additions & 39 deletions

File tree

‎arch/blackfin/kernel/time-ts.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,15 @@ static int __init bfin_clockevent_init(void)
348348
return 0;
349349
}
350350

351-
void __init time_init(void)
351+
void read_persistent_clock(struct timespec *ts)
352352
{
353353
time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */
354+
ts->tv_sec = secs_since_1970;
355+
ts->tv_nsec = 0;
356+
}
357+
358+
void __init time_init(void)
359+
{
354360

355361
#ifdef CONFIG_RTC_DRV_BFIN
356362
/* [#2663] hack to filter junk RTC values that would cause
@@ -363,11 +369,6 @@ void __init time_init(void)
363369
}
364370
#endif
365371

366-
/* Initialize xtime. From now on, xtime is updated with timer interrupts */
367-
xtime.tv_sec = secs_since_1970;
368-
xtime.tv_nsec = 0;
369-
set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
370-
371372
bfin_cs_cycles_init();
372373
bfin_cs_gptimer0_init();
373374
bfin_clockevent_init();

‎arch/blackfin/kernel/time.c‎

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ u32 arch_gettimeoffset(void)
112112
}
113113
#endif
114114

115-
static inline int set_rtc_mmss(unsigned long nowtime)
116-
{
117-
return 0;
118-
}
119-
120115
/*
121116
* timer_interrupt() needs to keep up the real-time clock,
122117
* as well as call the "do_timer()" routine every clocktick
@@ -126,29 +121,8 @@ __attribute__((l1_text))
126121
#endif
127122
irqreturn_t timer_interrupt(int irq, void *dummy)
128123
{
129-
/* last time the cmos clock got updated */
130-
static long last_rtc_update;
131-
132124
write_seqlock(&xtime_lock);
133125
do_timer(1);
134-
135-
/*
136-
* If we have an externally synchronized Linux clock, then update
137-
* CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
138-
* called as close as possible to 500 ms before the new second starts.
139-
*/
140-
if (ntp_synced() &&
141-
xtime.tv_sec > last_rtc_update + 660 &&
142-
(xtime.tv_nsec / NSEC_PER_USEC) >=
143-
500000 - ((unsigned)TICK_SIZE) / 2
144-
&& (xtime.tv_nsec / NSEC_PER_USEC) <=
145-
500000 + ((unsigned)TICK_SIZE) / 2) {
146-
if (set_rtc_mmss(xtime.tv_sec) == 0)
147-
last_rtc_update = xtime.tv_sec;
148-
else
149-
/* Do it again in 60s. */
150-
last_rtc_update = xtime.tv_sec - 600;
151-
}
152126
write_sequnlock(&xtime_lock);
153127

154128
#ifdef CONFIG_IPIPE
@@ -161,10 +135,15 @@ irqreturn_t timer_interrupt(int irq, void *dummy)
161135
return IRQ_HANDLED;
162136
}
163137

164-
void __init time_init(void)
138+
void read_persistent_clock(struct timespec *ts)
165139
{
166140
time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */
141+
ts->tv_sec = secs_since_1970;
142+
ts->tv_nsec = 0;
143+
}
167144

145+
void __init time_init(void)
146+
{
168147
#ifdef CONFIG_RTC_DRV_BFIN
169148
/* [#2663] hack to filter junk RTC values that would cause
170149
* userspace to have to deal with time values greater than
@@ -176,11 +155,5 @@ void __init time_init(void)
176155
}
177156
#endif
178157

179-
/* Initialize xtime. From now on, xtime is updated with timer interrupts */
180-
xtime.tv_sec = secs_since_1970;
181-
xtime.tv_nsec = 0;
182-
183-
wall_to_monotonic.tv_sec = -xtime.tv_sec;
184-
185158
time_sched_init(timer_interrupt);
186159
}

0 commit comments

Comments
 (0)