0f13485166c5f63dd3a3fd168cf05b7f6117d2c1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.24-rc1 / 0006-ACPI-thinkpad-acpi-add-mutex-based-locking-to-inpu.patch
blob0f13485166c5f63dd3a3fd168cf05b7f6117d2c1
1 From 8523ed6fb2ca04973fe759fda8ab4af72492fc7e 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:01 -0300
4 Subject: [PATCH 06/23] ACPI: thinkpad-acpi: add mutex-based locking to input device event send path
6 Protect the input device event sending path with a mutex, since hot key
7 input events are not atomic and require an cohesive event block to be sent
8 together.
10 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
11 Signed-off-by: Len Brown <len.brown@intel.com>
12 ---
13 drivers/misc/thinkpad_acpi.c | 10 ++++++++++
14 1 files changed, 10 insertions(+), 0 deletions(-)
16 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
17 index 8aa0f96..0ced9d6 100644
18 --- a/drivers/misc/thinkpad_acpi.c
19 +++ b/drivers/misc/thinkpad_acpi.c
20 @@ -519,6 +519,7 @@ static char *next_cmd(char **cmds)
21 static struct platform_device *tpacpi_pdev;
22 static struct class_device *tpacpi_hwmon;
23 static struct input_dev *tpacpi_inputdev;
24 +static struct mutex tpacpi_inputdev_send_mutex;
27 static int tpacpi_resume_handler(struct platform_device *pdev)
28 @@ -1131,6 +1132,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
29 unsigned int keycode)
31 if (keycode != KEY_RESERVED) {
32 + mutex_lock(&tpacpi_inputdev_send_mutex);
34 input_report_key(tpacpi_inputdev, keycode, 1);
35 if (keycode == KEY_UNKNOWN)
36 input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
37 @@ -1142,6 +1145,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
38 input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
39 scancode);
40 input_sync(tpacpi_inputdev);
42 + mutex_unlock(&tpacpi_inputdev_send_mutex);
46 @@ -1149,11 +1154,15 @@ static void tpacpi_input_send_radiosw(void)
48 int wlsw;
50 + mutex_lock(&tpacpi_inputdev_send_mutex);
52 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
53 input_report_switch(tpacpi_inputdev,
54 SW_RADIO, !!wlsw);
55 input_sync(tpacpi_inputdev);
58 + mutex_unlock(&tpacpi_inputdev_send_mutex);
61 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
62 @@ -4737,6 +4746,7 @@ static int __init thinkpad_acpi_module_init(void)
63 thinkpad_acpi_module_exit();
64 return ret;
66 + mutex_init(&tpacpi_inputdev_send_mutex);
67 tpacpi_inputdev = input_allocate_device();
68 if (!tpacpi_inputdev) {
69 printk(IBM_ERR "unable to allocate input device\n");
70 --
71 1.5.3.4