thinkpad-acpi: fix poll thread auto-start

The driver was not starting the NVRAM polling thread if the input
device was bound immediately after registration.

This fixes:
http://bugzilla.kernel.org/show_bug.cgi?id=15118Reported-by: default avatarFlorian Zumbiehl <florz@florz.de>
Signed-off-by: default avatarHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
parent 7d1894d8
...@@ -2607,16 +2607,11 @@ static int hotkey_inputdev_open(struct input_dev *dev) ...@@ -2607,16 +2607,11 @@ static int hotkey_inputdev_open(struct input_dev *dev)
{ {
switch (tpacpi_lifecycle) { switch (tpacpi_lifecycle) {
case TPACPI_LIFE_INIT: case TPACPI_LIFE_INIT:
/*
* hotkey_init will call hotkey_poll_setup_safe
* at the appropriate moment
*/
return 0;
case TPACPI_LIFE_EXITING:
return -EBUSY;
case TPACPI_LIFE_RUNNING: case TPACPI_LIFE_RUNNING:
hotkey_poll_setup_safe(false); hotkey_poll_setup_safe(false);
return 0; return 0;
case TPACPI_LIFE_EXITING:
return -EBUSY;
} }
/* Should only happen if tpacpi_lifecycle is corrupt */ /* Should only happen if tpacpi_lifecycle is corrupt */
...@@ -2627,7 +2622,7 @@ static int hotkey_inputdev_open(struct input_dev *dev) ...@@ -2627,7 +2622,7 @@ static int hotkey_inputdev_open(struct input_dev *dev)
static void hotkey_inputdev_close(struct input_dev *dev) static void hotkey_inputdev_close(struct input_dev *dev)
{ {
/* disable hotkey polling when possible */ /* disable hotkey polling when possible */
if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING && if (tpacpi_lifecycle != TPACPI_LIFE_EXITING &&
!(hotkey_source_mask & hotkey_driver_mask)) !(hotkey_source_mask & hotkey_driver_mask))
hotkey_poll_setup_safe(false); hotkey_poll_setup_safe(false);
} }
...@@ -9038,6 +9033,9 @@ static int __init thinkpad_acpi_module_init(void) ...@@ -9038,6 +9033,9 @@ static int __init thinkpad_acpi_module_init(void)
return ret; return ret;
} }
} }
tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
ret = input_register_device(tpacpi_inputdev); ret = input_register_device(tpacpi_inputdev);
if (ret < 0) { if (ret < 0) {
printk(TPACPI_ERR "unable to register input device\n"); printk(TPACPI_ERR "unable to register input device\n");
...@@ -9047,7 +9045,6 @@ static int __init thinkpad_acpi_module_init(void) ...@@ -9047,7 +9045,6 @@ static int __init thinkpad_acpi_module_init(void)
tp_features.input_device_registered = 1; tp_features.input_device_registered = 1;
} }
tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment