From cce4ffd2f7a9f0d1f2f25ea227240b081ad6ca4a Mon Sep 17 00:00:00 2001 From: Lekensteyn Date: Wed, 14 Dec 2011 19:20:58 +0100 Subject: [PATCH] bbswitch: fix more return values and document acpi_call_dsm --- bbswitch.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bbswitch.c b/bbswitch.c index 017d1c7..56d47cd 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -64,6 +64,9 @@ static char *buffer_to_string(const char buffer[], char *target) { return target; } +// Returns 0 if the call succeeded and non-zero otherwise. If the call +// succeeded, the result is stored in "result" providing that the result is an +// integer or a buffer containing 4 values static int acpi_call_dsm(acpi_handle handle, const char muid[16], int revid, int func, char *args, uint32_t *result) { struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -128,7 +131,7 @@ static int has_dsm_func(const char muid[16], int revid, int sfnc) { u32 result = 0; // fail if the _DSM call failed - if (!acpi_call_dsm(dis_handle, muid, revid, 0, 0, &result)) + if (acpi_call_dsm(dis_handle, muid, revid, 0, 0, &result)) return 0; // ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. If @@ -155,7 +158,7 @@ static int bbswitch_acpi_off(void) { char args[] = {2, 0, 0, 0}; u32 result = 0; - if (acpi_call_dsm(dis_handle, acpi_nvidia_dsm_muid, 0x102, 0x3, args, + if (!acpi_call_dsm(dis_handle, acpi_nvidia_dsm_muid, 0x102, 0x3, args, &result)) { // failure return 1; @@ -171,7 +174,7 @@ static int bbswitch_acpi_on(void) { char args[] = {1, 0, 0, 0}; u32 result = 0; - if (acpi_call_dsm(dis_handle, acpi_nvidia_dsm_muid, 0x102, 0x3, args, + if (!acpi_call_dsm(dis_handle, acpi_nvidia_dsm_muid, 0x102, 0x3, args, &result)) { // failure return 1;