Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Cleanup:



details:   https://anonhg.NetBSD.org/src/rev/53b778158a98
branches:  trunk
changeset: 752714:53b778158a98
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Thu Mar 04 22:29:47 2010 +0000

description:
Cleanup:

  * Semantics.
  * No need for <dev/acpi/acpica.h>.
  * Reduce the amount of error reporting.
  * Remove ACPI_BUT_DEBUG and ACPIBUT_F_VERBOSE.

No functional change.

diffstat:

 sys/dev/acpi/acpi_button.c |  72 ++++++++++++---------------------------------
 1 files changed, 20 insertions(+), 52 deletions(-)

diffs (149 lines):

diff -r 64eec221d074 -r 53b778158a98 sys/dev/acpi/acpi_button.c
--- a/sys/dev/acpi/acpi_button.c        Thu Mar 04 21:55:32 2010 +0000
+++ b/sys/dev/acpi/acpi_button.c        Thu Mar 04 22:29:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_button.c,v 1.31 2010/02/28 17:22:41 jruoho Exp $  */
+/*     $NetBSD: acpi_button.c,v 1.32 2010/03/04 22:29:47 jruoho Exp $  */
 
 /*
  * Copyright 2001, 2003 Wasabi Systems, Inc.
@@ -40,26 +40,24 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_button.c,v 1.31 2010/02/28 17:22:41 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_button.c,v 1.32 2010/03/04 22:29:47 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/module.h>
 
-#include <dev/acpi/acpica.h>
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
 
 #include <dev/sysmon/sysmonvar.h>
 
-#define _COMPONENT             ACPI_BUTTON_COMPONENT
-ACPI_MODULE_NAME               ("acpi_button")
+#define _COMPONENT              ACPI_BUTTON_COMPONENT
+ACPI_MODULE_NAME                ("acpi_button")
 
 struct acpibut_softc {
-       struct acpi_devnode *sc_node;   /* our ACPI devnode */
-       struct sysmon_pswitch sc_smpsw; /* our sysmon glue */
-       int sc_flags;                   /* see below */
+       struct acpi_devnode     *sc_node;
+       struct sysmon_pswitch    sc_smpsw;
 };
 
 static const char * const power_button_hid[] = {
@@ -72,13 +70,11 @@
        NULL
 };
 
-#define        ACPIBUT_F_VERBOSE               0x01    /* verbose events */
-
 static int     acpibut_match(device_t, cfdata_t, void *);
 static void    acpibut_attach(device_t, device_t, void *);
 static int     acpibut_detach(device_t, int);
 static void    acpibut_pressed_event(void *);
-static void    acpibut_notify_handler(ACPI_HANDLE, UINT32, void *);
+static void    acpibut_notify_handler(ACPI_HANDLE, uint32_t, void *);
 
 CFATTACH_DECL_NEW(acpibut, sizeof(struct acpibut_softc),
     acpibut_match, acpibut_attach, acpibut_detach, NULL);
@@ -126,36 +122,22 @@
        } else if (acpi_match_hid(aa->aa_node->ad_devinfo, sleep_button_hid)) {
                sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_SLEEP;
                desc = "Sleep";
-       } else {
-               panic("acpibut_attach: impossible");
-       }
+       } else
+               panic("%s: impossible", __func__);
 
        aprint_naive(": ACPI %s Button\n", desc);
        aprint_normal(": ACPI %s Button\n", desc);
 
        sc->sc_node = aa->aa_node;
 
-       if (sysmon_pswitch_register(&sc->sc_smpsw) != 0) {
-               aprint_error_dev(self, "unable to register with sysmon\n");
-               return;
-       }
+       (void)pmf_device_register(self, NULL, NULL)
+       (void)sysmon_pswitch_register(&sc->sc_smpsw);
 
        rv = AcpiInstallNotifyHandler(sc->sc_node->ad_handle,
            ACPI_DEVICE_NOTIFY, acpibut_notify_handler, self);
-       if (ACPI_FAILURE(rv)) {
-               aprint_error_dev(self,
-                   "unable to register DEVICE NOTIFY handler: %s\n",
-                   AcpiFormatException(rv));
-               return;
-       }
 
-#ifdef ACPI_BUT_DEBUG
-       /* Display the current state when it changes. */
-       sc->sc_flags = ACPIBUT_F_VERBOSE;
-#endif
-
-       if (!pmf_device_register(self, NULL, NULL))
-               aprint_error_dev(self, "couldn't establish power handler\n");
+       if (ACPI_FAILURE(rv))
+               aprint_error_dev(self, "failed to install notify handler\n");
 }
 
 /*
@@ -192,9 +174,7 @@
        device_t dv = arg;
        struct acpibut_softc *sc = device_private(dv);
 
-       if (sc->sc_flags & ACPIBUT_F_VERBOSE)
-               aprint_verbose_dev(dv, "button pressed\n");
-
+       aprint_debug_dev(dv, "button pressed\n");
        sysmon_pswitch_event(&sc->sc_smpsw, PSWITCH_EVENT_PRESSED);
 }
 
@@ -204,32 +184,20 @@
  *     Callback from ACPI interrupt handler to notify us of an event.
  */
 static void
-acpibut_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context)
+acpibut_notify_handler(ACPI_HANDLE handle, uint32_t notify, void *context)
 {
+       static const int handler = OSL_NOTIFY_HANDLER;
        device_t dv = context;
-       ACPI_STATUS rv;
 
        switch (notify) {
+
+     /* case ACPI_NOTIFY_S0SleepButtonPressed: */
        case ACPI_NOTIFY_S0PowerButtonPressed:
-#if 0
-       case ACPI_NOTIFY_S0SleepButtonPressed: /* same as above */
-#endif
-#ifdef ACPI_BUT_DEBUG
-               aprint_debug_dev(dv, "received ButtonPressed message\n");
-#endif
-               rv = AcpiOsExecute(OSL_NOTIFY_HANDLER,
-                   acpibut_pressed_event, dv);
-               if (ACPI_FAILURE(rv))
-                       aprint_error_dev(dv,
-                           "WARNING: unable to queue button pressed callback: %s\n",
-                           AcpiFormatException(rv));
+               (void)AcpiOsExecute(handler, acpibut_pressed_event, dv);
                break;
 
-       /* XXX ACPI_NOTIFY_DeviceWake?? */
-
        default:
-               aprint_error_dev(dv, "received unknown notify message: 0x%x\n",
-                   notify);
+               aprint_error_dev(dv, "unknown notify 0x%02X\n", notify);
        }
 }
 



Home | Main Index | Thread Index | Old Index