diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2007-07-19 06:45:34 +0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-07-22 07:38:31 +0400 |
commit | 7f5d1cd6287b7b29d210f85e2343207ac4310da2 (patch) | |
tree | 3f90f701043fab6086153f2a991ebdd0e54dddad /drivers/misc/thinkpad_acpi.c | |
parent | d54b7d7f8026300c612dd733d501fcbc22fd0370 (diff) | |
download | linux-7f5d1cd6287b7b29d210f85e2343207ac4310da2.tar.xz |
ACPI: thinkpad-acpi: register input device
Register an input device to send input events to userspace.
This patch is based on a patch by Richard Hughes <hughsient@gmail.com>.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Richard Hughes <hughsient@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.c')
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 4d7189330ec1..4427c994bc7d 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -510,13 +510,14 @@ static char *next_cmd(char **cmds) /**************************************************************************** **************************************************************************** * - * Device model: hwmon and platform + * Device model: input, hwmon and platform * **************************************************************************** ****************************************************************************/ static struct platform_device *tpacpi_pdev; static struct class_device *tpacpi_hwmon; +static struct input_dev *tpacpi_inputdev; static struct platform_driver tpacpi_pdriver = { .driver = { @@ -4363,6 +4364,20 @@ static int __init thinkpad_acpi_module_init(void) thinkpad_acpi_module_exit(); return ret; } + tpacpi_inputdev = input_allocate_device(); + if (!tpacpi_inputdev) { + printk(IBM_ERR "unable to allocate input device\n"); + thinkpad_acpi_module_exit(); + return -ENOMEM; + } else { + /* Prepare input device, but don't register */ + tpacpi_inputdev->name = "ThinkPad Extra Buttons"; + tpacpi_inputdev->phys = IBM_DRVR_NAME "/input0"; + tpacpi_inputdev->id.bustype = BUS_HOST; + tpacpi_inputdev->id.vendor = TPACPI_HKEY_INPUT_VENDOR; + tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; + tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; + } for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { ret = ibm_init(&ibms_init[i]); if (ret >= 0 && *ibms_init[i].param) @@ -4372,6 +4387,14 @@ static int __init thinkpad_acpi_module_init(void) return ret; } } + ret = input_register_device(tpacpi_inputdev); + if (ret < 0) { + printk(IBM_ERR "unable to register input device\n"); + thinkpad_acpi_module_exit(); + return ret; + } else { + tp_features.input_device_registered = 1; + } return 0; } @@ -4388,6 +4411,13 @@ static void thinkpad_acpi_module_exit(void) dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n"); + if (tpacpi_inputdev) { + if (tp_features.input_device_registered) + input_unregister_device(tpacpi_inputdev); + else + input_free_device(tpacpi_inputdev); + } + if (tpacpi_hwmon) hwmon_device_unregister(tpacpi_hwmon); |