Module Name: src Committed By: jruoho Date: Sun Jan 2 06:05:47 UTC 2011
Modified Files: src/sys/dev/acpi: acpi.c acpi_power.c acpi_wakedev.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/sys/dev/acpi/acpi.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/acpi/acpi_power.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/acpi/acpi_wakedev.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/acpi.c diff -u src/sys/dev/acpi/acpi.c:1.223 src/sys/dev/acpi/acpi.c:1.224 --- src/sys/dev/acpi/acpi.c:1.223 Fri Dec 31 09:19:43 2010 +++ src/sys/dev/acpi/acpi.c Sun Jan 2 06:05:47 2011 @@ -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; Index: src/sys/dev/acpi/acpi_power.c diff -u src/sys/dev/acpi/acpi_power.c:1.23 src/sys/dev/acpi/acpi_power.c:1.24 --- src/sys/dev/acpi/acpi_power.c:1.23 Fri Oct 8 07:04:31 2010 +++ src/sys/dev/acpi/acpi_power.c Sun Jan 2 06:05:47 2011 @@ -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) Index: src/sys/dev/acpi/acpi_wakedev.c diff -u src/sys/dev/acpi/acpi_wakedev.c:1.18 src/sys/dev/acpi/acpi_wakedev.c:1.19 --- src/sys/dev/acpi/acpi_wakedev.c:1.18 Fri Oct 8 07:04:31 2010 +++ src/sys/dev/acpi/acpi_wakedev.c Sun Jan 2 06:05:47 2011 @@ -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 <jmcne...@invisible.ca> @@ -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)