Module Name:    src
Committed By:   christos
Date:           Mon Nov 21 19:50:37 UTC 2011

Modified Files:
        src/sys/arch/alpha/alpha: mcclock.c

Log Message:
- don't clear the flags twice in the loop
- reorder calculation to preserve as much precision as possible.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/alpha/mcclock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/alpha/mcclock.c
diff -u src/sys/arch/alpha/alpha/mcclock.c:1.17 src/sys/arch/alpha/alpha/mcclock.c:1.18
--- src/sys/arch/alpha/alpha/mcclock.c:1.17	Fri Jul  1 15:22:35 2011
+++ src/sys/arch/alpha/alpha/mcclock.c	Mon Nov 21 14:50:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclock.c,v 1.17 2011/07/01 19:22:35 dyoung Exp $ */
+/* $NetBSD: mcclock.c,v 1.18 2011/11/21 19:50:37 christos Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.17 2011/07/01 19:22:35 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.18 2011/11/21 19:50:37 christos Exp $");
 
 #include "opt_clock_compat_osf1.h"
 
@@ -102,10 +102,11 @@ mcclock_set_pcc_freq(struct mc146818_sof
 	/* set interval 16Hz to measure pcc */
 	(*sc->sc_mcwrite)(sc, MC_REGA, MC_BASE_32_KHz | MC_RATE_16_Hz);
 
+	/* clear interrupt flags */
+	(void)(*sc->sc_mcread)(sc, MC_REGC);
+
 	/* Run the loop an extra time to prime the cache. */
 	for (i = 0; i < NLOOP; i++) {
-		/* clear interrupt flags */
-		(void)(*sc->sc_mcread)(sc, MC_REGC);
 
 		/* wait till the periodic interrupt flag is set */
 		while (((*sc->sc_mcread)(sc, MC_REGC) & MC_REGC_PF) == 0)
@@ -120,7 +121,7 @@ mcclock_set_pcc_freq(struct mc146818_sof
 		ctrdiff[i] = pcc_end - pcc_start;
 	}
 
-	freq = ((ctrdiff[NLOOP - 2] + ctrdiff[NLOOP - 1]) / 2) * 16 /* Hz */;
+	freq = ((ctrdiff[NLOOP - 2] + ctrdiff[NLOOP - 1]) * 16 /* Hz */) / 2;
 
 	/* restore REG_A */
 	(*sc->sc_mcwrite)(sc, MC_REGA, reg_a);

Reply via email to