Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Introduce support for ACPI kernel modules.



details:   https://anonhg.NetBSD.org/src/rev/e1a28e3a91df
branches:  trunk
changeset: 752528:e1a28e3a91df
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Feb 28 17:22:41 2010 +0000

description:
Introduce support for ACPI kernel modules.

Tested on couple of laptops.

diffstat:

 sys/dev/acpi/acpi_acad.c     |  81 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/acpi_bat.c      |  81 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/acpi_button.c   |  81 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/acpi_lid.c      |  81 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/thinkpad_acpi.c |  81 ++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 395 insertions(+), 10 deletions(-)

diffs (truncated from 517 to 300 lines):

diff -r 376277224652 -r e1a28e3a91df sys/dev/acpi/acpi_acad.c
--- a/sys/dev/acpi/acpi_acad.c  Sun Feb 28 17:22:01 2010 +0000
+++ b/sys/dev/acpi/acpi_acad.c  Sun Feb 28 17:22:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_acad.c,v 1.40 2010/02/24 22:37:56 dyoung Exp $    */
+/*     $NetBSD: acpi_acad.c,v 1.41 2010/02/28 17:22:41 jruoho Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,11 +40,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.40 2010/02/24 22:37:56 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.41 2010/02/28 17:22:41 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
+#include <sys/module.h>
 #include <sys/mutex.h>
 
 #include <dev/acpi/acpica.h>
@@ -301,3 +302,79 @@
        sysmon_envsys_destroy(sc->sc_sme);
        sc->sc_sme = NULL;
 }
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, acpiacad, NULL);
+CFDRIVER_DECL(acpiacad, DV_DULL, NULL);
+
+static int acpiacadloc[] = { -1 };
+extern struct cfattach acpiacad_ca;
+
+static struct cfparent acpiparent = {
+       "acpinodebus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata acpiacad_cfdata[] = {
+       {
+               .cf_name = "acpiacad",
+               .cf_atname = "acpiacad",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = acpiacadloc,
+               .cf_flags = 0,
+               .cf_pspec = &acpiparent,
+       },
+
+       { NULL }
+};
+
+static int
+acpiacad_modcmd(modcmd_t cmd, void *context)
+{
+       int err;
+
+       switch (cmd) {
+
+       case MODULE_CMD_INIT:
+
+               err = config_cfdriver_attach(&acpiacad_cd);
+
+               if (err != 0)
+                       return err;
+
+               err = config_cfattach_attach("acpiacad", &acpiacad_ca);
+
+               if (err != 0) {
+                       config_cfdriver_detach(&acpiacad_cd);
+                       return err;
+               }
+
+               err = config_cfdata_attach(acpiacad_cfdata, 1);
+
+               if (err != 0) {
+                       config_cfattach_detach("acpiacad", &acpiacad_ca);
+                       config_cfdriver_detach(&acpiacad_cd);
+                       return err;
+               }
+
+               return 0;
+
+       case MODULE_CMD_FINI:
+
+               err = config_cfdata_detach(acpiacad_cfdata);
+
+               if (err != 0)
+                       return err;
+
+               config_cfattach_detach("acpiacad", &acpiacad_ca);
+               config_cfdriver_detach(&acpiacad_cd);
+
+               return 0;
+
+       default:
+               return ENOTTY;
+       }
+}
+
+#endif /* _MODULE */
diff -r 376277224652 -r e1a28e3a91df sys/dev/acpi/acpi_bat.c
--- a/sys/dev/acpi/acpi_bat.c   Sun Feb 28 17:22:01 2010 +0000
+++ b/sys/dev/acpi/acpi_bat.c   Sun Feb 28 17:22:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_bat.c,v 1.82 2010/02/24 22:37:56 dyoung Exp $     */
+/*     $NetBSD: acpi_bat.c,v 1.83 2010/02/28 17:22:41 jruoho Exp $     */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -75,13 +75,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.82 2010/02/24 22:37:56 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.83 2010/02/28 17:22:41 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>                /* for hz */
 #include <sys/kmem.h>
 #include <sys/device.h>
+#include <sys/module.h>
 #include <sys/mutex.h>
 
 #include <dev/sysmon/sysmonvar.h>
