aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/thinkpad_acpi.c
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-07-18 22:45:34 -0400
committerLen Brown <len.brown@intel.com>2007-07-21 23:38:31 -0400
commit7f5d1cd6287b7b29d210f85e2343207ac4310da2 (patch)
tree3f90f701043fab6086153f2a991ebdd0e54dddad /drivers/misc/thinkpad_acpi.c
parentd54b7d7f8026300c612dd733d501fcbc22fd0370 (diff)
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.c32
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)
510/**************************************************************************** 510/****************************************************************************
511 **************************************************************************** 511 ****************************************************************************
512 * 512 *
513 * Device model: hwmon and platform 513 * Device model: input, hwmon and platform
514 * 514 *
515 **************************************************************************** 515 ****************************************************************************
516 ****************************************************************************/ 516 ****************************************************************************/
517 517
518static struct platform_device *tpacpi_pdev; 518static struct platform_device *tpacpi_pdev;
519static struct class_device *tpacpi_hwmon; 519static struct class_device *tpacpi_hwmon;
520static struct input_dev *tpacpi_inputdev;
520 521
521static struct platform_driver tpacpi_pdriver = { 522static struct platform_driver tpacpi_pdriver = {
522 .driver = { 523 .driver = {
@@ -4363,6 +4364,20 @@ static int __init thinkpad_acpi_module_init(void)
4363 thinkpad_acpi_module_exit(); 4364 thinkpad_acpi_module_exit();
4364 return ret; 4365 return ret;
4365 } 4366 }
4367 tpacpi_inputdev = input_allocate_device();
4368 if (!tpacpi_inputdev) {
4369 printk(IBM_ERR "unable to allocate input device\n");
4370 thinkpad_acpi_module_exit();
4371 return -ENOMEM;
4372 } else {
4373 /* Prepare input device, but don't register */
4374 tpacpi_inputdev->name = "ThinkPad Extra Buttons";
4375 tpacpi_inputdev->phys = IBM_DRVR_NAME "/input0";
4376 tpacpi_inputdev->id.bustype = BUS_HOST;
4377 tpacpi_inputdev->id.vendor = TPACPI_HKEY_INPUT_VENDOR;
4378 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
4379 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
4380 }
4366 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { 4381 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
4367 ret = ibm_init(&ibms_init[i]); 4382 ret = ibm_init(&ibms_init[i]);
4368 if (ret >= 0 && *ibms_init[i].param) 4383 if (ret >= 0 && *ibms_init[i].param)
@@ -4372,6 +4387,14 @@ static int __init thinkpad_acpi_module_init(void)
4372 return ret; 4387 return ret;
4373 } 4388 }
4374 } 4389 }
4390 ret = input_register_device(tpacpi_inputdev);
4391 if (ret < 0) {
4392 printk(IBM_ERR "unable to register input device\n");
4393 thinkpad_acpi_module_exit();
4394 return ret;
4395 } else {
4396 tp_features.input_device_registered = 1;
4397 }
4375 4398
4376 return 0; 4399 return 0;
4377} 4400}
@@ -4388,6 +4411,13 @@ static void thinkpad_acpi_module_exit(void)
4388 4411
4389 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n"); 4412 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
4390 4413
4414 if (tpacpi_inputdev) {
4415 if (tp_features.input_device_registered)
4416 input_unregister_device(tpacpi_inputdev);
4417 else
4418 input_free_device(tpacpi_inputdev);
4419 }
4420
4391 if (tpacpi_hwmon) 4421 if (tpacpi_hwmon)
4392 hwmon_device_unregister(tpacpi_hwmon); 4422 hwmon_device_unregister(tpacpi_hwmon);
4393 4423