Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi/wmi add support for building as a module
details: https://anonhg.NetBSD.org/src/rev/8b24cba39215
branches: trunk
changeset: 758180:8b24cba39215
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Oct 24 18:26:29 2010 +0000
description:
add support for building as a module
diffstat:
sys/dev/acpi/wmi/wmi_acpi.c | 81 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 79 insertions(+), 2 deletions(-)
diffs (105 lines):
diff -r f1decf8fe0d2 -r 8b24cba39215 sys/dev/acpi/wmi/wmi_acpi.c
--- a/sys/dev/acpi/wmi/wmi_acpi.c Sun Oct 24 17:53:27 2010 +0000
+++ b/sys/dev/acpi/wmi/wmi_acpi.c Sun Oct 24 18:26:29 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wmi_acpi.c,v 1.8 2010/10/24 15:07:20 jmcneill Exp $ */
+/* $NetBSD: wmi_acpi.c,v 1.9 2010/10/24 18:26:29 jmcneill Exp $ */
/*-
* Copyright (c) 2009, 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,13 +27,14 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.8 2010/10/24 15:07:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.9 2010/10/24 18:26:29 jmcneill Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/endian.h>
#include <sys/kmem.h>
#include <sys/systm.h>
+#include <sys/module.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
@@ -726,3 +727,79 @@
return AcpiEvaluateObject(sc->sc_node->ad_handle, path, &arg, obuf);
}
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, acpiwmi, NULL);
+CFDRIVER_DECL(acpiwmi, DV_DULL, NULL);
+
+static int acpiwmiloc[] = { -1 };
+extern struct cfattach acpiwmi_ca;
+
+static struct cfparent acpiparent = {
+ "acpinodebus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata acpiwmi_cfdata[] = {
+ {
+ .cf_name = "acpiwmi",
+ .cf_atname = "acpiwmi",
+ .cf_unit = 0,
+ .cf_fstate = FSTATE_STAR,
+ .cf_loc = acpiwmiloc,
+ .cf_flags = 0,
+ .cf_pspec = &acpiparent,
+ },
+
+ { NULL }
+};
+
+static int
+acpiwmi_modcmd(modcmd_t cmd, void *opaque)
+{
+ int err;
+
+ switch (cmd) {
+
+ case MODULE_CMD_INIT:
+
+ err = config_cfdriver_attach(&acpiwmi_cd);
+
+ if (err != 0)
+ return err;
+
+ err = config_cfattach_attach("acpiwmi", &acpiwmi_ca);
+
+ if (err != 0) {
+ config_cfdriver_detach(&acpiwmi_cd);
+ return err;
+ }
+
+ err = config_cfdata_attach(acpiwmi_cfdata, 1);
+
+ if (err != 0) {
+ config_cfattach_detach("acpiwmi", &acpiwmi_ca);
+ config_cfdriver_detach(&acpiwmi_cd);
+ return err;
+ }
+
+ return 0;
+
+ case MODULE_CMD_FINI:
+
+ err = config_cfdata_detach(acpiwmi_cfdata);
+
+ if (err != 0)
+ return err;
+
+ config_cfattach_detach("acpiwmi", &acpiwmi_ca);
+ config_cfdriver_detach(&acpiwmi_cd);
+
+ return 0;
+
+ default:
+ return ENOTTY;
+ }
+}
+
+#endif /* _MODULE */
Home |
Main Index |
Thread Index |
Old Index