ACPI: thinkpad-acpi: add mutex-based locking to input device event send path
Protect the input device event sending path with a mutex, since hot key input events are not atomic and require an cohesive event block to be sent together. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
committed by
Len Brown
parent
f4e1e43c60
commit
8523ed6fb2
@@ -519,6 +519,7 @@ static char *next_cmd(char **cmds)
|
|||||||
static struct platform_device *tpacpi_pdev;
|
static struct platform_device *tpacpi_pdev;
|
||||||
static struct class_device *tpacpi_hwmon;
|
static struct class_device *tpacpi_hwmon;
|
||||||
static struct input_dev *tpacpi_inputdev;
|
static struct input_dev *tpacpi_inputdev;
|
||||||
|
static struct mutex tpacpi_inputdev_send_mutex;
|
||||||
|
|
||||||
|
|
||||||
static int tpacpi_resume_handler(struct platform_device *pdev)
|
static int tpacpi_resume_handler(struct platform_device *pdev)
|
||||||
@@ -1131,6 +1132,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
|
|||||||
unsigned int keycode)
|
unsigned int keycode)
|
||||||
{
|
{
|
||||||
if (keycode != KEY_RESERVED) {
|
if (keycode != KEY_RESERVED) {
|
||||||
|
mutex_lock(&tpacpi_inputdev_send_mutex);
|
||||||
|
|
||||||
input_report_key(tpacpi_inputdev, keycode, 1);
|
input_report_key(tpacpi_inputdev, keycode, 1);
|
||||||
if (keycode == KEY_UNKNOWN)
|
if (keycode == KEY_UNKNOWN)
|
||||||
input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
|
input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
|
||||||
@@ -1142,6 +1145,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
|
|||||||
input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
|
input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
|
||||||
scancode);
|
scancode);
|
||||||
input_sync(tpacpi_inputdev);
|
input_sync(tpacpi_inputdev);
|
||||||
|
|
||||||
|
mutex_unlock(&tpacpi_inputdev_send_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1149,11 +1154,15 @@ static void tpacpi_input_send_radiosw(void)
|
|||||||
{
|
{
|
||||||
int wlsw;
|
int wlsw;
|
||||||
|
|
||||||
|
mutex_lock(&tpacpi_inputdev_send_mutex);
|
||||||
|
|
||||||
if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
|
if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
|
||||||
input_report_switch(tpacpi_inputdev,
|
input_report_switch(tpacpi_inputdev,
|
||||||
SW_RADIO, !!wlsw);
|
SW_RADIO, !!wlsw);
|
||||||
input_sync(tpacpi_inputdev);
|
input_sync(tpacpi_inputdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&tpacpi_inputdev_send_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hotkey_notify(struct ibm_struct *ibm, u32 event)
|
static void hotkey_notify(struct ibm_struct *ibm, u32 event)
|
||||||
@@ -4737,6 +4746,7 @@ static int __init thinkpad_acpi_module_init(void)
|
|||||||
thinkpad_acpi_module_exit();
|
thinkpad_acpi_module_exit();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
mutex_init(&tpacpi_inputdev_send_mutex);
|
||||||
tpacpi_inputdev = input_allocate_device();
|
tpacpi_inputdev = input_allocate_device();
|
||||||
if (!tpacpi_inputdev) {
|
if (!tpacpi_inputdev) {
|
||||||
printk(IBM_ERR "unable to allocate input device\n");
|
printk(IBM_ERR "unable to allocate input device\n");
|
||||||
|
Reference in New Issue
Block a user