Module Name: src Committed By: jmcneill Date: Sun Oct 24 18:26:29 UTC 2010
Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: add support for building as a module To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/wmi/wmi_acpi.c 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/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.8 src/sys/dev/acpi/wmi/wmi_acpi.c:1.9 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.8 Sun Oct 24 15:07:20 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Sun Oct 24 18:26:29 2010 @@ -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 <jruoho...@iki.fi> @@ -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 */