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 modules



details:   https://anonhg.NetBSD.org/src/rev/b2d17667885d
branches:  trunk
changeset: 758175:b2d17667885d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Oct 24 16:25:31 2010 +0000

description:
add support for building as modules

diffstat:

 sys/dev/acpi/wmi/wmi_dell.c |  81 +++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/wmi/wmi_hp.c   |  81 +++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/wmi/wmi_msi.c  |  81 +++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 237 insertions(+), 6 deletions(-)

diffs (truncated from 307 to 300 lines):

diff -r ee74f7e933da -r b2d17667885d sys/dev/acpi/wmi/wmi_dell.c
--- a/sys/dev/acpi/wmi/wmi_dell.c       Sun Oct 24 15:07:20 2010 +0000
+++ b/sys/dev/acpi/wmi/wmi_dell.c       Sun Oct 24 16:25:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wmi_dell.c,v 1.4 2010/06/30 07:58:11 jruoho Exp $ */
+/*     $NetBSD: wmi_dell.c,v 1.5 2010/10/24 16:25:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -31,10 +31,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.4 2010/06/30 07:58:11 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.5 2010/10/24 16:25:31 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
+#include <sys/module.h>
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -231,3 +232,79 @@
                aprint_error_dev(sc->sc_dev, "failed to get data for "
                    "event 0x%02X: %s\n", evt, AcpiFormatException(rv));
 }
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, wmidell, NULL);
+CFDRIVER_DECL(wmidell, DV_DULL, NULL);
+
+static int wmidellloc[] = { -1 };
+extern struct cfattach wmidell_ca;
+
+static struct cfparent wmiparent = {
+       "acpiwmibus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata wmidell_cfdata[] = {
+       {
+               .cf_name = "wmidell",
+               .cf_atname = "wmidell",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = wmidellloc,
+               .cf_flags = 0,
+               .cf_pspec = &wmiparent,
+       },
+
+       { NULL }
+};
+
+static int
+wmidell_modcmd(modcmd_t cmd, void *opaque)
+{
+       int err;
+
+       switch (cmd) {
+
+       case MODULE_CMD_INIT:
+
+               err = config_cfdriver_attach(&wmidell_cd);
+
+               if (err != 0)
+                       return err;
+
+               err = config_cfattach_attach("wmidell", &wmidell_ca);
+
+               if (err != 0) {
+                       config_cfdriver_detach(&wmidell_cd);
+                       return err;
+               }
+
+               err = config_cfdata_attach(wmidell_cfdata, 1);
+
+               if (err != 0) {
+                       config_cfattach_detach("wmidell", &wmidell_ca);
+                       config_cfdriver_detach(&wmidell_cd);
+                       return err;
+               }
+
+               return 0;
+
+       case MODULE_CMD_FINI:
+
+               err = config_cfdata_detach(wmidell_cfdata);
+
+               if (err != 0)
+                       return err;
+
+               config_cfattach_detach("wmidell", &wmidell_ca);
+               config_cfdriver_detach(&wmidell_cd);
+
+               return 0;
+
+       default:
+               return ENOTTY;
+       }
+}
+
+#endif /* _MODULE */
diff -r ee74f7e933da -r b2d17667885d sys/dev/acpi/wmi/wmi_hp.c
--- a/sys/dev/acpi/wmi/wmi_hp.c Sun Oct 24 15:07:20 2010 +0000
+++ b/sys/dev/acpi/wmi/wmi_hp.c Sun Oct 24 16:25:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wmi_hp.c,v 1.2 2010/06/30 07:58:11 jruoho Exp $ */
+/*     $NetBSD: wmi_hp.c,v 1.3 2010/10/24 16:25:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -57,11 +57,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.2 2010/06/30 07:58:11 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.3 2010/10/24 16:25:31 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/kmem.h>
+#include <sys/module.h>
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -529,3 +530,79 @@
                sc->sc_sensor[WMI_HP_SENSOR_WWAN].state = ENVSYS_SVALID;
        }
 }
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, wmihp, NULL);
+CFDRIVER_DECL(wmihp, DV_DULL, NULL);
+
+static int wmihploc[] = { -1 };
+extern struct cfattach wmihp_ca;
+
+static struct cfparent wmiparent = {
+       "acpiwmibus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata wmihp_cfdata[] = {
+       {
+               .cf_name = "wmihp",
+               .cf_atname = "wmihp",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = wmihploc,
+               .cf_flags = 0,
+               .cf_pspec = &wmiparent,
+       },
+
+       { NULL }
+};
+
+static int
+wmihp_modcmd(modcmd_t cmd, void *opaque)
+{
+       int err;
+
+       switch (cmd) {
+
+       case MODULE_CMD_INIT:
+
+               err = config_cfdriver_attach(&wmihp_cd);
+
+               if (err != 0)
+                       return err;
+
+               err = config_cfattach_attach("wmihp", &wmihp_ca);
+
+               if (err != 0) {
+                       config_cfdriver_detach(&wmihp_cd);
+                       return err;
+               }
+
+               err = config_cfdata_attach(wmihp_cfdata, 1);
+
+               if (err != 0) {
+                       config_cfattach_detach("wmihp", &wmihp_ca);
+                       config_cfdriver_detach(&wmihp_cd);
+                       return err;
+               }
+
+               return 0;
+
+       case MODULE_CMD_FINI:
+
+               err = config_cfdata_detach(wmihp_cfdata);
+
+               if (err != 0)
+                       return err;
+
+               config_cfattach_detach("wmihp", &wmihp_ca);
+               config_cfdriver_detach(&wmihp_cd);
+
+               return 0;
+
+       default:
+               return ENOTTY;
+       }
+}
+
+#endif /* _MODULE */
diff -r ee74f7e933da -r b2d17667885d sys/dev/acpi/wmi/wmi_msi.c
--- a/sys/dev/acpi/wmi/wmi_msi.c        Sun Oct 24 15:07:20 2010 +0000
+++ b/sys/dev/acpi/wmi/wmi_msi.c        Sun Oct 24 16:25:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wmi_msi.c,v 1.1 2010/10/24 08:54:15 jruoho Exp $ */
+/*     $NetBSD: wmi_msi.c,v 1.2 2010/10/24 16:25:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,10 +31,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wmi_msi.c,v 1.1 2010/10/24 08:54:15 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_msi.c,v 1.2 2010/10/24 16:25:31 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
+#include <sys/module.h>
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -192,3 +193,79 @@
                aprint_error_dev(sc->sc_dev, "failed to get data for "
                    "event 0x%02X: %s\n", evt, AcpiFormatException(rv));
 }
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, wmimsi, NULL);
+CFDRIVER_DECL(wmimsi, DV_DULL, NULL);
+
+static int wmimsiloc[] = { -1 };
+extern struct cfattach wmimsi_ca;
+
+static struct cfparent wmiparent = {
+       "acpiwmibus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata wmimsi_cfdata[] = {
+       {
+               .cf_name = "wmimsi",
+               .cf_atname = "wmimsi",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = wmimsiloc,
+               .cf_flags = 0,
+               .cf_pspec = &wmiparent,
+       },
+
+       { NULL }
+};
+
+static int
+wmimsi_modcmd(modcmd_t cmd, void *opaque)
+{
+       int err;
+
+       switch (cmd) {
+
+       case MODULE_CMD_INIT:
+
+               err = config_cfdriver_attach(&wmimsi_cd);
+
+               if (err != 0)
+                       return err;
+
+               err = config_cfattach_attach("wmimsi", &wmimsi_ca);
+
+               if (err != 0) {
+                       config_cfdriver_detach(&wmimsi_cd);
+                       return err;
+               }
+
+               err = config_cfdata_attach(wmimsi_cfdata, 1);
+
+               if (err != 0) {
+                       config_cfattach_detach("wmimsi", &wmimsi_ca);
+                       config_cfdriver_detach(&wmimsi_cd);
+                       return err;
+               }
+
+               return 0;
+
+       case MODULE_CMD_FINI:
+
+               err = config_cfdata_detach(wmimsi_cfdata);
+
+               if (err != 0)
+                       return err;
+
+               config_cfattach_detach("wmimsi", &wmimsi_ca);
+               config_cfdriver_detach(&wmimsi_cd);
+
+               return 0;



Home | Main Index | Thread Index | Old Index