Module Name:    src
Committed By:   jruoho
Date:           Sat Jul 10 13:08:09 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi.c acpi_timer.c acpi_timer.h

Log Message:
Export the wrapper functions that read from the ACPI PM timer.
Needed for ACPI CPUs. Also KNF, cosmetics. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/dev/acpi/acpi.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/acpi/acpi_timer.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/acpi_timer.h

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

Modified files:

Index: src/sys/dev/acpi/acpi.c
diff -u src/sys/dev/acpi/acpi.c:1.205 src/sys/dev/acpi/acpi.c:1.206
--- src/sys/dev/acpi/acpi.c:1.205	Fri Jul  2 05:18:38 2010
+++ src/sys/dev/acpi/acpi.c	Sat Jul 10 13:08:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi.c,v 1.205 2010/07/02 05:18:38 jruoho Exp $	*/
+/*	$NetBSD: acpi.c,v 1.206 2010/07/10 13:08:09 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.205 2010/07/02 05:18:38 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.206 2010/07/10 13:08:09 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -78,6 +78,7 @@
 #include <sys/mutex.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
+#include <sys/timetc.h>
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -528,7 +529,7 @@
 	acpi_register_fixed_button(sc, ACPI_EVENT_POWER_BUTTON);
 	acpi_register_fixed_button(sc, ACPI_EVENT_SLEEP_BUTTON);
 
-	acpitimer_init();
+	acpitimer_init(sc);
 
 #ifdef ACPI_DEBUGGER
 	if (acpi_dbgr & ACPI_DBGR_PROBE)

Index: src/sys/dev/acpi/acpi_timer.c
diff -u src/sys/dev/acpi/acpi_timer.c:1.16 src/sys/dev/acpi/acpi_timer.c:1.17
--- src/sys/dev/acpi/acpi_timer.c:1.16	Fri Mar  5 17:04:26 2010
+++ src/sys/dev/acpi/acpi_timer.c	Sat Jul 10 13:08:09 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_timer.c,v 1.16 2010/03/05 17:04:26 jruoho Exp $ */
+/* $NetBSD: acpi_timer.c,v 1.17 2010/07/10 13:08:09 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2006 Matthias Drochner <droch...@netbsd.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_timer.c,v 1.16 2010/03/05 17:04:26 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_timer.c,v 1.17 2010/07/10 13:08:09 jruoho Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
@@ -39,10 +39,8 @@
 
 #include <machine/acpi_machdep.h>
 
-static int acpitimer_test(void);
-static uint32_t acpitimer_delta(uint32_t, uint32_t);
-static u_int acpitimer_read_safe(struct timecounter *);
-static u_int acpitimer_read_fast(struct timecounter *);
+static int	acpitimer_test(void);
+static uint32_t	acpitimer_delta(uint32_t, uint32_t);
 
 static struct timecounter acpi_timecounter = {
 	acpitimer_read_safe,
@@ -56,21 +54,21 @@
 };
 
 int
-acpitimer_init(void)
+acpitimer_init(struct acpi_softc *sc)
 {
+	ACPI_STATUS res;
 	uint32_t bits;
 	int i, j;
-	ACPI_STATUS res;
 
 	res = AcpiGetTimerResolution(&bits);
+
 	if (res != AE_OK)
 		return (-1);
 
 	if (bits == 32)
 		acpi_timecounter.tc_counter_mask = 0xffffffff;
 
-	j = 0;
-	for (i = 0; i < 10; i++)
+	for (i = j = 0; i < 10; i++)
 		j += acpitimer_test();
 
 	if (j >= 10) {
@@ -78,62 +76,71 @@
 		acpi_timecounter.tc_get_timecount = acpitimer_read_fast;
 		acpi_timecounter.tc_quality = 1000;
 	}
-		
+
 	tc_init(&acpi_timecounter);
-	aprint_verbose("%s %d-bit timer\n", acpi_timecounter.tc_name, bits);
 
-	return (0);
+	aprint_debug_dev(sc->sc_dev,
+	    "%s %d-bit timer\n", acpi_timecounter.tc_name, bits);
+
+	return 0;
 }
 
 int
 acpitimer_detach(void)
 {
+
 	return tc_detach(&acpi_timecounter);
 }
 
-static u_int
+u_int
 acpitimer_read_fast(struct timecounter *tc)
 {
 	uint32_t t;
 
-	AcpiGetTimer(&t);
-	return (t);
+	(void)AcpiGetTimer(&t);
+
+	return t;
 }
 
 /*
  * Some chipsets (PIIX4 variants) do not latch correctly; there
  * is a chance that a transition is hit.
  */
