Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Add support for module(9).
details: https://anonhg.NetBSD.org/src/rev/649a249b91df
branches: trunk
changeset: 758205:649a249b91df
user: jruoho <jruoho%NetBSD.org@localhost>
date: Tue Oct 26 05:28:29 2010 +0000
description:
Add support for module(9).
diffstat:
sys/dev/acpi/asus_acpi.c | 34 ++++++++++++++++-
sys/dev/acpi/hpqlb_acpi.c | 86 +++++++++++++++++++++++++++++++++-------------
2 files changed, 92 insertions(+), 28 deletions(-)
diffs (225 lines):
diff -r 9ff7bee2fcc5 -r 649a249b91df sys/dev/acpi/asus_acpi.c
--- a/sys/dev/acpi/asus_acpi.c Tue Oct 26 05:12:34 2010 +0000
+++ b/sys/dev/acpi/asus_acpi.c Tue Oct 26 05:28:29 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: asus_acpi.c,v 1.20 2010/04/15 07:02:24 jruoho Exp $ */
+/* $NetBSD: asus_acpi.c,v 1.21 2010/10/26 05:28:29 jruoho Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,10 +27,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: asus_acpi.c,v 1.20 2010/04/15 07:02:24 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asus_acpi.c,v 1.21 2010/10/26 05:28:29 jruoho Exp $");
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/module.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -320,7 +321,7 @@
if (err || newp == NULL)
return err;
- if (tmp < 0 || tmp >= sc->sc_cfvnum)
+ if (tmp < 0 || (uint64_t)tmp >= sc->sc_cfvnum)
return EINVAL;
rv = acpi_eval_set_integer(sc->sc_node->ad_handle,
@@ -410,3 +411,30 @@
*speed = (rpmh << 8) | rpml;
return true;
}
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, asus, NULL);
+
+#include "ioconf.c"
+
+static int
+asus_modcmd(modcmd_t cmd, void *context)
+{
+
+ switch (cmd) {
+
+ case MODULE_CMD_INIT:
+ return config_init_component(cfdriver_ioconf_asus,
+ cfattach_ioconf_asus, cfdata_ioconf_asus);
+
+ case MODULE_CMD_FINI:
+ return config_fini_component(cfdriver_ioconf_asus,
+ cfattach_ioconf_asus, cfdata_ioconf_asus);
+
+ default:
+ return ENOTTY;
+ }
+}
+
+#endif /* _MODULE */
diff -r 9ff7bee2fcc5 -r 649a249b91df sys/dev/acpi/hpqlb_acpi.c
--- a/sys/dev/acpi/hpqlb_acpi.c Tue Oct 26 05:12:34 2010 +0000
+++ b/sys/dev/acpi/hpqlb_acpi.c Tue Oct 26 05:28:29 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hpqlb_acpi.c,v 1.7 2010/03/05 14:00:17 jruoho Exp $ */
+/* $NetBSD: hpqlb_acpi.c,v 1.8 2010/10/26 05:28:29 jruoho Exp $ */
/*-
* Copyright (c) 2008 Christoph Egger <cegger%netbsd.org@localhost>
@@ -27,10 +27,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpqlb_acpi.c,v 1.7 2010/03/05 14:00:17 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpqlb_acpi.c,v 1.8 2010/10/26 05:28:29 jruoho Exp $");
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/module.h>
#include <sys/systm.h>
#include <machine/pio.h>
@@ -46,12 +47,6 @@
#define _COMPONENT ACPI_RESOURCE_COMPONENT
ACPI_MODULE_NAME ("hpqlb_acpi")
-#ifdef HPQLB_DEBUG
-#define DPRINTF(x) do { printf x; } while (/* CONSTCOND */0)
-#else
-#define DPRINTF(x)
-#endif
-
struct hpqlb_softc {
device_t sc_dev;
struct acpi_devnode *sc_node;
@@ -89,6 +84,7 @@
static int hpqlb_match(device_t, cfdata_t, void *);
static void hpqlb_attach(device_t, device_t, void *);
+static int hpqlb_detach(device_t, int);
static int hpqlb_finalize(device_t);
static int hpqlb_hotkey_handler(struct wskbd_softc *, void *, u_int, int);
@@ -97,7 +93,7 @@
static bool hpqlb_resume(device_t, const pmf_qual_t *);
CFATTACH_DECL_NEW(hpqlb, sizeof(struct hpqlb_softc),
- hpqlb_match, hpqlb_attach, NULL, NULL);
+ hpqlb_match, hpqlb_attach, hpqlb_detach, NULL);
static const char * const hpqlb_ids[] = {
"HPQ0006",
@@ -131,29 +127,44 @@
hpqlb_init(self);
if (config_finalize_register(self, hpqlb_finalize) != 0)
- aprint_error_dev(self,
- "WARNING: unable to register hpqlb finalizer\n");
+ aprint_error_dev(self, "unable to register hpqlb finalizer\n");
sc->sc_smpsw_displaycycle_valid = true;
+
sc->sc_smpsw[HP_PSW_DISPLAY_CYCLE].smpsw_name =
PSWITCH_HK_DISPLAY_CYCLE;
+
sc->sc_smpsw[HP_PSW_DISPLAY_CYCLE].smpsw_type =
PSWITCH_TYPE_HOTKEY;
- if (sysmon_pswitch_register(&sc->sc_smpsw[HP_PSW_DISPLAY_CYCLE])) {
- aprint_error_dev(self, "couldn't register with sysmon\n");
+
+ if (sysmon_pswitch_register(&sc->sc_smpsw[HP_PSW_DISPLAY_CYCLE]) != 0)
sc->sc_smpsw_displaycycle_valid = false;
- }
sc->sc_smpsw_sleep_valid = true;
sc->sc_smpsw[HP_PSW_SLEEP].smpsw_name = device_xname(self);
sc->sc_smpsw[HP_PSW_SLEEP].smpsw_type = PSWITCH_TYPE_SLEEP;
- if (sysmon_pswitch_register(&sc->sc_smpsw[HP_PSW_SLEEP])) {
- aprint_error_dev(self, "couldn't register sleep with sysmon\n");
+
+ if (sysmon_pswitch_register(&sc->sc_smpsw[HP_PSW_SLEEP]) != 0)
sc->sc_smpsw_sleep_valid = false;
- }
+
+ (void)pmf_device_register(self, NULL, hpqlb_resume);
+}
+
+static int
+hpqlb_detach(device_t self, int flags)
+{
+ struct hpqlb_softc *sc = device_private(self);
- if (!pmf_device_register(self, NULL, hpqlb_resume))
- aprint_error_dev(self, "couldn't establish power handler\n");
+ pmf_device_deregister(self);
+ wskbd_hotkey_deregister(sc->sc_wskbddev);
+
+ if (sc->sc_smpsw_sleep_valid != false)
+ sysmon_pswitch_unregister(&sc->sc_smpsw[HP_PSW_SLEEP]);
+
+ if (sc->sc_smpsw_displaycycle_valid != false)
+ sysmon_pswitch_unregister(&sc->sc_smpsw[HP_PSW_DISPLAY_CYCLE]);
+
+ return 0;
}
static int
@@ -193,11 +204,8 @@
case HP_QLB_Sleep:
if (type != WSCONS_EVENT_KEY_DOWN)
break;
- if (sc->sc_smpsw_sleep_valid == false) {
- DPRINTF(("%s: Sleep hotkey\n",
- device_xname(sc->sc_dev)));
+ if (sc->sc_smpsw_sleep_valid == false)
break;
- }
sysmon_pswitch_event(&sc->sc_smpsw[HP_PSW_SLEEP],
PSWITCH_EVENT_PRESSED);
break;
@@ -219,8 +227,9 @@
pmf_event_inject(NULL, PMFE_CHASSIS_LID_OPEN);
break;
default:
- DPRINTF(("%s: unknown hotkey 0x%02x\n",
- device_xname(sc->sc_dev), value));
+
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "unknown hotkey "
+ "0x%02x\n", value));
ret = 0; /* Assume, this is no hotkey */
break;
}
@@ -293,3 +302,30 @@
return true;
}
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, hpqlb, NULL);
+
+#include "ioconf.c"
+
+static int
+hpqlb_modcmd(modcmd_t cmd, void *context)
+{
+
+ switch (cmd) {
+
+ case MODULE_CMD_INIT:
+ return config_init_component(cfdriver_ioconf_hpqlb,
+ cfattach_ioconf_hpqlb, cfdata_ioconf_hpqlb);
+
+ case MODULE_CMD_FINI:
+ return config_fini_component(cfdriver_ioconf_hpqlb,
+ cfattach_ioconf_hpqlb, cfdata_ioconf_hpqlb);
+
+ default:
+ return ENOTTY;
+ }
+}
+
+#endif /* _MODULE */
Home |
Main Index |
Thread Index |
Old Index