Add a patch accepted in 2.6.24-rc1 that was forgotten
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.24-rc1 / 0010-ACPI-thinkpad-acpi-dequeue-all-pending-hot-key-eve.patch
blob57441e7a38a2cc0ee89fc878fcb4fefe0cc5bf12
1 From 3eea123df1637a88d0899626a67b83dca959efff Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sun, 23 Sep 2007 11:39:04 -0300
4 Subject: [PATCH 09/23] ACPI: thinkpad-acpi: dequeue all pending hot key events at once (v2.2)
6 Receive all pending HKEY events at once from a single notification, and don't
7 complain if the queue is empty.
9 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
10 Signed-off-by: Len Brown <len.brown@intel.com>
11 ---
12 drivers/misc/thinkpad_acpi.c | 51 ++++++++++++++++++++++++++++--------------
13 1 files changed, 34 insertions(+), 17 deletions(-)
15 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
16 index 9a61140..3efe81b 100644
17 --- a/drivers/misc/thinkpad_acpi.c
18 +++ b/drivers/misc/thinkpad_acpi.c
19 @@ -1196,9 +1196,30 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
21 u32 hkey;
22 unsigned int keycode, scancode;
23 - int send_acpi_ev = 0;
24 + int send_acpi_ev;
26 + if (event != 0x80) {
27 + printk(IBM_ERR "unknown HKEY notification event %d\n", event);
28 + /* forward it to userspace, maybe it knows how to handle it */
29 + acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
30 + ibm->acpi->device->dev.bus_id,
31 + event, 0);
32 + return;
33 + }
35 + while (1) {
36 + if (!acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
37 + printk(IBM_ERR "failed to retrieve HKEY event\n");
38 + return;
39 + }
41 + if (hkey == 0) {
42 + /* queue empty */
43 + return;
44 + }
46 + send_acpi_ev = 0;
48 - if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
49 switch (hkey >> 12) {
50 case 1:
51 /* 0x1000-0x1FFF: key presses */
52 @@ -1220,8 +1241,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
53 * eat up known LID events */
54 if (hkey != 0x5001 && hkey != 0x5002) {
55 printk(IBM_ERR
56 - "unknown LID-related hotkey event: 0x%04x\n",
57 - hkey);
58 + "unknown LID-related HKEY event: 0x%04x\n",
59 + hkey);
60 send_acpi_ev = 1;
62 break;
63 @@ -1240,21 +1261,17 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
64 printk(IBM_NOTICE "unhandled HKEY event 0x%04x\n", hkey);
65 send_acpi_ev = 1;
67 - } else {
68 - printk(IBM_ERR "unknown hotkey notification event %d\n", event);
69 - hkey = 0;
70 - send_acpi_ev = 1;
71 - }
73 - /* Legacy events */
74 - if (send_acpi_ev || hotkey_report_mode < 2)
75 - acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
76 + /* Legacy events */
77 + if (send_acpi_ev || hotkey_report_mode < 2)
78 + acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
80 - /* netlink events */
81 - if (send_acpi_ev) {
82 - acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
83 - ibm->acpi->device->dev.bus_id,
84 - event, hkey);
85 + /* netlink events */
86 + if (send_acpi_ev) {
87 + acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
88 + ibm->acpi->device->dev.bus_id,
89 + event, hkey);
90 + }
94 --
95 1.5.3.4