-static u_int
+u_int
 acpitimer_read_safe(struct timecounter *tc)
 {
 	uint32_t t1, t2, t3;
 
-	AcpiGetTimer(&t2);
-	AcpiGetTimer(&t3);
+	(void)AcpiGetTimer(&t2);
+	(void)AcpiGetTimer(&t3);
+
 	do {
 		t1 = t2;
 		t2 = t3;
-		AcpiGetTimer(&t3);
+
+		(void)AcpiGetTimer(&t3);
+
 	} while ((t1 > t2) || (t2 > t3));
-	return (t2);
+
+	return t2;
 }
 
 static uint32_t
 acpitimer_delta(uint32_t end, uint32_t start)
 {
+	const u_int mask = acpi_timecounter.tc_counter_mask;
 	uint32_t delta;
-	u_int mask = acpi_timecounter.tc_counter_mask;
 
 	if (end >= start)
 		delta = end - start;
 	else
 		delta = ((mask - start) + end + 1) & mask;
 
-	return (delta);
+	return delta;
 }
 
 #define N 2000
+
 static int
 acpitimer_test(void)
 {
@@ -144,16 +151,23 @@
 	maxl = 0;
 
 	acpi_md_OsDisableInterrupt();
-	AcpiGetTimer(&last);
+
+	(void)AcpiGetTimer(&last);
+
 	for (n = 0; n < N; n++) {
-		AcpiGetTimer(&this);
+
+		(void)AcpiGetTimer(&this);
+
 		delta = acpitimer_delta(this, last);
+
 		if (delta > maxl)
 			maxl = delta;
 		else if (delta < minl)
 			minl = delta;
+
 		last = this;
 	}
+
 	acpi_md_OsEnableInterrupt();
 
 	if (maxl - minl > 2 )
@@ -163,5 +177,5 @@
 	else
 		n = 1;
 
-	return (n);
+	return n;
 }

Index: src/sys/dev/acpi/acpi_timer.h
diff -u src/sys/dev/acpi/acpi_timer.h:1.4 src/sys/dev/acpi/acpi_timer.h:1.5
--- src/sys/dev/acpi/acpi_timer.h:1.4	Fri Mar  5 17:04:26 2010
+++ src/sys/dev/acpi/acpi_timer.h	Sat Jul 10 13:08:09 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_timer.h,v 1.4 2010/03/05 17:04:26 jruoho Exp $ */
+/* $NetBSD: acpi_timer.h,v 1.5 2010/07/10 13:08:09 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2006 Matthias Drochner <droch...@netbsd.org>
@@ -29,7 +29,9 @@
 #ifndef _SYS_DEV_ACPI_ACPI_TIMER_H
 #define _SYS_DEV_ACPI_ACPI_TIMER_H
 
-int	acpitimer_init(void);
+int	acpitimer_init(struct acpi_softc *);
 int	acpitimer_detach(void);
+u_int	acpitimer_read_safe(struct timecounter *);
+u_int	acpitimer_read_fast(struct timecounter *);
 
 #endif	/* !_SYS_DEV_ACPI_ACPI_TIMER_H */

Reply via email to