Skip to content

Commit 8eff8a5

Browse files
John StultzKAGA-KOKO
authored andcommitted
cris: Convert cris to use read/update_persistent_clock
This patch converts the cris 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: Mikael Starvik <starvik@axis.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Andrew Morton <akpm@linux-foundation.org> LKML-Reference: <1267675049-12337-14-git-send-email-johnstul@us.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent ffbcad4 commit 8eff8a5

4 files changed

Lines changed: 18 additions & 82 deletions

File tree

‎arch/cris/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ config RWSEM_XCHGADD_ALGORITHM
2323
config GENERIC_TIME
2424
def_bool y
2525

26+
config GENERIC_CMOS_UPDATE
27+
def_bool y
28+
2629
config ARCH_USES_GETTIMEOFFSET
2730
def_bool y
2831

‎arch/cris/arch-v10/kernel/time.c‎

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
/* it will make jiffies at 96 hz instead of 100 hz though */
2727
#undef USE_CASCADE_TIMERS
2828

29-
extern void update_xtime_from_cmos(void);
3029
extern int set_rtc_mmss(unsigned long nowtime);
3130
extern int have_rtc;
3231

@@ -188,8 +187,6 @@ stop_watchdog(void)
188187
#endif
189188
}
190189

191-
/* last time the cmos clock got updated */
192-
static long last_rtc_update = 0;
193190

194191
/*
195192
* timer_interrupt() needs to keep up the real-time clock,
@@ -232,24 +229,6 @@ timer_interrupt(int irq, void *dev_id)
232229
do_timer(1);
233230

234231
cris_do_profile(regs); /* Save profiling information */
235-
236-
/*
237-
* If we have an externally synchronized Linux clock, then update
238-
* CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
239-
* called as close as possible to 500 ms before the new second starts.
240-
*
241-
* The division here is not time critical since it will run once in
242-
* 11 minutes
243-
*/
244-
if (ntp_synced() &&
245-
xtime.tv_sec > last_rtc_update + 660 &&
246-
(xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
247-
(xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
248-
if (set_rtc_mmss(xtime.tv_sec) == 0)
249-
last_rtc_update = xtime.tv_sec;
250-
else
251-
last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
252-
}
253232
return IRQ_HANDLED;
254233
}
255234

@@ -274,22 +253,10 @@ time_init(void)
274253
*/
275254
loops_per_usec = 50;
276255

277-
if(RTC_INIT() < 0) {
278-
/* no RTC, start at 1980 */
279-
xtime.tv_sec = 0;
280-
xtime.tv_nsec = 0;
256+
if(RTC_INIT() < 0)
281257
have_rtc = 0;
282-
} else {
283-
/* get the current time */
258+
else
284259
have_rtc = 1;
285-
update_xtime_from_cmos();
286-
}
287-
288-
/*
289-
* Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
290-
* tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
291-
*/
292-
set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
293260

294261
/* Setup the etrax timers
295262
* Base frequency is 25000 hz, divider 250 -> 100 HZ

‎arch/cris/arch-v32/kernel/time.c‎

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ unsigned long timer_regs[NR_CPUS] =
4444
#endif
4545
};
4646

47-
extern void update_xtime_from_cmos(void);
4847
extern int set_rtc_mmss(unsigned long nowtime);
4948
extern int have_rtc;
5049

@@ -198,9 +197,6 @@ handle_watchdog_bite(struct pt_regs* regs)
198197
#endif
199198
}
200199

201-
/* Last time the cmos clock got updated. */
202-
static long last_rtc_update = 0;
203-
204200
/*
205201
* timer_interrupt() needs to keep up the real-time clock,
206202
* as well as call the "do_timer()" routine every clocktick.
@@ -238,25 +234,6 @@ timer_interrupt(int irq, void *dev_id)
238234

239235
/* Call the real timer interrupt handler */
240236
do_timer(1);
241-
242-
/*
243-
* If we have an externally synchronized Linux clock, then update
244-
* CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
245-
* called as close as possible to 500 ms before the new second starts.
246-
*
247-
* The division here is not time critical since it will run once in
248-
* 11 minutes
249-
*/
250-
if ((time_status & STA_UNSYNC) == 0 &&
251-
xtime.tv_sec > last_rtc_update + 660 &&
252-
(xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
253-
(xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
254-
if (set_rtc_mmss(xtime.tv_sec) == 0)
255-
last_rtc_update = xtime.tv_sec;
256-
else
257-
/* Do it again in 60 s */
258-
last_rtc_update = xtime.tv_sec - 600;
259-
}
260237
return IRQ_HANDLED;
261238
}
262239

@@ -309,23 +286,10 @@ time_init(void)
309286
*/
310287
loops_per_usec = 50;
311288

312-
if(RTC_INIT() < 0) {
313-
/* No RTC, start at 1980 */
314-
xtime.tv_sec = 0;
315-
xtime.tv_nsec = 0;
289+
if(RTC_INIT() < 0)
316290
have_rtc = 0;
317-
} else {
318-
/* Get the current time */
291+
else
319292
have_rtc = 1;
320-
update_xtime_from_cmos();
321-
}
322-
323-
/*
324-
* Initialize wall_to_monotonic such that adding it to
325-
* xtime will yield zero, the tv_nsec field must be normalized
326-
* (i.e., 0 <= nsec < NSEC_PER_SEC).
327-
*/
328-
set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
329293

330294
/* Start CPU local timer. */
331295
cris_timer_init();

‎arch/cris/kernel/time.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ unsigned long
9898
get_cmos_time(void)
9999
{
100100
unsigned int year, mon, day, hour, min, sec;
101+
if(!have_rtc)
102+
return 0;
101103

102104
sec = CMOS_READ(RTC_SECONDS);
103105
min = CMOS_READ(RTC_MINUTES);
@@ -119,19 +121,19 @@ get_cmos_time(void)
119121
return mktime(year, mon, day, hour, min, sec);
120122
}
121123

122-
/* update xtime from the CMOS settings. used when /dev/rtc gets a SET_TIME.
123-
* TODO: this doesn't reset the fancy NTP phase stuff as do_settimeofday does.
124-
*/
125124

126-
void
127-
update_xtime_from_cmos(void)
125+
int update_persistent_clock(struct timespec now)
128126
{
129-
if(have_rtc) {
130-
xtime.tv_sec = get_cmos_time();
131-
xtime.tv_nsec = 0;
132-
}
127+
return set_rtc_mmss(now.tv_sec);
133128
}
134129

130+
void read_persistent_clock(struct timespec *ts)
131+
{
132+
ts->tv_sec = get_cmos_time();
133+
ts->tv_nsec = 0;
134+
}
135+
136+
135137
extern void cris_profile_sample(struct pt_regs* regs);
136138

137139
void

0 commit comments

Comments
 (0)