Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288956
b: refs/heads/master
c: 2ac1696
h: refs/heads/master
v: v3
  • Loading branch information
Szymon Janc authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent df33cf2 commit 30f1c9d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1692caa949728d866238020fe2214bd48f825d62
refs/heads/master: 2ac16967b8de55ec1cfb596717b3a68b0d5b42f7
38 changes: 26 additions & 12 deletions trunk/drivers/staging/quickstart/quickstart.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,39 +191,53 @@ static void quickstart_acpi_notify(acpi_handle handle, u32 event, void *data)
return;
}

static void quickstart_acpi_ghid(struct quickstart_acpi *quickstart)
static int quickstart_acpi_ghid(struct quickstart_acpi *quickstart)
{
acpi_status status;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
uint32_t usageid = 0;

if (!quickstart)
return;
int ret = 0;

/*
* This returns a buffer telling the button usage ID,
* and triggers pending notify events (The ones before booting).
*/
status = acpi_evaluate_object(quickstart->device->handle, "GHID", NULL,
&buffer);
if (ACPI_FAILURE(status) || !buffer.pointer) {
if (ACPI_FAILURE(status)) {
printk(KERN_ERR "quickstart: %s GHID method failed.\n",
quickstart->btn->name);
return;
return -EINVAL;
}

if (buffer.length < 8)
return;

/*
* <<The GHID method can return a BYTE, WORD, or DWORD.
* The value must be encoded in little-endian byte
* order (least significant byte first).>>
*/
usageid = *((uint32_t *)(buffer.pointer + (buffer.length - 8)));
quickstart->btn->id = usageid;
switch (buffer.length) {
case 1:
quickstart->btn->id = *(uint8_t *)buffer.pointer;
break;
case 2:
quickstart->btn->id = *(uint16_t *)buffer.pointer;
break;
case 4:
quickstart->btn->id = *(uint32_t *)buffer.pointer;
break;
case 8:
quickstart->btn->id = *(uint64_t *)buffer.pointer;
break;
default:
printk(KERN_ERR "quickstart: %s GHID method returned buffer "
"of unexpected length %u\n",
quickstart->btn->name, buffer.length);
ret = -EINVAL;
break;
}

kfree(buffer.pointer);

return ret;
}

static int quickstart_acpi_config(struct quickstart_acpi *quickstart, char *bid)
Expand Down

0 comments on commit 30f1c9d

Please sign in to comment.