Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Introduce acpi_eval_set_integer().
details: https://anonhg.NetBSD.org/src/rev/b334c1813017
branches: trunk
changeset: 749434:b334c1813017
user: cegger <cegger%NetBSD.org@localhost>
date: Sun Nov 29 21:32:50 2009 +0000
description:
Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html
No comments.
XXX Is there an acpi(9) manpage?
diffstat:
sys/dev/acpi/acpi.c | 22 ++++++++++++++++++++--
sys/dev/acpi/acpi_lid.c | 16 ++++------------
sys/dev/acpi/acpivar.h | 4 +++-
sys/dev/acpi/thinkpad_acpi.c | 19 +++++--------------
sys/dev/acpi/wmi_acpi.c | 14 +++-----------
5 files changed, 35 insertions(+), 40 deletions(-)
diffs (200 lines):
diff -r 6c51ddcc15b4 -r b334c1813017 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c Sun Nov 29 20:56:01 2009 +0000
+++ b/sys/dev/acpi/acpi.c Sun Nov 29 21:32:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.135 2009/11/28 17:03:17 cegger Exp $ */
+/* $NetBSD: acpi.c,v 1.136 2009/11/29 21:32:50 cegger Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.135 2009/11/28 17:03:17 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.136 2009/11/29 21:32:50 cegger Exp $");
#include "opt_acpi.h"
#include "opt_pcifixup.h"
@@ -1171,6 +1171,24 @@
return rv;
}
+ACPI_STATUS
+acpi_eval_set_integer(ACPI_HANDLE handle, const char *path, ACPI_INTEGER arg)
+{
+ ACPI_OBJECT param_arg;
+ ACPI_OBJECT_LIST param_args;
+
+ if (handle == NULL)
+ handle = ACPI_ROOT_OBJECT;
+
+ param_arg.Type = ACPI_TYPE_INTEGER;
+ param_arg.Integer.Value = arg;
+
+ param_args.Count = 1;
+ param_args.Pointer = ¶m_arg;
+
+ return AcpiEvaluateObject(handle, path, ¶m_args, NULL);
+}
+
/*
* acpi_eval_string:
*
diff -r 6c51ddcc15b4 -r b334c1813017 sys/dev/acpi/acpi_lid.c
--- a/sys/dev/acpi/acpi_lid.c Sun Nov 29 20:56:01 2009 +0000
+++ b/sys/dev/acpi/acpi_lid.c Sun Nov 29 21:32:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_lid.c,v 1.28 2009/08/25 10:34:08 jmcneill Exp $ */
+/* $NetBSD: acpi_lid.c,v 1.29 2009/11/29 21:32:50 cegger Exp $ */
/*
* Copyright 2001, 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_lid.c,v 1.28 2009/08/25 10:34:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_lid.c,v 1.29 2009/11/29 21:32:50 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -155,17 +155,9 @@
struct acpilid_softc *sc = device_private(dv);
ACPI_STATUS rv;
- ACPI_OBJECT_LIST ArgList;
- ACPI_OBJECT Arg;
- ArgList.Count = 1;
- ArgList.Pointer = &Arg;
-
- Arg.Type = ACPI_TYPE_INTEGER;
- Arg.Integer.Value = enable ? 1 : 0;
-
- rv = AcpiEvaluateObject(sc->sc_node->ad_handle, "_PSW",
- &ArgList, NULL);
+ rv = acpi_eval_set_integer(sc->sc_node->ad_handle, "_PSW",
+ enable ? 1 : 0);
if (ACPI_FAILURE(rv) && rv != AE_NOT_FOUND)
aprint_error_dev(dv,
"unable to evaluate _PSW handler: %s\n",
diff -r 6c51ddcc15b4 -r b334c1813017 sys/dev/acpi/acpivar.h
--- a/sys/dev/acpi/acpivar.h Sun Nov 29 20:56:01 2009 +0000
+++ b/sys/dev/acpi/acpivar.h Sun Nov 29 21:32:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpivar.h,v 1.37 2009/11/28 17:02:14 cegger Exp $ */
+/* $NetBSD: acpivar.h,v 1.38 2009/11/29 21:32:50 cegger Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -267,6 +267,8 @@
void acpi_clear_wake_gpe(ACPI_HANDLE);
ACPI_STATUS acpi_eval_integer(ACPI_HANDLE, const char *, ACPI_INTEGER *);
+ACPI_STATUS acpi_eval_set_integer(ACPI_HANDLE handle, const char *path,
+ ACPI_INTEGER arg);
ACPI_STATUS acpi_eval_string(ACPI_HANDLE, const char *, char **);
ACPI_STATUS acpi_eval_struct(ACPI_HANDLE, const char *, ACPI_BUFFER *);
diff -r 6c51ddcc15b4 -r b334c1813017 sys/dev/acpi/thinkpad_acpi.c
--- a/sys/dev/acpi/thinkpad_acpi.c Sun Nov 29 20:56:01 2009 +0000
+++ b/sys/dev/acpi/thinkpad_acpi.c Sun Nov 29 21:32:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thinkpad_acpi.c,v 1.20 2009/09/25 20:26:26 dyoung Exp $ */
+/* $NetBSD: thinkpad_acpi.c,v 1.21 2009/11/29 21:32:50 cegger Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.20 2009/09/25 20:26:26 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.21 2009/11/29 21:32:50 cegger Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -419,9 +419,7 @@
}
/* Enable hotkey events */
- params.Count = 1;
- param[0].Integer.Value = 1;
- rv = AcpiEvaluateObject(sc->sc_node->ad_handle, "MHKC", ¶ms, NULL);
+ rv = acpi_eval_set_integer(sc->sc_node->ad_handle, "MHKC", 1);
if (ACPI_FAILURE(rv)) {
aprint_error_dev(sc->sc_dev, "couldn't enable hotkeys: %s\n",
AcpiFormatException(rv));
@@ -429,8 +427,7 @@
}
/* Claim ownership of brightness control */
- param[0].Integer.Value = 0;
- (void)AcpiEvaluateObject(sc->sc_node->ad_handle, "PWMS", ¶ms, NULL);
+ (void)acpi_eval_set_integer(sc->sc_node->ad_handle, "PWMS", 0);
return AE_OK;
}
@@ -601,18 +598,12 @@
static void
thinkpad_cmos(thinkpad_softc_t *sc, uint8_t cmd)
{
- ACPI_OBJECT param;
- ACPI_OBJECT_LIST params;
ACPI_STATUS rv;
if (sc->sc_cmoshdl_valid == false)
return;
- params.Count = 1;
- params.Pointer = ¶m;
- param.Type = ACPI_TYPE_INTEGER;
- param.Integer.Value = cmd;
- rv = AcpiEvaluateObject(sc->sc_cmoshdl, NULL, ¶ms, NULL);
+ rv = acpi_eval_set_integer(sc->sc_cmoshdl, NULL, cmd);
if (ACPI_FAILURE(rv))
aprint_error_dev(sc->sc_dev, "couldn't evalute CMOS: %s\n",
AcpiFormatException(rv));
diff -r 6c51ddcc15b4 -r b334c1813017 sys/dev/acpi/wmi_acpi.c
--- a/sys/dev/acpi/wmi_acpi.c Sun Nov 29 20:56:01 2009 +0000
+++ b/sys/dev/acpi/wmi_acpi.c Sun Nov 29 21:32:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wmi_acpi.c,v 1.2 2009/10/03 15:49:21 jmcneill Exp $ */
+/* $NetBSD: wmi_acpi.c,v 1.3 2009/11/29 21:32:50 cegger Exp $ */
/*-
* Copyright (c) 2009 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.2 2009/10/03 15:49:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.3 2009/11/29 21:32:50 cegger Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -541,8 +541,6 @@
acpi_wmi_enable(const ACPI_HANDLE hdl, const char * const oid,
const bool data, const bool flag)
{
- ACPI_OBJECT_LIST arg;
- ACPI_OBJECT obj;
char path[5];
const char *str;
@@ -551,13 +549,7 @@
(void)strlcpy(path, str, sizeof(path));
(void)strlcat(path, oid, sizeof(path));
- obj.Type = ACPI_TYPE_INTEGER;
- obj.Integer.Value = (flag != false) ? 0x01 : 0x00;
-
- arg.Count = 0x01;
- arg.Pointer = &obj;
-
- return AcpiEvaluateObject(hdl, path, &arg, NULL);
+ return acpi_eval_set_integer(hdl, path, (flag != false) ? 0x01 : 0x00);
}
/*
* Makes a WMI data block query (WQxx). The corresponding control
Home |
Main Index |
Thread Index |
Old Index