Change to acpi_{Get,Set}Integer to provide both methods. Convert all

callers to the new API.

Submitted by:	Mark Santcroos <marks@ripe.net>
This commit is contained in:
Nate Lawson 2004-03-03 18:34:42 +00:00
parent db2585fd12
commit c310653ea1
11 changed files with 52 additions and 69 deletions

View File

@ -166,7 +166,7 @@ AcpiOsWritePciConfiguration (
}
/* XXX should use acpivar.h but too many include dependencies */
extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int
extern ACPI_STATUS acpi_GetInteger(ACPI_HANDLE handle, char *path, int
*number);
/*
@ -183,7 +183,7 @@ acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId)
/* Try to get the _BBN object of the root, otherwise assume it is 0 */
bus = 0;
if (root == curr) {
if (ACPI_FAILURE(acpi_EvaluateInteger(root, "_BBN", &bus)) &&
if (ACPI_FAILURE(acpi_GetInteger(root, "_BBN", &bus)) &&
bootverbose)
printf("acpi_bus_number: root bus has no _BBN, assuming 0\n");
return (bus);
@ -200,7 +200,7 @@ acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId)
return (bus);
}
/* Get the parent's slot and function */
if (ACPI_FAILURE(acpi_EvaluateInteger(parent, "_ADR", &adr))) {
if (ACPI_FAILURE(acpi_GetInteger(parent, "_ADR", &adr))) {
printf("acpi_bus_number: can't get _ADR\n");
return (bus);
}
@ -243,7 +243,7 @@ AcpiOsDerivePciId (
/* Try to read _BBN for bus number if we're at the root */
bus = 0;
if (rhandle == chandle) {
if (ACPI_FAILURE(acpi_EvaluateInteger(rhandle, "_BBN", &bus)) &&
if (ACPI_FAILURE(acpi_GetInteger(rhandle, "_BBN", &bus)) &&
bootverbose)
printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n");
}

View File

@ -1358,11 +1358,27 @@ acpi_AllocBuffer(int size)
return (buf);
}
ACPI_STATUS
acpi_SetInteger(ACPI_HANDLE handle, char *path, int number)
{
ACPI_OBJECT arg1;
ACPI_OBJECT_LIST args;
ACPI_ASSERTLOCK;
arg1.Type = ACPI_TYPE_INTEGER;
arg1.Integer.Value = number;
args.Count = 1;
args.Pointer = &arg1;
return (AcpiEvaluateObject(handle, path, &args, NULL));
}
/*
* Evaluate a path that should return an integer.
*/
ACPI_STATUS
acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
acpi_GetInteger(ACPI_HANDLE handle, char *path, int *number)
{
ACPI_STATUS status;
ACPI_BUFFER buf;
@ -1566,14 +1582,8 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res)
ACPI_STATUS
acpi_SetIntrModel(int model)
{
ACPI_OBJECT_LIST ArgList;
ACPI_OBJECT Arg;
Arg.Type = ACPI_TYPE_INTEGER;
Arg.Integer.Value = model;
ArgList.Count = 1;
ArgList.Pointer = &Arg;
return (AcpiEvaluateObject(ACPI_ROOT_OBJECT, "_PIC", &ArgList, NULL));
return (acpi_SetInteger(ACPI_ROOT_OBJECT, "_PIC", model));
}
#define ACPI_MINIMUM_AWAKETIME 5
@ -1927,21 +1937,12 @@ acpi_disabled(char *subsys)
void
acpi_device_enable_wake_capability(ACPI_HANDLE h, int enable)
{
ACPI_OBJECT_LIST ArgList;
ACPI_OBJECT Arg;
/*
* TBD: All Power Resources referenced by elements 2 through N
* of the _PRW object are put into the ON state.
*/
ArgList.Count = 1;
ArgList.Pointer = &Arg;
Arg.Type = ACPI_TYPE_INTEGER;
Arg.Integer.Value = enable;
(void)AcpiEvaluateObject(h, "_PSW", &ArgList, NULL);
(void)acpi_SetInteger(h, "_PSW", enable);
}
void

View File

@ -95,7 +95,7 @@ acpi_acad_get_status(void *context)
dev = context;
sc = device_get_softc(dev);
h = acpi_get_handle(dev);
if (ACPI_FAILURE(acpi_EvaluateInteger(h, "_PSR", &newstatus))) {
if (ACPI_FAILURE(acpi_GetInteger(h, "_PSR", &newstatus))) {
sc->status = -1;
return;
}

View File

@ -449,10 +449,10 @@ acpi_ec_probe(device_t dev)
* global lock value to see if we should acquire it when
* accessing the EC.
*/
status = acpi_EvaluateInteger(h, "_UID", &uid);
status = acpi_GetInteger(h, "_UID", &uid);
if (ACPI_FAILURE(status))
uid = 0;
status = acpi_EvaluateInteger(h, "_GLK", &glk);
status = acpi_GetInteger(h, "_GLK", &glk);
if (ACPI_FAILURE(status))
glk = 0;
@ -461,7 +461,7 @@ acpi_ec_probe(device_t dev)
* signal status (SCI). Note that we don't handle the case where
* it can return a package instead of an int.
*/
status = acpi_EvaluateInteger(h, "_GPE", &gpebit);
status = acpi_GetInteger(h, "_GPE", &gpebit);
if (ACPI_FAILURE(status)) {
device_printf(dev, "can't evaluate _GPE - %s\n",
AcpiFormatException(status));

View File

@ -139,7 +139,7 @@ acpi_lid_notify_status_changed(void *arg)
* Zero: The lid is closed
* Non-zero: The lid is open
*/
status = acpi_EvaluateInteger(sc->lid_handle, "_LID", &sc->lid_status);
status = acpi_GetInteger(sc->lid_handle, "_LID", &sc->lid_status);
if (ACPI_FAILURE(status))
return_VOID;

View File

@ -170,7 +170,7 @@ acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level, void *context,
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
if (ACPI_FAILURE(acpi_EvaluateInteger(handle, "_ADR", &address)))
if (ACPI_FAILURE(acpi_GetInteger(handle, "_ADR", &address)))
return_ACPI_STATUS(AE_OK);
slot = address >> 16;
func = address & 0xffff;

View File

@ -158,7 +158,7 @@ acpi_pcib_acpi_attach(device_t dev)
* if _BBN is zero and pcib0 already exists, we try to read our
* bus number from the configuration registers at address _ADR.
*/
status = acpi_EvaluateInteger(sc->ap_handle, "_BBN", &sc->ap_bus);
status = acpi_GetInteger(sc->ap_handle, "_BBN", &sc->ap_bus);
if (ACPI_FAILURE(status)) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _BBN - %s\n",
@ -177,7 +177,7 @@ acpi_pcib_acpi_attach(device_t dev)
busok = 1;
if (sc->ap_bus == 0 && devclass_get_device(pcib_devclass, 0) != dev) {
busok = 0;
status = acpi_EvaluateInteger(sc->ap_handle, "_ADR", &addr);
status = acpi_GetInteger(sc->ap_handle, "_ADR", &addr);
if (ACPI_FAILURE(status)) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _ADR - %s\n",
@ -216,7 +216,7 @@ acpi_pcib_acpi_attach(device_t dev)
* Get our segment number by evaluating _SEG
* It's OK for this to not exist.
*/
if (ACPI_FAILURE(status = acpi_EvaluateInteger(sc->ap_handle, "_SEG", &sc->ap_segment))) {
if (ACPI_FAILURE(status = acpi_GetInteger(sc->ap_handle, "_SEG", &sc->ap_segment))) {
if (status != AE_NOT_FOUND) {
device_printf(dev, "could not evaluate _SEG - %s\n", AcpiFormatException(status));
return_VALUE(ENXIO);

View File

@ -572,7 +572,7 @@ acpi_pwr_switch_power(void)
}
/* We could cache this if we trusted it not to change under us */
status = acpi_EvaluateInteger(rp->ap_resource, "_STA", &cur);
status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
acpi_name(rp->ap_resource), status));
@ -615,7 +615,7 @@ acpi_pwr_switch_power(void)
}
/* We could cache this if we trusted it not to change under us */
status = acpi_EvaluateInteger(rp->ap_resource, "_STA", &cur);
status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
acpi_name(rp->ap_resource), status));

View File

@ -404,7 +404,7 @@ acpi_tz_monitor(void *Context)
sc->tz_tmp_updating = 1;
/* Get the current temperature. */
status = acpi_EvaluateInteger(sc->tz_handle, "_TMP", &temp);
status = acpi_GetInteger(sc->tz_handle, "_TMP", &temp);
if (ACPI_FAILURE(status)) {
ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
"error fetching current temperature -- %s\n",
@ -661,7 +661,7 @@ acpi_tz_getparam(struct acpi_tz_softc *sc, char *node, int *data)
ACPI_ASSERTLOCK;
if (ACPI_FAILURE(acpi_EvaluateInteger(sc->tz_handle, node, data))) {
if (ACPI_FAILURE(acpi_GetInteger(sc->tz_handle, node, data))) {
*data = -1;
} else {
ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "%s.%s = %d\n",
@ -783,8 +783,6 @@ acpi_tz_timeout(struct acpi_tz_softc *sc)
static void
acpi_tz_power_profile(void *arg)
{
ACPI_OBJECT_LIST args;
ACPI_OBJECT obj;
ACPI_STATUS status;
struct acpi_tz_softc *sc = (struct acpi_tz_softc *)arg;
int state;
@ -800,11 +798,8 @@ acpi_tz_power_profile(void *arg)
if ((sc->tz_flags & TZ_FLAG_NO_SCP) == 0) {
/* Call _SCP to set the new profile */
obj.Type = ACPI_TYPE_INTEGER;
obj.Integer.Value = (state == POWER_PROFILE_PERFORMANCE) ? 0 : 1;
args.Count = 1;
args.Pointer = &obj;
status = AcpiEvaluateObject(sc->tz_handle, "_SCP", &args, NULL);
status = acpi_SetInteger(sc->tz_handle, "_SCP",
(state == POWER_PROFILE_PERFORMANCE) ? 0 : 1);
if (ACPI_FAILURE(status)) {
if (status != AE_NOT_FOUND)
ACPI_VPRINT(sc->tz_dev,

View File

@ -729,15 +729,10 @@ static void
vid_set_switch_policy(ACPI_HANDLE handle, UINT32 policy)
{
ACPI_STATUS status;
ACPI_OBJECT_LIST args;
ACPI_OBJECT arg1;
ACPI_ASSERTLOCK;
arg1.Type = ACPI_TYPE_INTEGER;
arg1.Integer.Value = policy;
args.Count = 1;
args.Pointer = &arg1;
status = AcpiEvaluateObject(handle, "_DOS", &args, NULL);
status = acpi_SetInteger(handle, "_DOS", policy);
if (ACPI_FAILURE(status))
printf("can't evaluate %s._DOS - %s\n",
acpi_name(handle), AcpiFormatException(status));
@ -760,7 +755,7 @@ vid_enum_outputs_subr(ACPI_HANDLE handle, UINT32 level __unused,
size_t i;
argset = context;
status = acpi_EvaluateInteger(handle, "_ADR", &adr);
status = acpi_GetInteger(handle, "_ADR", &adr);
if (ACPI_SUCCESS(status)) {
for (i = 0; i < argset->dod_pkg->Package.Count; i++) {
tmp = &argset->dod_pkg->Package.Elements[i];
@ -883,15 +878,10 @@ static void
vo_set_brightness(ACPI_HANDLE handle, int level)
{
ACPI_STATUS status;
ACPI_OBJECT_LIST args;
ACPI_OBJECT arg1;
ACPI_ASSERTLOCK;
arg1.Type = ACPI_TYPE_INTEGER;
arg1.Integer.Value = level;
args.Count = 1;
args.Pointer = &arg1;
status = AcpiEvaluateObject(handle, "_BCM", &args, NULL);
status = acpi_SetInteger(handle, "_BCM", level);
if (ACPI_FAILURE(status))
printf("can't evaluate %s._BCM - %s\n",
acpi_name(handle), AcpiFormatException(status));
@ -904,7 +894,7 @@ vo_get_device_status(ACPI_HANDLE handle)
ACPI_STATUS status;
ACPI_ASSERTLOCK;
status = acpi_EvaluateInteger(handle, "_DCS", &dcs);
status = acpi_GetInteger(handle, "_DCS", &dcs);
if (ACPI_FAILURE(status))
printf("can't evaluate %s._DCS - %s\n",
acpi_name(handle), AcpiFormatException(status));
@ -919,7 +909,7 @@ vo_query_graphics_state(ACPI_HANDLE handle)
ACPI_STATUS status;
ACPI_ASSERTLOCK;
status = acpi_EvaluateInteger(handle, "_DGS", &dgs);
status = acpi_GetInteger(handle, "_DGS", &dgs);
if (ACPI_FAILURE(status))
printf("can't evaluate %s._DGS - %s\n",
acpi_name(handle), AcpiFormatException(status));
@ -931,15 +921,10 @@ static void
vo_set_device_state(ACPI_HANDLE handle, UINT32 state)
{
ACPI_STATUS status;
ACPI_OBJECT_LIST args;
ACPI_OBJECT arg1;
ACPI_ASSERTLOCK;
arg1.Type = ACPI_TYPE_INTEGER;
arg1.Integer.Value = state;
args.Count = 1;
args.Pointer = &arg1;
status = AcpiEvaluateObject(handle, "_DSS", &args, NULL);
status = acpi_SetInteger(handle, "_DSS", state);
if (ACPI_FAILURE(status))
printf("can't evaluate %s._DSS - %s\n",
acpi_name(handle), AcpiFormatException(status));

View File

@ -175,10 +175,12 @@ extern BOOLEAN acpi_MatchHid(device_t dev, char *hid);
extern ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,
ACPI_HANDLE *result);
extern ACPI_BUFFER *acpi_AllocBuffer(int size);
extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path,
int *number);
extern ACPI_STATUS acpi_ConvertBufferToInteger(ACPI_BUFFER *bufp,
int *number);
int *number);
extern ACPI_STATUS acpi_GetInteger(ACPI_HANDLE handle, char *path,
int *number);
extern ACPI_STATUS acpi_SetInteger(ACPI_HANDLE handle, char *path,
int number);
extern ACPI_STATUS acpi_ForeachPackageObject(ACPI_OBJECT *obj,
void (*func)(ACPI_OBJECT *comp, void *arg),
void *arg);