Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Use "real" device names for the hw.acpi.wake an...



details:   https://anonhg.NetBSD.org/src/rev/924037d873f9
branches:  trunk
changeset: 760287:924037d873f9
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Jan 02 06:05:47 2011 +0000

description:
Use "real" device names for the hw.acpi.wake and hw.acpi.power sysctl(8)
trees. For instance, instead of hw.acpi.wake.DURT, we have hw.acpi.wake.wm0
for wm(4). This is a temporary solution, but without solving the big
abstraction questions, this is the best we can do.

diffstat:

 sys/dev/acpi/acpi.c         |  14 +++++++++-----
 sys/dev/acpi/acpi_power.c   |  30 ++++++++++++++++++++----------
 sys/dev/acpi/acpi_wakedev.c |  25 ++++++++++++++++++++-----
 3 files changed, 49 insertions(+), 20 deletions(-)

diffs (177 lines):

diff -r 54f08877a656 -r 924037d873f9 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Sun Jan 02 05:48:55 2011 +0000
+++ b/sys/dev/acpi/acpi.c       Sun Jan 02 06:05:47 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.223 2010/12/31 09:19:43 jruoho Exp $        */
+/*     $NetBSD: acpi.c,v 1.224 2011/01/02 06:05:47 jruoho Exp $        */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.223 2010/12/31 09:19:43 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.224 2011/01/02 06:05:47 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -213,7 +213,7 @@
 
 static int             acpi_rescan(device_t, const char *, const int *);
 static void            acpi_rescan_nodes(struct acpi_softc *);
-static void            acpi_rescan_capabilities(struct acpi_softc *);
+static void            acpi_rescan_capabilities(device_t);
 static int             acpi_print(void *aux, const char *);
 
 static void            acpi_notify_handler(ACPI_HANDLE, uint32_t, void *);
@@ -674,7 +674,10 @@
        (void)acpi_pcidev_scan(sc->sc_root);
        (void)acpi_rescan(sc->sc_dev, NULL, NULL);
 
-       acpi_rescan_capabilities(sc);
+       /*
+        * Defer rest of the configuration.
+        */
+       (void)config_defer(sc->sc_dev, acpi_rescan_capabilities);
 }
 
 static ACPI_STATUS
@@ -1008,8 +1011,9 @@
 }
 
 static void
-acpi_rescan_capabilities(struct acpi_softc *sc)
+acpi_rescan_capabilities(device_t self)
 {
+       struct acpi_softc *sc = device_private(self);
        struct acpi_devnode *ad;
        ACPI_HANDLE tmp;
        ACPI_STATUS rv;
diff -r 54f08877a656 -r 924037d873f9 sys/dev/acpi/acpi_power.c
--- a/sys/dev/acpi/acpi_power.c Sun Jan 02 05:48:55 2011 +0000
+++ b/sys/dev/acpi/acpi_power.c Sun Jan 02 06:05:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_power.c,v 1.23 2010/10/08 07:04:31 gsutre Exp $ */
+/* $NetBSD: acpi_power.c,v 1.24 2011/01/02 06:05:47 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.23 2010/10/08 07:04:31 gsutre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.24 2011/01/02 06:05:47 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -65,6 +65,7 @@
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpi_pci.h>
 #include <dev/acpi/acpi_power.h>
 
 #define _COMPONENT                     ACPI_BUS_COMPONENT
@@ -728,6 +729,8 @@
 void
 acpi_power_add(struct acpi_devnode *ad)
 {
+       const char *str = NULL;
+       device_t dev;
        int err;
 
        KASSERT(ad != NULL && ad->ad_root != NULL);
@@ -737,15 +740,22 @@
            acpi_power_powernode == CTL_EOL)
                return;
 
-       /*
-        * Make this read-only: because a single power resource
-        * may power multiple devices, it is unclear whether
-        * power resources should be controllable by an user.
-        */
+       if (ad->ad_device != NULL)
+               str = device_xname(ad->ad_device);
+       else {
+               dev = acpi_pcidev_find_dev(ad);
+
+               if (dev != NULL)
+                       str = device_xname(dev);
+       }
+
+       if (str == NULL)
+               return;
+
        err = sysctl_createv(NULL, 0, NULL, NULL,
-           CTLFLAG_READONLY, CTLTYPE_STRING, ad->ad_name,
-           NULL, acpi_power_sysctl, 0, ad, 0,
-           CTL_HW, acpi_power_acpinode, acpi_power_powernode,
+           CTLFLAG_READONLY, CTLTYPE_STRING, str,
+           NULL, acpi_power_sysctl, 0, ad, 0, CTL_HW,
+           acpi_power_acpinode, acpi_power_powernode,
            CTL_CREATE, CTL_EOL);
 
        if (err != 0)
diff -r 54f08877a656 -r 924037d873f9 sys/dev/acpi/acpi_wakedev.c
--- a/sys/dev/acpi/acpi_wakedev.c       Sun Jan 02 05:48:55 2011 +0000
+++ b/sys/dev/acpi/acpi_wakedev.c       Sun Jan 02 06:05:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_wakedev.c,v 1.18 2010/10/08 07:04:31 gsutre Exp $ */
+/* $NetBSD: acpi_wakedev.c,v 1.19 2011/01/02 06:05:47 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.18 2010/10/08 07:04:31 gsutre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.19 2011/01/02 06:05:47 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -36,6 +36,7 @@
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpi_pci.h>
 #include <dev/acpi/acpi_power.h>
 #include <dev/acpi/acpi_wakedev.h>
 
@@ -95,6 +96,8 @@
 void
 acpi_wakedev_add(struct acpi_devnode *ad)
 {
+       const char *str = NULL;
+       device_t dev;
        int err;
 
        KASSERT(ad != NULL && ad->ad_root != NULL);
@@ -109,10 +112,22 @@
            acpi_wakedev_wakenode == CTL_EOL)
                return;
 
+       if (ad->ad_device != NULL)
+               str = device_xname(ad->ad_device);
+       else {
+               dev = acpi_pcidev_find_dev(ad);
+
+               if (dev != NULL)
+                       str = device_xname(dev);
+       }
+
+       if (str == NULL)
+               return;
+
        err = sysctl_createv(NULL, 0, NULL, NULL,
-           CTLFLAG_READWRITE, CTLTYPE_BOOL, ad->ad_name,
-           NULL, NULL, 0, &ad->ad_wake, 0,
-           CTL_HW, acpi_wakedev_acpinode, acpi_wakedev_wakenode,
+           CTLFLAG_READWRITE, CTLTYPE_BOOL, str,
+           NULL, NULL, 0, &ad->ad_wake, 0, CTL_HW,
+           acpi_wakedev_acpinode, acpi_wakedev_wakenode,
            CTL_CREATE, CTL_EOL);
 
        if (err != 0)



Home | Main Index | Thread Index | Old Index