aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86
diff options
context:
space:
mode:
authorThomas Renninger <trenn@suse.de>2010-05-21 10:18:09 -0400
committerMatthew Garrett <mjg@redhat.com>2010-08-03 09:48:40 -0400
commit751ae808f6b29803228609f51aa1ae057f5c576e (patch)
treecc0906d31b8968c99822061924c5d0d799239b5f /drivers/platform/x86
parent4b30fbca4f64bc70c59867ad5769c37efb587ff4 (diff)
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: Thomas Renninger <trenn@suse.de> Signed-off-by: Matthew Garrett <mjg@redhat.com> CC: linux-acpi@vger.kernel.org CC: platform-driver-x86@vger.kernel.org
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r--drivers/platform/x86/hp-wmi.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 51c07a05a7bc..f1c186245f98 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -58,6 +58,12 @@ enum hp_wmi_radio {
58 HPWMI_WWAN = 2, 58 HPWMI_WWAN = 2,
59}; 59};
60 60
61enum hp_wmi_event_ids {
62 HPWMI_DOCK_EVENT = 1,
63 HPWMI_BEZEL_BUTTON = 4,
64 HPWMI_WIRELESS = 5,
65};
66
61static int __devinit hp_wmi_bios_setup(struct platform_device *device); 67static int __devinit hp_wmi_bios_setup(struct platform_device *device);
62static int __exit hp_wmi_bios_remove(struct platform_device *device); 68static int __exit hp_wmi_bios_remove(struct platform_device *device);
63static int hp_wmi_resume_handler(struct device *device); 69static int hp_wmi_resume_handler(struct device *device);
@@ -338,7 +344,7 @@ static void hp_wmi_notify(u32 value, void *context)
338 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; 344 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
339 static struct key_entry *key; 345 static struct key_entry *key;
340 union acpi_object *obj; 346 union acpi_object *obj;
341 int eventcode; 347 int eventcode, key_code;
342 acpi_status status; 348 acpi_status status;
343 349
344 status = wmi_get_event_data(value, &response); 350 status = wmi_get_event_data(value, &response);
@@ -357,28 +363,32 @@ static void hp_wmi_notify(u32 value, void *context)
357 363
358 eventcode = *((u8 *) obj->buffer.pointer); 364 eventcode = *((u8 *) obj->buffer.pointer);
359 kfree(obj); 365 kfree(obj);
360 if (eventcode == 0x4) 366 switch (eventcode) {
361 eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0, 367 case HPWMI_DOCK_EVENT:
362 0);
363 key = hp_wmi_get_entry_by_scancode(eventcode);
364 if (key) {
365 switch (key->type) {
366 case KE_KEY:
367 input_report_key(hp_wmi_input_dev,
368 key->keycode, 1);
369 input_sync(hp_wmi_input_dev);
370 input_report_key(hp_wmi_input_dev,
371 key->keycode, 0);
372 input_sync(hp_wmi_input_dev);
373 break;
374 }
375 } else if (eventcode == 0x1) {
376 input_report_switch(hp_wmi_input_dev, SW_DOCK, 368 input_report_switch(hp_wmi_input_dev, SW_DOCK,
377 hp_wmi_dock_state()); 369 hp_wmi_dock_state());
378 input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, 370 input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
379 hp_wmi_tablet_state()); 371 hp_wmi_tablet_state());
380 input_sync(hp_wmi_input_dev); 372 input_sync(hp_wmi_input_dev);
381 } else if (eventcode == 0x5) { 373 break;
374 case HPWMI_BEZEL_BUTTON:
375 key_code = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
376 0);
377 key = hp_wmi_get_entry_by_scancode(key_code);
378 if (key) {
379 switch (key->type) {
380 case KE_KEY:
381 input_report_key(hp_wmi_input_dev,
382 key->keycode, 1);
383 input_sync(hp_wmi_input_dev);
384 input_report_key(hp_wmi_input_dev,
385 key->keycode, 0);
386 input_sync(hp_wmi_input_dev);
387 break;
388 }
389 }
390 break;
391 case HPWMI_WIRELESS:
382 if (wifi_rfkill) 392 if (wifi_rfkill)
383 rfkill_set_states(wifi_rfkill, 393 rfkill_set_states(wifi_rfkill,
384 hp_wmi_get_sw_state(HPWMI_WIFI), 394 hp_wmi_get_sw_state(HPWMI_WIFI),
@@ -391,9 +401,12 @@ static void hp_wmi_notify(u32 value, void *context)
391 rfkill_set_states(wwan_rfkill, 401 rfkill_set_states(wwan_rfkill,
392 hp_wmi_get_sw_state(HPWMI_WWAN), 402 hp_wmi_get_sw_state(HPWMI_WWAN),
393 hp_wmi_get_hw_state(HPWMI_WWAN)); 403 hp_wmi_get_hw_state(HPWMI_WWAN));
394 } else 404 break;
405 default:
395 printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", 406 printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
396 eventcode); 407 eventcode);
408 break;
409 }
397} 410}
398 411
399static int __init hp_wmi_input_setup(void) 412static int __init hp_wmi_input_setup(void)