Commit ad69676b authored by Carlo Caione's avatar Carlo Caione Committed by Thadeu Lima de Souza Cascardo

platform/x86: hp-wmi: Fix detection for dock and tablet mode

BugLink: http://bugs.launchpad.net/bugs/1732698

commit 298747b7 upstream.

The current driver code is not checking for the error values returned by
'hp_wmi_dock_state()' and 'hp_wmi_tablet_state()' before passing the
returned values down to 'input_report_switch()'. This error code is
being translated to '1' in the input subsystem, reporting the wrong
status.

The biggest problem caused by this issue is that several laptops are
wrongly reported by the driver as docked, preventing them to be put to
sleep using the LID (and in most cases they are not even dockable).

With this patch we create the report switches only if we are able to
read the dock and tablet mode status correctly from ACPI.
Signed-off-by: default avatarCarlo Caione <carlo@endlessm.com>
Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
Cc: Philip Müller <philm@manjaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
parent d9c0678d
...@@ -573,8 +573,10 @@ static void hp_wmi_notify(u32 value, void *context) ...@@ -573,8 +573,10 @@ static void hp_wmi_notify(u32 value, void *context)
switch (event_id) { switch (event_id) {
case HPWMI_DOCK_EVENT: case HPWMI_DOCK_EVENT:
if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
input_report_switch(hp_wmi_input_dev, SW_DOCK, input_report_switch(hp_wmi_input_dev, SW_DOCK,
hp_wmi_dock_state()); hp_wmi_dock_state());
if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
hp_wmi_tablet_state()); hp_wmi_tablet_state());
input_sync(hp_wmi_input_dev); input_sync(hp_wmi_input_dev);
...@@ -649,6 +651,7 @@ static int __init hp_wmi_input_setup(void) ...@@ -649,6 +651,7 @@ static int __init hp_wmi_input_setup(void)
{ {
acpi_status status; acpi_status status;
int err; int err;
int val;
hp_wmi_input_dev = input_allocate_device(); hp_wmi_input_dev = input_allocate_device();
if (!hp_wmi_input_dev) if (!hp_wmi_input_dev)
...@@ -659,17 +662,26 @@ static int __init hp_wmi_input_setup(void) ...@@ -659,17 +662,26 @@ static int __init hp_wmi_input_setup(void)
hp_wmi_input_dev->id.bustype = BUS_HOST; hp_wmi_input_dev->id.bustype = BUS_HOST;
__set_bit(EV_SW, hp_wmi_input_dev->evbit); __set_bit(EV_SW, hp_wmi_input_dev->evbit);
/* Dock */
val = hp_wmi_dock_state();
if (!(val < 0)) {
__set_bit(SW_DOCK, hp_wmi_input_dev->swbit); __set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
input_report_switch(hp_wmi_input_dev, SW_DOCK, val);
}
/* Tablet mode */
val = hp_wmi_tablet_state();
if (!(val < 0)) {
__set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val);
}
err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL); err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL);
if (err) if (err)
goto err_free_dev; goto err_free_dev;
/* Set initial hardware state */ /* Set initial hardware state */
input_report_switch(hp_wmi_input_dev, SW_DOCK, hp_wmi_dock_state());
input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
hp_wmi_tablet_state());
input_sync(hp_wmi_input_dev); input_sync(hp_wmi_input_dev);
if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later()) if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later())
...@@ -982,8 +994,10 @@ static int hp_wmi_resume_handler(struct device *device) ...@@ -982,8 +994,10 @@ static int hp_wmi_resume_handler(struct device *device)
* changed. * changed.
*/ */
if (hp_wmi_input_dev) { if (hp_wmi_input_dev) {
if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
input_report_switch(hp_wmi_input_dev, SW_DOCK, input_report_switch(hp_wmi_input_dev, SW_DOCK,
hp_wmi_dock_state()); hp_wmi_dock_state());
if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
hp_wmi_tablet_state()); hp_wmi_tablet_state());
input_sync(hp_wmi_input_dev); input_sync(hp_wmi_input_dev);
......
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