Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Store sysctl MIBs instead of a pointer to the r...
details: https://anonhg.NetBSD.org/src/rev/66fbbdc11961
branches: trunk
changeset: 757970:66fbbdc11961
user: gsutre <gsutre%NetBSD.org@localhost>
date: Fri Oct 08 07:04:31 2010 +0000
description:
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@
diffstat:
sys/dev/acpi/acpi_power.c | 27 +++++++++++++++------------
sys/dev/acpi/acpi_wakedev.c | 27 +++++++++++++++------------
2 files changed, 30 insertions(+), 24 deletions(-)
diffs (181 lines):
diff -r 3e0b7e2f77f3 -r 66fbbdc11961 sys/dev/acpi/acpi_power.c
--- a/sys/dev/acpi/acpi_power.c Thu Oct 07 20:39:54 2010 +0000
+++ b/sys/dev/acpi/acpi_power.c Fri Oct 08 07:04:31 2010 +0000
@@ -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)
diff -r 3e0b7e2f77f3 -r 66fbbdc11961 sys/dev/acpi/acpi_wakedev.c
--- a/sys/dev/acpi/acpi_wakedev.c Thu Oct 07 20:39:54 2010 +0000
+++ b/sys/dev/acpi/acpi_wakedev.c Fri Oct 08 07:04:31 2010 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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)
Home |
Main Index |
Thread Index |
Old Index