Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Export the wrapper functions that read from the...



details:   https://anonhg.NetBSD.org/src/rev/6ec49aa5bed8
branches:  trunk
changeset: 756278:6ec49aa5bed8
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sat Jul 10 13:08:09 2010 +0000

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

diffstat:

 sys/dev/acpi/acpi.c       |   7 ++--
 sys/dev/acpi/acpi_timer.c |  66 ++++++++++++++++++++++++++++------------------
 sys/dev/acpi/acpi_timer.h |   6 ++-
 3 files changed, 48 insertions(+), 31 deletions(-)

diffs (230 lines):

diff -r 0c0051a0aea3 -r 6ec49aa5bed8 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Sat Jul 10 11:50:49 2010 +0000
+++ b/sys/dev/acpi/acpi.c       Sat Jul 10 13:08:09 2010 +0000
@@ -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)
diff -r 0c0051a0aea3 -r 6ec49aa5bed8 sys/dev/acpi/acpi_timer.c
--- a/sys/dev/acpi/acpi_timer.c Sat Jul 10 11:50:49 2010 +0000
+++ b/sys/dev/acpi/acpi_timer.c Sat Jul 10 13:08:09 2010 +0000
@@ -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 <drochner%NetBSD.org@localhost>
@@ -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;
 }
diff -r 0c0051a0aea3 -r 6ec49aa5bed8 sys/dev/acpi/acpi_timer.h
--- a/sys/dev/acpi/acpi_timer.h Sat Jul 10 11:50:49 2010 +0000
+++ b/sys/dev/acpi/acpi_timer.h Sat Jul 10 13:08:09 2010 +0000
@@ -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 <drochner%NetBSD.org@localhost>
@@ -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 */



Home | Main Index | Thread Index | Old Index