@@ -782,3 +783,79 @@
 
        return true;
 }
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, acpibat, NULL);
+CFDRIVER_DECL(acpibat, DV_DULL, NULL);
+
+static int acpibatloc[] = { -1 };
+extern struct cfattach acpibat_ca;
+
+static struct cfparent acpiparent = {
+       "acpinodebus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata acpibat_cfdata[] = {
+       {
+               .cf_name = "acpibat",
+               .cf_atname = "acpibat",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = acpibatloc,
+               .cf_flags = 0,
+               .cf_pspec = &acpiparent,
+       },
+
+       { NULL }
+};
+
+static int
+acpibat_modcmd(modcmd_t cmd, void *context)
+{
+       int err;
+
+       switch (cmd) {
+
+       case MODULE_CMD_INIT:
+
+               err = config_cfdriver_attach(&acpibat_cd);
+
+               if (err != 0)
+                       return err;
+
+               err = config_cfattach_attach("acpibat", &acpibat_ca);
+
+               if (err != 0) {
+                       config_cfdriver_detach(&acpibat_cd);
+                       return err;
+               }
+
+               err = config_cfdata_attach(acpibat_cfdata, 1);
+
+               if (err != 0) {
+                       config_cfattach_detach("acpibat", &acpibat_ca);
+                       config_cfdriver_detach(&acpibat_cd);
+                       return err;
+               }
+
+               return 0;
+
+       case MODULE_CMD_FINI:
+
+               err = config_cfdata_detach(acpibat_cfdata);
+
+               if (err != 0)
+                       return err;
+
+               config_cfattach_detach("acpibat", &acpibat_ca);
+               config_cfdriver_detach(&acpibat_cd);
+
+               return 0;
+
+       default:
+               return ENOTTY;
+       }
+}
+
+#endif /* _MODULE */
diff -r 376277224652 -r e1a28e3a91df sys/dev/acpi/acpi_button.c
--- a/sys/dev/acpi/acpi_button.c        Sun Feb 28 17:22:01 2010 +0000
+++ b/sys/dev/acpi/acpi_button.c        Sun Feb 28 17:22:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_button.c,v 1.30 2010/01/31 06:10:53 jruoho Exp $  */
+/*     $NetBSD: acpi_button.c,v 1.31 2010/02/28 17:22:41 jruoho Exp $  */
 
 /*
  * Copyright 2001, 2003 Wasabi Systems, Inc.
@@ -40,11 +40,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_button.c,v 1.30 2010/01/31 06:10:53 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_button.c,v 1.31 2010/02/28 17:22:41 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>
@@ -231,3 +232,79 @@
                    notify);
        }
 }
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, acpibut, NULL);
+CFDRIVER_DECL(acpibut, DV_DULL, NULL);
+
+static int acpibutloc[] = { -1 };
+extern struct cfattach acpibut_ca;
+
+static struct cfparent acpiparent = {
+       "acpinodebus", NULL, DVUNIT_ANY
+};
+
+static struct cfdata acpibut_cfdata[] = {
+       {
+               .cf_name = "acpibut",
+               .cf_atname = "acpibut",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = acpibutloc,
+               .cf_flags = 0,
+               .cf_pspec = &acpiparent,
+       },
+
+       { NULL }
+};
+
+static int
+acpibut_modcmd(modcmd_t cmd, void *context)
+{
+       int err;
+
+       switch (cmd) {
+
+       case MODULE_CMD_INIT:
+
+               err = config_cfdriver_attach(&acpibut_cd);
+
+               if (err != 0)
+                       return err;
+
+               err = config_cfattach_attach("acpibut", &acpibut_ca);
+
+               if (err != 0) {
+                       config_cfdriver_detach(&acpibut_cd);
+                       return err;
+               }
+
+               err = config_cfdata_attach(acpibut_cfdata, 1);
+
+               if (err != 0) {
+                       config_cfattach_detach("acpibut", &acpibut_ca);
+                       config_cfdriver_detach(&acpibut_cd);
+                       return err;
+               }
+
+               return 0;
+
+       case MODULE_CMD_FINI:
+
+               err = config_cfdata_detach(acpibut_cfdata);
+
+               if (err != 0)
+                       return err;
+



Home | Main Index | Thread Index | Old Index