Commit 751ae808 authored by Thomas Renninger's avatar Thomas Renninger Committed by Matthew Garrett

x86 platform drivers: hp-wmi Reorder event id processing

Event id 0x4 defines the hotkey event.
No need (or even wrong) to query HPWMI_HOTKEY_QUERY if event id is != 0x4.

Reorder the eventcode conditionals and use switch case instead of if/else.
Use an enum for the event ids cases.
Signed-off-by: default avatarThomas Renninger <trenn@suse.de>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
CC: linux-acpi@vger.kernel.org
CC: platform-driver-x86@vger.kernel.org
parent 4b30fbca
...@@ -58,6 +58,12 @@ enum hp_wmi_radio { ...@@ -58,6 +58,12 @@ enum hp_wmi_radio {
HPWMI_WWAN = 2, HPWMI_WWAN = 2,
}; };
enum hp_wmi_event_ids {
HPWMI_DOCK_EVENT = 1,
HPWMI_BEZEL_BUTTON = 4,
HPWMI_WIRELESS = 5,
};
static int __devinit hp_wmi_bios_setup(struct platform_device *device); static int __devinit hp_wmi_bios_setup(struct platform_device *device);
static int __exit hp_wmi_bios_remove(struct platform_device *device); static int __exit hp_wmi_bios_remove(struct platform_device *device);
static int hp_wmi_resume_handler(struct device *device); static int hp_wmi_resume_handler(struct device *device);
...@@ -338,7 +344,7 @@ static void hp_wmi_notify(u32 value, void *context) ...@@ -338,7 +344,7 @@ static void hp_wmi_notify(u32 value, void *context)
struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
static struct key_entry *key; static struct key_entry *key;
union acpi_object *obj; union acpi_object *obj;
int eventcode; int eventcode, key_code;
acpi_status status; acpi_status status;
status = wmi_get_event_data(value, &response); status = wmi_get_event_data(value, &response);
...@@ -357,10 +363,18 @@ static void hp_wmi_notify(u32 value, void *context) ...@@ -357,10 +363,18 @@ static void hp_wmi_notify(u32 value, void *context)
eventcode = *((u8 *) obj->buffer.pointer); eventcode = *((u8 *) obj->buffer.pointer);
kfree(obj); kfree(obj);
if (eventcode == 0x4) switch (eventcode) {
eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0, case HPWMI_DOCK_EVENT:
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);
break;
case HPWMI_BEZEL_BUTTON:
key_code = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
0); 0);
key = hp_wmi_get_entry_by_scancode(eventcode); key = hp_wmi_get_entry_by_scancode(key_code);
if (key) { if (key) {
switch (key->type) { switch (key->type) {
case KE_KEY: case KE_KEY:
...@@ -372,13 +386,9 @@ static void hp_wmi_notify(u32 value, void *context) ...@@ -372,13 +386,9 @@ static void hp_wmi_notify(u32 value, void *context)
input_sync(hp_wmi_input_dev); input_sync(hp_wmi_input_dev);
break; break;
} }
} else if (eventcode == 0x1) { }
input_report_switch(hp_wmi_input_dev, SW_DOCK, break;
hp_wmi_dock_state()); case HPWMI_WIRELESS:
input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
hp_wmi_tablet_state());
input_sync(hp_wmi_input_dev);
} else if (eventcode == 0x5) {
if (wifi_rfkill) if (wifi_rfkill)
rfkill_set_states(wifi_rfkill, rfkill_set_states(wifi_rfkill,
hp_wmi_get_sw_state(HPWMI_WIFI), hp_wmi_get_sw_state(HPWMI_WIFI),
...@@ -391,9 +401,12 @@ static void hp_wmi_notify(u32 value, void *context) ...@@ -391,9 +401,12 @@ static void hp_wmi_notify(u32 value, void *context)
rfkill_set_states(wwan_rfkill, rfkill_set_states(wwan_rfkill,
hp_wmi_get_sw_state(HPWMI_WWAN), hp_wmi_get_sw_state(HPWMI_WWAN),
hp_wmi_get_hw_state(HPWMI_WWAN)); hp_wmi_get_hw_state(HPWMI_WWAN));
} else break;
default:
printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
eventcode); eventcode);
break;
}
} }
static int __init hp_wmi_input_setup(void) static int __init hp_wmi_input_setup(void)
......
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