misc: Add dell-wmi driver for hotkey control
Subsystems (2)
PATCH 1/1 misc: Add dell-wmi driver for hotkey control
Add a WMI driver for Dell laptops. Currently it does nothing but send a generic input event when a button with a picture of a battery on it is pressed, but maybe other uses will appear over time.
MAINTAINERS +5 -0
@@ -1371,6 +1371,11 @@ P: Doug Warzecha M: [email protected] S: Maintained +DELL WMI EXTRAS DRIVER +P: Matthew Garrett +M: [email protected] +S: Maintained + DEVICE NUMBER REGISTRY P: Torben Mathiasen M: [email protected]
drivers/misc/Kconfig +10 -0
@@ -227,6 +227,16 @@ config HP_WMI To compile this driver as a module, choose M here: the module will be called hp-wmi. +config DELL_WMI + tristate "Dell WMI extras" + depends on ACPI_WMI + depends on INPUT + help + Say Y here if you want to support WMI-based hotkeys on Dell laptops. + + To compile this driver as a module, choose M here: the module will + be called dell-wmi. + config ICS932S401 tristate "Integrated Circuits ICS932S401" depends on I2C && EXPERIMENTAL
drivers/misc/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o obj-$(CONFIG_HP_WMI) += hp-wmi.o +obj-$(CONFIG_DELL_WMI) += dell-wmi.o obj-$(CONFIG_ICS932S401) += ics932s401.o obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o obj-$(CONFIG_LKDTM) += lkdtm.o
drivers/misc/dell-wmi.c new file +198 -0
198 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 3 lines · Matthew Garrett
Add a WMI driver for Dell laptops. Currently it does nothing but send a generic input event when a button with a picture of a battery on it is pressed, but maybe other uses will appear over time.
Some general notes below. I have no knowledge of the input layer, so I can't verify the patch in terms of input layer correctness.
Quoted 2 lines
[...]
+voiddell_wmi_notify(u32 value, void *context)
static
Quoted 12 lines
drivers/misc/dell-wmi.c new file +12
-0+{ +struct acpi_buffer response = {ACPI_ALLOCATE_BUFFER ,NULL }; +static struct key_entry *key; +union acpi_object *obj; + +wmi_get_event_data (value, &response); + + obj = (union acpi_object *)response.pointer; + +if (obj && obj->type ==ACPI_TYPE_BUFFER ) { +int *buffer = (int *)obj->buffer.pointer; + key =dell_wmi_get_entry_by_scancode (buffer[1 ]);
drivers/misc/dell-wmi.c line 135
Quoted 10 lines
drivers/misc/dell-wmi.c new file +10
-0+if (key) { +input_report_key (dell_wmi_input_dev, key->keycode,1 ); +input_sync (dell_wmi_input_dev); +input_report_key (dell_wmi_input_dev, key->keycode,0 ); +input_sync (dell_wmi_input_dev); + }else +printk (KERN_INFO "dell-wmi: Unknown key %x pressed\n" , + buffer[1 ]); + } +return ;
No need to at the end of a function.
drivers/misc/dell-wmi.c line 145
Quoted 10 lines
drivers/misc/dell-wmi.c new file +10
-0+} + +static int __init dell_wmi_input_setup (void ) +{ +struct key_entry *key; +int err; + + dell_wmi_input_dev =input_allocate_device (); + + dell_wmi_input_dev->name ="Dell WMI hotkeys" ;
Missing check for allocation failure.
drivers/misc/dell-wmi.c line 182
Quoted 10 lines
[...]
drivers/misc/dell-wmi.c new file +9
-0+static int __init dell_wmi_init (void ) +{ +int err; + +if (wmi_has_guid (DELL_EVENT_GUID )) { + err =wmi_install_notify_handler (DELL_EVENT_GUID , + dell_wmi_notify,NULL ); +if (!err) +dell_wmi_input_setup ();
Uhm, what if the notify handler gets called before the device has been set up? And looking at the function, the dell_wmi_input_setup() call can fail, which means you end up with invalid device handle.
Sven
Thanks - updated version follows.
commit 6e7b4e08dc924e3ec71f33b9e0e8fda077c2be89
Author: Matthew Garrett <[email protected]> Date: Wed Dec 3 19:42:40 2008 +0000
misc: add dell-wmi driver
Add a WMI driver for Dell laptops. Currently it does nothing but send a generic input event when a button with a picture of a battery on it is pressed, but maybe other uses will appear over time.
MAINTAINERS +5 -0
@@ -1371,6 +1371,11 @@ P: Doug Warzecha M: [email protected] S: Maintained +DELL WMI EXTRAS DRIVER +P: Matthew Garrett +M: [email protected] +S: Maintained + DEVICE NUMBER REGISTRY P: Torben Mathiasen M: [email protected]
drivers/misc/Kconfig +10 -0
@@ -227,6 +227,16 @@ config HP_WMI To compile this driver as a module, choose M here: the module will be called hp-wmi. +config DELL_WMI + tristate "Dell WMI extras" + depends on ACPI_WMI + depends on INPUT + help + Say Y here if you want to support WMI-based hotkeys on Dell laptops. + + To compile this driver as a module, choose M here: the module will + be called dell-wmi. + config ICS932S401 tristate "Integrated Circuits ICS932S401" depends on I2C && EXPERIMENTAL
drivers/misc/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o obj-$(CONFIG_HP_WMI) += hp-wmi.o +obj-$(CONFIG_DELL_WMI) += dell-wmi.o obj-$(CONFIG_ICS932S401) += ics932s401.o obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o obj-$(CONFIG_LKDTM) += lkdtm.o
drivers/misc/dell-wmi.c new file +210 -0
210 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]