Add patches accepted for 2.6.23-rc1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.23-rc1 / 0009-ACPI-thinkpad-acpi-register-input-device.patch
blob54612cf33c93570be13c384e1bc7ed4603666683
1 From 7f5d1cd6287b7b29d210f85e2343207ac4310da2 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Wed, 18 Jul 2007 23:45:34 -0300
4 Subject: ACPI: thinkpad-acpi: register input device
6 Register an input device to send input events to userspace.
8 This patch is based on a patch by Richard Hughes <hughsient@gmail.com>.
10 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
11 Cc: Richard Hughes <hughsient@gmail.com>
12 Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
13 Signed-off-by: Len Brown <len.brown@intel.com>
14 ---
15 drivers/misc/thinkpad_acpi.c | 32 +++++++++++++++++++++++++++++++-
16 drivers/misc/thinkpad_acpi.h | 9 +++++++++
17 2 files changed, 40 insertions(+), 1 deletions(-)
19 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
20 index 4d71893..4427c99 100644
21 --- a/drivers/misc/thinkpad_acpi.c
22 +++ b/drivers/misc/thinkpad_acpi.c
23 @@ -510,13 +510,14 @@ static char *next_cmd(char **cmds)
24 /****************************************************************************
25 ****************************************************************************
27 - * Device model: hwmon and platform
28 + * Device model: input, hwmon and platform
30 ****************************************************************************
31 ****************************************************************************/
33 static struct platform_device *tpacpi_pdev;
34 static struct class_device *tpacpi_hwmon;
35 +static struct input_dev *tpacpi_inputdev;
37 static struct platform_driver tpacpi_pdriver = {
38 .driver = {
39 @@ -4363,6 +4364,20 @@ static int __init thinkpad_acpi_module_init(void)
40 thinkpad_acpi_module_exit();
41 return ret;
43 + tpacpi_inputdev = input_allocate_device();
44 + if (!tpacpi_inputdev) {
45 + printk(IBM_ERR "unable to allocate input device\n");
46 + thinkpad_acpi_module_exit();
47 + return -ENOMEM;
48 + } else {
49 + /* Prepare input device, but don't register */
50 + tpacpi_inputdev->name = "ThinkPad Extra Buttons";
51 + tpacpi_inputdev->phys = IBM_DRVR_NAME "/input0";
52 + tpacpi_inputdev->id.bustype = BUS_HOST;
53 + tpacpi_inputdev->id.vendor = TPACPI_HKEY_INPUT_VENDOR;
54 + tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
55 + tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
56 + }
57 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
58 ret = ibm_init(&ibms_init[i]);
59 if (ret >= 0 && *ibms_init[i].param)
60 @@ -4372,6 +4387,14 @@ static int __init thinkpad_acpi_module_init(void)
61 return ret;
64 + ret = input_register_device(tpacpi_inputdev);
65 + if (ret < 0) {
66 + printk(IBM_ERR "unable to register input device\n");
67 + thinkpad_acpi_module_exit();
68 + return ret;
69 + } else {
70 + tp_features.input_device_registered = 1;
71 + }
73 return 0;
75 @@ -4388,6 +4411,13 @@ static void thinkpad_acpi_module_exit(void)
77 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
79 + if (tpacpi_inputdev) {
80 + if (tp_features.input_device_registered)
81 + input_unregister_device(tpacpi_inputdev);
82 + else
83 + input_free_device(tpacpi_inputdev);
84 + }
86 if (tpacpi_hwmon)
87 hwmon_device_unregister(tpacpi_hwmon);
89 diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
90 index 78ea4c8..00f1bd7 100644
91 --- a/drivers/misc/thinkpad_acpi.h
92 +++ b/drivers/misc/thinkpad_acpi.h
93 @@ -39,6 +39,7 @@
94 #include <linux/platform_device.h>
95 #include <linux/hwmon.h>
96 #include <linux/hwmon-sysfs.h>
97 +#include <linux/input.h>
98 #include <asm/uaccess.h>
100 #include <linux/dmi.h>
101 @@ -48,6 +49,7 @@
102 #include <acpi/acpi_drivers.h>
103 #include <acpi/acnamesp.h>
105 +#include <linux/pci_ids.h>
107 /****************************************************************************
108 * Main driver
109 @@ -98,6 +100,11 @@ static const char *str_supported(int is_supported);
110 #define vdbg_printk(a_dbg_level, format, arg...)
111 #endif
113 +/* Input IDs */
114 +#define TPACPI_HKEY_INPUT_VENDOR PCI_VENDOR_ID_IBM
115 +#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */
116 +#define TPACPI_HKEY_INPUT_VERSION 0x4101
118 /* ACPI HIDs */
119 #define IBM_HKEY_HID "IBM0068"
120 #define IBM_PCI_HID "PNP0A03"
121 @@ -161,6 +168,7 @@ static int parse_strtoul(const char *buf, unsigned long max,
122 static struct platform_device *tpacpi_pdev;
123 static struct class_device *tpacpi_hwmon;
124 static struct platform_driver tpacpi_pdriver;
125 +static struct input_dev *tpacpi_inputdev;
126 static int tpacpi_create_driver_attributes(struct device_driver *drv);
127 static void tpacpi_remove_driver_attributes(struct device_driver *drv);
129 @@ -233,6 +241,7 @@ static struct {
130 u16 light_status:1;
131 u16 wan:1;
132 u16 fan_ctrl_status_undef:1;
133 + u16 input_device_registered:1;
134 } tp_features;
136 static struct list_head tpacpi_all_drivers;
138 1.5.2.1