diff options
| author | jruoho <jruoho@NetBSD.org> | 2010-04-23 19:00:58 +0000 |
|---|---|---|
| committer | jruoho <jruoho@NetBSD.org> | 2010-04-23 19:00:58 +0000 |
| commit | ba4f1cd0dd817eef4ddf44d430ecfcb8c9c2d376 (patch) | |
| tree | 854213e7184d8c3412acc3eb0a0e55842c3dd2c1 /sys/dev | |
| parent | 16bdc3ff0f1a0d01636b585b0ad7fa94b0bc2ff6 (diff) | |
Forgot that the firmware may change the power state behind our back,
so actively query the state when the sysctl(8) is invoked.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/acpi/acpi_power.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/dev/acpi/acpi_power.c b/sys/dev/acpi/acpi_power.c index 950e754c6d0..300ee49672f 100644 --- a/sys/dev/acpi/acpi_power.c +++ b/sys/dev/acpi/acpi_power.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_power.c,v 1.4 2010/04/23 18:51:31 jruoho Exp $ */ +/* $NetBSD: acpi_power.c,v 1.5 2010/04/23 19:00:58 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.4 2010/04/23 18:51:31 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.5 2010/04/23 19:00:58 jruoho Exp $"); #include <sys/param.h> #include <sys/kmem.h> @@ -758,7 +758,7 @@ acpi_power_add(struct acpi_devnode *ad) */ err = sysctl_createv(NULL, 0, &anode, NULL, CTLFLAG_READONLY, CTLTYPE_STRING, ad->ad_name, - NULL, acpi_power_sysctl, 0, &ad->ad_state, 0, + NULL, acpi_power_sysctl, 0, ad, 0, CTL_CREATE, CTL_EOL); if (err != 0) @@ -769,12 +769,16 @@ acpi_power_add(struct acpi_devnode *ad) static int acpi_power_sysctl(SYSCTLFN_ARGS) { + struct acpi_devnode *ad; struct sysctlnode node; int err, state; char t[3]; node = *rnode; - state = *(int *)rnode->sysctl_data; + ad = rnode->sysctl_data; + + if (acpi_power_get(ad, &state) != true) + state = 0; (void)memset(t, '\0', sizeof(t)); (void)snprintf(t, sizeof(t), "D%d", state); |
