Module Name: src Committed By: gsutre Date: Fri Oct 8 07:04:32 UTC 2010
Modified Files: src/sys/dev/acpi: acpi_power.c acpi_wakedev.c Log Message: Store sysctl MIBs instead of a pointer to the root of the sysctl sub-tree (because the pointer may be invalid at the time we use it). ok jruoho@ To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/acpi/acpi_power.c cvs rdiff -u -r1.17 -r1.18 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_power.c diff -u src/sys/dev/acpi/acpi_power.c:1.22 src/sys/dev/acpi/acpi_power.c:1.23 --- src/sys/dev/acpi/acpi_power.c:1.22 Fri Aug 6 18:10:40 2010 +++ src/sys/dev/acpi/acpi_power.c Fri Oct 8 07:04:31 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_power.c,v 1.22 2010/08/06 18:10:40 jruoho Exp $ */ +/* $NetBSD: acpi_power.c,v 1.23 2010/10/08 07:04:31 gsutre 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.22 2010/08/06 18:10:40 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.23 2010/10/08 07:04:31 gsutre Exp $"); #include <sys/param.h> #include <sys/kmem.h> @@ -99,7 +99,8 @@ static TAILQ_HEAD(, acpi_power_res) res_head = TAILQ_HEAD_INITIALIZER(res_head); -static const struct sysctlnode *anode = NULL; +static int32_t acpi_power_acpinode = CTL_EOL; +static int32_t acpi_power_powernode = CTL_EOL; static struct acpi_power_res *acpi_power_res_init(ACPI_HANDLE); static struct acpi_power_res *acpi_power_res_get(ACPI_HANDLE); @@ -691,6 +692,7 @@ SYSCTL_SETUP(sysctl_acpi_power_setup, "sysctl hw.acpi.power subtree setup") { + const struct sysctlnode *anode; int err; err = sysctl_createv(NULL, 0, NULL, &anode, @@ -699,7 +701,7 @@ CTL_HW, CTL_EOL); if (err != 0) - goto fail; + return; err = sysctl_createv(NULL, 0, &anode, &anode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "acpi", @@ -707,7 +709,9 @@ CTL_CREATE, CTL_EOL); if (err != 0) - goto fail; + return; + + acpi_power_acpinode = anode->sysctl_num; err = sysctl_createv(NULL, 0, &anode, &anode, CTLFLAG_PERMANENT, CTLTYPE_NODE, @@ -716,12 +720,9 @@ CTL_CREATE, CTL_EOL); if (err != 0) - goto fail; - - return; + return; -fail: - anode = NULL; + acpi_power_powernode = anode->sysctl_num; } void @@ -732,7 +733,8 @@ KASSERT(ad != NULL && ad->ad_root != NULL); KASSERT((ad->ad_flags & ACPI_DEVICE_POWER) != 0); - if (anode == NULL) + if (acpi_power_acpinode == CTL_EOL || + acpi_power_powernode == CTL_EOL) return; /* @@ -740,9 +742,10 @@ * may power multiple devices, it is unclear whether * power resources should be controllable by an user. */ - err = sysctl_createv(NULL, 0, &anode, NULL, + 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, 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.17 src/sys/dev/acpi/acpi_wakedev.c:1.18 --- src/sys/dev/acpi/acpi_wakedev.c:1.17 Mon Jun 7 14:12:20 2010 +++ src/sys/dev/acpi/acpi_wakedev.c Fri Oct 8 07:04:31 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakedev.c,v 1.17 2010/06/07 14:12:20 jruoho Exp $ */ +/* $NetBSD: acpi_wakedev.c,v 1.18 2010/10/08 07:04:31 gsutre 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.17 2010/06/07 14:12:20 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.18 2010/10/08 07:04:31 gsutre Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -50,7 +50,8 @@ NULL, }; -static const struct sysctlnode *rnode = NULL; +static int32_t acpi_wakedev_acpinode = CTL_EOL; +static int32_t acpi_wakedev_wakenode = CTL_EOL; static void acpi_wakedev_method(struct acpi_devnode *, int, int); static void acpi_wakedev_gpe(struct acpi_devnode *, int, int); @@ -58,6 +59,7 @@ SYSCTL_SETUP(sysctl_acpi_wakedev_setup, "sysctl hw.acpi.wake subtree setup") { + const struct sysctlnode *rnode; int err; err = sysctl_createv(NULL, 0, NULL, &rnode, @@ -66,7 +68,7 @@ CTL_HW, CTL_EOL); if (err != 0) - goto fail; + return; err = sysctl_createv(NULL, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "acpi", @@ -74,7 +76,9 @@ CTL_CREATE, CTL_EOL); if (err != 0) - goto fail; + return; + + acpi_wakedev_acpinode = rnode->sysctl_num; err = sysctl_createv(NULL, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, @@ -83,12 +87,9 @@ CTL_CREATE, CTL_EOL); if (err != 0) - goto fail; - - return; + return; -fail: - rnode = NULL; + acpi_wakedev_wakenode = rnode->sysctl_num; } void @@ -104,12 +105,14 @@ if (acpi_match_hid(ad->ad_devinfo, acpi_wakedev_default)) ad->ad_wake = 1; - if (rnode == NULL) + if (acpi_wakedev_acpinode == CTL_EOL || + acpi_wakedev_wakenode == CTL_EOL) return; - err = sysctl_createv(NULL, 0, &rnode, NULL, + 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, CTL_CREATE, CTL_EOL); if (err != 0)