diff options
author | Corentin Chary <corentincj@iksaif.net> | 2011-02-26 04:20:31 -0500 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2011-03-28 06:07:20 -0400 |
commit | e12e6d94db24e9050821965aa75c95e8d2c65f10 (patch) | |
tree | 9d747a02982309c27206720d2f6699db9e532dff /drivers | |
parent | 5b799d4fb787bb94f1068352220ab033ac7969f8 (diff) |
eeepc-wmi: asus generic asus-wmi.ko module
New Asus notebooks are using a WMI device similar to
the one used in Eee PCs. Since we don't want to load
eeepc-wmi module on Asus notebooks, and we want to
keep the eeepc-wmi module for backward compatibility,
this patch introduce a new module, named asus-wmi, that
will be used by eeepc-wmi and the new Asus Notebook WMI
Driver.
eeepc-wmi's input device strings (device name and phys)
are kept, but rfkill and led names are changed (s/eeepc/asus/).
This should not break anything since rfkill are used by type or
index, not by name, and the eeepc::touchpad led wasn't working
correctly before 2.6.39 anyway.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/Kconfig | 24 | ||||
-rw-r--r-- | drivers/platform/x86/Makefile | 3 | ||||
-rw-r--r-- | drivers/platform/x86/asus-wmi.c | 924 | ||||
-rw-r--r-- | drivers/platform/x86/asus-wmi.h | 58 | ||||
-rw-r--r-- | drivers/platform/x86/eeepc-wmi.c | 162 |
5 files changed, 677 insertions, 494 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index b039d6a93f17..7fde7ba01ab0 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -451,10 +451,11 @@ config EEEPC_LAPTOP | |||
451 | Bluetooth, backlight and allows powering on/off some other | 451 | Bluetooth, backlight and allows powering on/off some other |
452 | devices. | 452 | devices. |
453 | 453 | ||
454 | If you have an Eee PC laptop, say Y or M here. | 454 | If you have an Eee PC laptop, say Y or M here. If this driver |
455 | doesn't work on your Eee PC, try eeepc-wmi instead. | ||
455 | 456 | ||
456 | config EEEPC_WMI | 457 | config ASUS_WMI |
457 | tristate "Eee PC WMI Hotkey Driver (EXPERIMENTAL)" | 458 | tristate "ASUS WMI Driver (EXPERIMENTAL)" |
458 | depends on ACPI_WMI | 459 | depends on ACPI_WMI |
459 | depends on INPUT | 460 | depends on INPUT |
460 | depends on EXPERIMENTAL | 461 | depends on EXPERIMENTAL |
@@ -464,10 +465,23 @@ config EEEPC_WMI | |||
464 | select LEDS_CLASS | 465 | select LEDS_CLASS |
465 | select NEW_LEDS | 466 | select NEW_LEDS |
466 | ---help--- | 467 | ---help--- |
467 | Say Y here if you want to support WMI-based hotkeys on Eee PC laptops. | 468 | Say Y here if you have a WMI aware Asus laptop (like Eee PCs). |
468 | 469 | ||
469 | To compile this driver as a module, choose M here: the module will | 470 | To compile this driver as a module, choose M here: the module will |
470 | be called eeepc-wmi. | 471 | be called asus-wmi. |
472 | |||
473 | config EEEPC_WMI | ||
474 | tristate "Eee PC WMI Driver (EXPERIMENTAL)" | ||
475 | depends on ASUS_WMI | ||
476 | ---help--- | ||
477 | This is a driver for newer Eee PC laptops. It adds extra features | ||
478 | like wireless radio and bluetooth control, leds, hotkeys, backlight... | ||
479 | |||
480 | For more informations, see | ||
481 | <file:Documentation/ABI/testing/sysfs-platform-asus-wmi> | ||
482 | |||
483 | If you have an ACPI-WMI compatible Eee PC laptop (>= 1000), say Y or M | ||
484 | here. | ||
471 | 485 | ||
472 | config ACPI_WMI | 486 | config ACPI_WMI |
473 | tristate "WMI" | 487 | tristate "WMI" |
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 443257617b20..f9c83f48c922 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile | |||
@@ -3,8 +3,9 @@ | |||
3 | # x86 Platform-Specific Drivers | 3 | # x86 Platform-Specific Drivers |
4 | # | 4 | # |
5 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o | 5 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o |
6 | obj-$(CONFIG_ASUS_WMI) += asus-wmi.o | ||
6 | obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o | 7 | obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o |
7 | obj-$(CONFIG_EEEPC_WMI) += asus-wmi.o eeepc-wmi.o | 8 | obj-$(CONFIG_EEEPC_WMI) += eeepc-wmi.o |
8 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o | 9 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o |
9 | obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o | 10 | obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o |
10 | obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o | 11 | obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o |
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index d3997757e790..35e6bb6c266d 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Eee PC WMI hotkey driver | 2 | * Asus PC WMI hotkey driver |
3 | * | 3 | * |
4 | * Copyright(C) 2010 Intel Corporation. | 4 | * Copyright(C) 2010 Intel Corporation. |
5 | * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com> | 5 | * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com> |
@@ -42,23 +42,23 @@ | |||
42 | #include <linux/debugfs.h> | 42 | #include <linux/debugfs.h> |
43 | #include <linux/seq_file.h> | 43 | #include <linux/seq_file.h> |
44 | #include <linux/platform_device.h> | 44 | #include <linux/platform_device.h> |
45 | #include <linux/dmi.h> | ||
46 | #include <acpi/acpi_bus.h> | 45 | #include <acpi/acpi_bus.h> |
47 | #include <acpi/acpi_drivers.h> | 46 | #include <acpi/acpi_drivers.h> |
48 | 47 | ||
49 | #define EEEPC_WMI_FILE "eeepc-wmi" | 48 | #include "asus-wmi.h" |
50 | 49 | ||
51 | MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>"); | 50 | MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>, " |
52 | MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver"); | 51 | "Yong Wang <yong.y.wang@intel.com>"); |
52 | MODULE_DESCRIPTION("Asus Generic WMI Driver"); | ||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #define EEEPC_ACPI_HID "ASUS010" /* old _HID used in eeepc-laptop */ | 55 | #define to_platform_driver(drv) \ |
56 | (container_of((drv), struct platform_driver, driver)) | ||
56 | 57 | ||
57 | #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000" | 58 | #define to_asus_wmi_driver(pdrv) \ |
58 | #define EEEPC_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66" | 59 | (container_of((pdrv), struct asus_wmi_driver, platform_driver)) |
59 | 60 | ||
60 | MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID); | 61 | #define ASUS_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66" |
61 | MODULE_ALIAS("wmi:"EEEPC_WMI_MGMT_GUID); | ||
62 | 62 | ||
63 | #define NOTIFY_BRNUP_MIN 0x11 | 63 | #define NOTIFY_BRNUP_MIN 0x11 |
64 | #define NOTIFY_BRNUP_MAX 0x1f | 64 | #define NOTIFY_BRNUP_MAX 0x1f |
@@ -66,90 +66,55 @@ MODULE_ALIAS("wmi:"EEEPC_WMI_MGMT_GUID); | |||
66 | #define NOTIFY_BRNDOWN_MAX 0x2e | 66 | #define NOTIFY_BRNDOWN_MAX 0x2e |
67 | 67 | ||
68 | /* WMI Methods */ | 68 | /* WMI Methods */ |
69 | #define EEEPC_WMI_METHODID_DSTS 0x53544344 | 69 | #define ASUS_WMI_METHODID_DSTS 0x53544344 |
70 | #define EEEPC_WMI_METHODID_DEVS 0x53564544 | 70 | #define ASUS_WMI_METHODID_DEVS 0x53564544 |
71 | #define EEEPC_WMI_METHODID_CFVS 0x53564643 | 71 | #define ASUS_WMI_METHODID_CFVS 0x53564643 |
72 | 72 | ||
73 | /* Wireless */ | 73 | /* Wireless */ |
74 | #define EEEPC_WMI_DEVID_WLAN 0x00010011 | 74 | #define ASUS_WMI_DEVID_WLAN 0x00010011 |
75 | #define EEEPC_WMI_DEVID_BLUETOOTH 0x00010013 | 75 | #define ASUS_WMI_DEVID_BLUETOOTH 0x00010013 |
76 | #define EEEPC_WMI_DEVID_WIMAX 0x00010017 | 76 | #define ASUS_WMI_DEVID_WIMAX 0x00010017 |
77 | #define EEEPC_WMI_DEVID_WWAN3G 0x00010019 | 77 | #define ASUS_WMI_DEVID_WWAN3G 0x00010019 |
78 | 78 | ||
79 | /* Backlight and Brightness */ | 79 | /* Backlight and Brightness */ |
80 | #define EEEPC_WMI_DEVID_BACKLIGHT 0x00050011 | 80 | #define ASUS_WMI_DEVID_BACKLIGHT 0x00050011 |
81 | #define EEEPC_WMI_DEVID_BRIGHTNESS 0x00050012 | 81 | #define ASUS_WMI_DEVID_BRIGHTNESS 0x00050012 |
82 | 82 | ||
83 | /* Misc */ | 83 | /* Misc */ |
84 | #define EEEPC_WMI_DEVID_CAMERA 0x00060013 | 84 | #define ASUS_WMI_DEVID_CAMERA 0x00060013 |
85 | 85 | ||
86 | /* Storage */ | 86 | /* Storage */ |
87 | #define EEEPC_WMI_DEVID_CARDREADER 0x00080013 | 87 | #define ASUS_WMI_DEVID_CARDREADER 0x00080013 |
88 | 88 | ||
89 | /* Input */ | 89 | /* Input */ |
90 | #define EEEPC_WMI_DEVID_TOUCHPAD 0x00100011 | 90 | #define ASUS_WMI_DEVID_TOUCHPAD 0x00100011 |
91 | #define EEEPC_WMI_DEVID_TOUCHPAD_LED 0x00100012 | 91 | #define ASUS_WMI_DEVID_TOUCHPAD_LED 0x00100012 |
92 | 92 | ||
93 | /* DSTS masks */ | 93 | /* DSTS masks */ |
94 | #define EEEPC_WMI_DSTS_STATUS_BIT 0x00000001 | 94 | #define ASUS_WMI_DSTS_STATUS_BIT 0x00000001 |
95 | #define EEEPC_WMI_DSTS_PRESENCE_BIT 0x00010000 | 95 | #define ASUS_WMI_DSTS_PRESENCE_BIT 0x00010000 |
96 | #define EEEPC_WMI_DSTS_BRIGHTNESS_MASK 0x000000FF | 96 | #define ASUS_WMI_DSTS_BRIGHTNESS_MASK 0x000000FF |
97 | #define EEEPC_WMI_DSTS_MAX_BRIGTH_MASK 0x0000FF00 | 97 | #define ASUS_WMI_DSTS_MAX_BRIGTH_MASK 0x0000FF00 |
98 | |||
99 | static bool hotplug_wireless; | ||
100 | |||
101 | module_param(hotplug_wireless, bool, 0444); | ||
102 | MODULE_PARM_DESC(hotplug_wireless, | ||
103 | "Enable hotplug for wireless device. " | ||
104 | "If your laptop needs that, please report to " | ||
105 | "acpi4asus-user@lists.sourceforge.net."); | ||
106 | |||
107 | static const struct key_entry eeepc_wmi_keymap[] = { | ||
108 | /* Sleep already handled via generic ACPI code */ | ||
109 | { KE_IGNORE, NOTIFY_BRNDOWN_MIN, { KEY_BRIGHTNESSDOWN } }, | ||
110 | { KE_IGNORE, NOTIFY_BRNUP_MIN, { KEY_BRIGHTNESSUP } }, | ||
111 | { KE_KEY, 0x30, { KEY_VOLUMEUP } }, | ||
112 | { KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, | ||
113 | { KE_KEY, 0x32, { KEY_MUTE } }, | ||
114 | { KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */ | ||
115 | { KE_KEY, 0x5d, { KEY_WLAN } }, | ||
116 | { KE_KEY, 0x6b, { KEY_F13 } }, /* Disable Touchpad */ | ||
117 | { KE_KEY, 0x82, { KEY_CAMERA } }, | ||
118 | { KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } }, | ||
119 | { KE_KEY, 0x88, { KEY_WLAN } }, | ||
120 | { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } }, | ||
121 | { KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */ | ||
122 | { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */ | ||
123 | { KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } }, | ||
124 | { KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } }, | ||
125 | { KE_KEY, 0xec, { KEY_CAMERA_UP } }, | ||
126 | { KE_KEY, 0xed, { KEY_CAMERA_DOWN } }, | ||
127 | { KE_KEY, 0xee, { KEY_CAMERA_LEFT } }, | ||
128 | { KE_KEY, 0xef, { KEY_CAMERA_RIGHT } }, | ||
129 | { KE_END, 0}, | ||
130 | }; | ||
131 | 98 | ||
132 | struct bios_args { | 99 | struct bios_args { |
133 | u32 dev_id; | 100 | u32 dev_id; |
134 | u32 ctrl_param; | 101 | u32 ctrl_param; |
135 | }; | 102 | }; |
136 | 103 | ||
137 | /* | 104 | /* |
138 | * eeepc-wmi/ - debugfs root directory | 105 | * <platform>/ - debugfs root directory |
139 | * dev_id - current dev_id | 106 | * dev_id - current dev_id |
140 | * ctrl_param - current ctrl_param | 107 | * ctrl_param - current ctrl_param |
141 | * devs - call DEVS(dev_id, ctrl_param) and print result | 108 | * devs - call DEVS(dev_id, ctrl_param) and print result |
142 | * dsts - call DSTS(dev_id) and print result | 109 | * dsts - call DSTS(dev_id) and print result |
143 | */ | 110 | */ |
144 | struct eeepc_wmi_debug { | 111 | struct asus_wmi_debug { |
145 | struct dentry *root; | 112 | struct dentry *root; |
146 | u32 dev_id; | 113 | u32 dev_id; |
147 | u32 ctrl_param; | 114 | u32 ctrl_param; |
148 | }; | 115 | }; |
149 | 116 | ||
150 | struct eeepc_wmi { | 117 | struct asus_wmi { |
151 | bool hotplug_wireless; | ||
152 | |||
153 | struct input_dev *inputdev; | 118 | struct input_dev *inputdev; |
154 | struct backlight_device *backlight_device; | 119 | struct backlight_device *backlight_device; |
155 | struct platform_device *platform_device; | 120 | struct platform_device *platform_device; |
@@ -170,59 +135,61 @@ struct eeepc_wmi { | |||
170 | struct workqueue_struct *hotplug_workqueue; | 135 | struct workqueue_struct *hotplug_workqueue; |
171 | struct work_struct hotplug_work; | 136 | struct work_struct hotplug_work; |
172 | 137 | ||
173 | struct eeepc_wmi_debug debug; | 138 | struct asus_wmi_debug debug; |
139 | |||
140 | struct asus_wmi_driver *driver; | ||
174 | }; | 141 | }; |
175 | 142 | ||
176 | static int eeepc_wmi_input_init(struct eeepc_wmi *eeepc) | 143 | static int asus_wmi_input_init(struct asus_wmi *asus) |
177 | { | 144 | { |
178 | int err; | 145 | int err; |
179 | 146 | ||
180 | eeepc->inputdev = input_allocate_device(); | 147 | asus->inputdev = input_allocate_device(); |
181 | if (!eeepc->inputdev) | 148 | if (!asus->inputdev) |
182 | return -ENOMEM; | 149 | return -ENOMEM; |
183 | 150 | ||
184 | eeepc->inputdev->name = "Eee PC WMI hotkeys"; | 151 | asus->inputdev->name = asus->driver->input_phys; |
185 | eeepc->inputdev->phys = EEEPC_WMI_FILE "/input0"; | 152 | asus->inputdev->phys = asus->driver->input_name; |
186 | eeepc->inputdev->id.bustype = BUS_HOST; | 153 | asus->inputdev->id.bustype = BUS_HOST; |
187 | eeepc->inputdev->dev.parent = &eeepc->platform_device->dev; | 154 | asus->inputdev->dev.parent = &asus->platform_device->dev; |
188 | 155 | ||
189 | err = sparse_keymap_setup(eeepc->inputdev, eeepc_wmi_keymap, NULL); | 156 | err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); |
190 | if (err) | 157 | if (err) |
191 | goto err_free_dev; | 158 | goto err_free_dev; |
192 | 159 | ||
193 | err = input_register_device(eeepc->inputdev); | 160 | err = input_register_device(asus->inputdev); |
194 | if (err) | 161 | if (err) |
195 | goto err_free_keymap; | 162 | goto err_free_keymap; |
196 | 163 | ||
197 | return 0; | 164 | return 0; |
198 | 165 | ||
199 | err_free_keymap: | 166 | err_free_keymap: |
200 | sparse_keymap_free(eeepc->inputdev); | 167 | sparse_keymap_free(asus->inputdev); |
201 | err_free_dev: | 168 | err_free_dev: |
202 | input_free_device(eeepc->inputdev); | 169 | input_free_device(asus->inputdev); |
203 | return err; | 170 | return err; |
204 | } | 171 | } |
205 | 172 | ||
206 | static void eeepc_wmi_input_exit(struct eeepc_wmi *eeepc) | 173 | static void asus_wmi_input_exit(struct asus_wmi *asus) |
207 | { | 174 | { |
208 | if (eeepc->inputdev) { | 175 | if (asus->inputdev) { |
209 | sparse_keymap_free(eeepc->inputdev); | 176 | sparse_keymap_free(asus->inputdev); |
210 | input_unregister_device(eeepc->inputdev); | 177 | input_unregister_device(asus->inputdev); |
211 | } | 178 | } |
212 | 179 | ||
213 | eeepc->inputdev = NULL; | 180 | asus->inputdev = NULL; |
214 | } | 181 | } |
215 | 182 | ||
216 | static acpi_status eeepc_wmi_get_devstate(u32 dev_id, u32 *retval) | 183 | static acpi_status asus_wmi_get_devstate(u32 dev_id, u32 *retval) |
217 | { | 184 | { |
218 | struct acpi_buffer input = { (acpi_size)sizeof(u32), &dev_id }; | 185 | struct acpi_buffer input = { (acpi_size) sizeof(u32), &dev_id }; |
219 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | 186 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
220 | union acpi_object *obj; | 187 | union acpi_object *obj; |
221 | acpi_status status; | 188 | acpi_status status; |
222 | u32 tmp; | 189 | u32 tmp; |
223 | 190 | ||
224 | status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID, | 191 | status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, |
225 | 1, EEEPC_WMI_METHODID_DSTS, | 192 | 1, ASUS_WMI_METHODID_DSTS, |
226 | &input, &output); | 193 | &input, &output); |
227 | 194 | ||
228 | if (ACPI_FAILURE(status)) | 195 | if (ACPI_FAILURE(status)) |
@@ -230,7 +197,7 @@ static acpi_status eeepc_wmi_get_devstate(u32 dev_id, u32 *retval) | |||
230 | 197 | ||
231 | obj = (union acpi_object *)output.pointer; | 198 | obj = (union acpi_object *)output.pointer; |
232 | if (obj && obj->type == ACPI_TYPE_INTEGER) | 199 | if (obj && obj->type == ACPI_TYPE_INTEGER) |
233 | tmp = (u32)obj->integer.value; | 200 | tmp = (u32) obj->integer.value; |
234 | else | 201 | else |
235 | tmp = 0; | 202 | tmp = 0; |
236 | 203 | ||
@@ -243,27 +210,27 @@ static acpi_status eeepc_wmi_get_devstate(u32 dev_id, u32 *retval) | |||
243 | 210 | ||
244 | } | 211 | } |
245 | 212 | ||
246 | static acpi_status eeepc_wmi_set_devstate(u32 dev_id, u32 ctrl_param, | 213 | static acpi_status asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, |
247 | u32 *retval) | 214 | u32 *retval) |
248 | { | 215 | { |
249 | struct bios_args args = { | 216 | struct bios_args args = { |
250 | .dev_id = dev_id, | 217 | .dev_id = dev_id, |
251 | .ctrl_param = ctrl_param, | 218 | .ctrl_param = ctrl_param, |
252 | }; | 219 | }; |
253 | struct acpi_buffer input = { (acpi_size)sizeof(args), &args }; | 220 | struct acpi_buffer input = { (acpi_size) sizeof(args), &args }; |
254 | acpi_status status; | 221 | acpi_status status; |
255 | 222 | ||
256 | if (!retval) { | 223 | if (!retval) { |
257 | status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID, 1, | 224 | status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 1, |
258 | EEEPC_WMI_METHODID_DEVS, | 225 | ASUS_WMI_METHODID_DEVS, |
259 | &input, NULL); | 226 | &input, NULL); |
260 | } else { | 227 | } else { |
261 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | 228 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
262 | union acpi_object *obj; | 229 | union acpi_object *obj; |
263 | u32 tmp; | 230 | u32 tmp; |
264 | 231 | ||
265 | status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID, 1, | 232 | status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 1, |
266 | EEEPC_WMI_METHODID_DEVS, | 233 | ASUS_WMI_METHODID_DEVS, |
267 | &input, &output); | 234 | &input, &output); |
268 | 235 | ||
269 | if (ACPI_FAILURE(status)) | 236 | if (ACPI_FAILURE(status)) |
@@ -271,7 +238,7 @@ static acpi_status eeepc_wmi_set_devstate(u32 dev_id, u32 ctrl_param, | |||
271 | 238 | ||
272 | obj = (union acpi_object *)output.pointer; | 239 | obj = (union acpi_object *)output.pointer; |
273 | if (obj && obj->type == ACPI_TYPE_INTEGER) | 240 | if (obj && obj->type == ACPI_TYPE_INTEGER) |
274 | tmp = (u32)obj->integer.value; | 241 | tmp = (u32) obj->integer.value; |
275 | else | 242 | else |
276 | tmp = 0; | 243 | tmp = 0; |
277 | 244 | ||
@@ -284,25 +251,25 @@ static acpi_status eeepc_wmi_set_devstate(u32 dev_id, u32 ctrl_param, | |||
284 | } | 251 | } |
285 | 252 | ||
286 | /* Helper for special devices with magic return codes */ | 253 | /* Helper for special devices with magic return codes */ |
287 | static int eeepc_wmi_get_devstate_bits(u32 dev_id, u32 mask) | 254 | static int asus_wmi_get_devstate_bits(u32 dev_id, u32 mask) |
288 | { | 255 | { |
289 | u32 retval = 0; | 256 | u32 retval = 0; |
290 | acpi_status status; | 257 | acpi_status status; |
291 | 258 | ||
292 | status = eeepc_wmi_get_devstate(dev_id, &retval); | 259 | status = asus_wmi_get_devstate(dev_id, &retval); |
293 | 260 | ||
294 | if (ACPI_FAILURE(status)) | 261 | if (ACPI_FAILURE(status)) |
295 | return -EINVAL; | 262 | return -EINVAL; |
296 | 263 | ||
297 | if (!(retval & EEEPC_WMI_DSTS_PRESENCE_BIT)) | 264 | if (!(retval & ASUS_WMI_DSTS_PRESENCE_BIT)) |
298 | return -ENODEV; | 265 | return -ENODEV; |
299 | 266 | ||
300 | return retval & mask; | 267 | return retval & mask; |
301 | } | 268 | } |
302 | 269 | ||
303 | static int eeepc_wmi_get_devstate_simple(u32 dev_id) | 270 | static int asus_wmi_get_devstate_simple(u32 dev_id) |
304 | { | 271 | { |
305 | return eeepc_wmi_get_devstate_bits(dev_id, EEEPC_WMI_DSTS_STATUS_BIT); | 272 | return asus_wmi_get_devstate_bits(dev_id, ASUS_WMI_DSTS_STATUS_BIT); |
306 | } | 273 | } |
307 | 274 | ||
308 | /* | 275 | /* |
@@ -311,93 +278,92 @@ static int eeepc_wmi_get_devstate_simple(u32 dev_id) | |||
311 | /* | 278 | /* |
312 | * These functions actually update the LED's, and are called from a | 279 | * These functions actually update the LED's, and are called from a |
313 | * workqueue. By doing this as separate work rather than when the LED | 280 | * workqueue. By doing this as separate work rather than when the LED |
314 | * subsystem asks, we avoid messing with the Eeepc ACPI stuff during a | 281 | * subsystem asks, we avoid messing with the Asus ACPI stuff during a |
315 | * potentially bad time, such as a timer interrupt. | 282 | * potentially bad time, such as a timer interrupt. |
316 | */ | 283 | */ |
317 | static void tpd_led_update(struct work_struct *work) | 284 | static void tpd_led_update(struct work_struct *work) |
318 | { | 285 | { |
319 | int ctrl_param; | 286 | int ctrl_param; |
320 | struct eeepc_wmi *eeepc; | 287 | struct asus_wmi *asus; |
321 | 288 | ||
322 | eeepc = container_of(work, struct eeepc_wmi, tpd_led_work); | 289 | asus = container_of(work, struct asus_wmi, tpd_led_work); |
323 | 290 | ||
324 | ctrl_param = eeepc->tpd_led_wk; | 291 | ctrl_param = asus->tpd_led_wk; |
325 | eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_TOUCHPAD_LED, ctrl_param, NULL); | 292 | asus_wmi_set_devstate(ASUS_WMI_DEVID_TOUCHPAD_LED, ctrl_param, NULL); |
326 | } | 293 | } |
327 | 294 | ||
328 | static void tpd_led_set(struct led_classdev *led_cdev, | 295 | static void tpd_led_set(struct led_classdev *led_cdev, |
329 | enum led_brightness value) | 296 | enum led_brightness value) |
330 | { | 297 | { |
331 | struct eeepc_wmi *eeepc; | 298 | struct asus_wmi *asus; |
332 | 299 | ||
333 | eeepc = container_of(led_cdev, struct eeepc_wmi, tpd_led); | 300 | asus = container_of(led_cdev, struct asus_wmi, tpd_led); |
334 | 301 | ||
335 | eeepc->tpd_led_wk = !!value; | 302 | asus->tpd_led_wk = !!value; |
336 | queue_work(eeepc->led_workqueue, &eeepc->tpd_led_work); | 303 | queue_work(asus->led_workqueue, &asus->tpd_led_work); |
337 | } | 304 | } |
338 | 305 | ||
339 | static int read_tpd_led_state(struct eeepc_wmi *eeepc) | 306 | static int read_tpd_led_state(struct asus_wmi *asus) |
340 | { | 307 | { |
341 | return eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_TOUCHPAD_LED); | 308 | return asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_TOUCHPAD_LED); |
342 | } | 309 | } |
343 | 310 | ||
344 | static enum led_brightness tpd_led_get(struct led_classdev *led_cdev) | 311 | static enum led_brightness tpd_led_get(struct led_classdev *led_cdev) |
345 | { | 312 | { |
346 | struct eeepc_wmi *eeepc; | 313 | struct asus_wmi *asus; |
347 | 314 | ||
348 | eeepc = container_of(led_cdev, struct eeepc_wmi, tpd_led); | 315 | asus = container_of(led_cdev, struct asus_wmi, tpd_led); |
349 | 316 | ||
350 | return read_tpd_led_state(eeepc); | 317 | return read_tpd_led_state(asus); |
351 | } | 318 | } |
352 | 319 | ||
353 | static int eeepc_wmi_led_init(struct eeepc_wmi *eeepc) | 320 | static int asus_wmi_led_init(struct asus_wmi *asus) |
354 | { | 321 | { |
355 | int rv; | 322 | int rv; |
356 | 323 | ||
357 | if (read_tpd_led_state(eeepc) < 0) | 324 | if (read_tpd_led_state(asus) < 0) |
358 | return 0; | 325 | return 0; |
359 | 326 | ||
360 | eeepc->led_workqueue = create_singlethread_workqueue("led_workqueue"); | 327 | asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); |
361 | if (!eeepc->led_workqueue) | 328 | if (!asus->led_workqueue) |
362 | return -ENOMEM; | 329 | return -ENOMEM; |
363 | INIT_WORK(&eeepc->tpd_led_work, tpd_led_update); | 330 | INIT_WORK(&asus->tpd_led_work, tpd_led_update); |
364 | 331 | ||
365 | eeepc->tpd_led.name = "eeepc::touchpad"; | 332 | asus->tpd_led.name = "asus::touchpad"; |
366 | eeepc->tpd_led.brightness_set = tpd_led_set; | 333 | asus->tpd_led.brightness_set = tpd_led_set; |
367 | eeepc->tpd_led.brightness_get = tpd_led_get; | 334 | asus->tpd_led.brightness_get = tpd_led_get; |
368 | eeepc->tpd_led.max_brightness = 1; | 335 | asus->tpd_led.max_brightness = 1; |
369 | 336 | ||
370 | rv = led_classdev_register(&eeepc->platform_device->dev, | 337 | rv = led_classdev_register(&asus->platform_device->dev, &asus->tpd_led); |
371 | &eeepc->tpd_led); | ||
372 | if (rv) { | 338 | if (rv) { |
373 | destroy_workqueue(eeepc->led_workqueue); | 339 | destroy_workqueue(asus->led_workqueue); |
374 | return rv; | 340 | return rv; |
375 | } | 341 | } |
376 | 342 | ||
377 | return 0; | 343 | return 0; |
378 | } | 344 | } |
379 | 345 | ||
380 | static void eeepc_wmi_led_exit(struct eeepc_wmi *eeepc) | 346 | static void asus_wmi_led_exit(struct asus_wmi *asus) |
381 | { | 347 | { |
382 | if (eeepc->tpd_led.dev) | 348 | if (asus->tpd_led.dev) |
383 | led_classdev_unregister(&eeepc->tpd_led); | 349 | led_classdev_unregister(&asus->tpd_led); |
384 | if (eeepc->led_workqueue) | 350 | if (asus->led_workqueue) |
385 | destroy_workqueue(eeepc->led_workqueue); | 351 | destroy_workqueue(asus->led_workqueue); |
386 | } | 352 | } |
387 | 353 | ||
388 | /* | 354 | /* |
389 | * PCI hotplug (for wlan rfkill) | 355 | * PCI hotplug (for wlan rfkill) |
390 | */ | 356 | */ |
391 | static bool eeepc_wlan_rfkill_blocked(struct eeepc_wmi *eeepc) | 357 | static bool asus_wlan_rfkill_blocked(struct asus_wmi *asus) |
392 | { | 358 | { |
393 | int result = eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WLAN); | 359 | int result = asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WLAN); |
394 | 360 | ||
395 | if (result < 0) | 361 | if (result < 0) |
396 | return false; | 362 | return false; |
397 | return !result; | 363 | return !result; |
398 | } | 364 | } |
399 | 365 | ||
400 | static void eeepc_rfkill_hotplug(struct eeepc_wmi *eeepc) | 366 | static void asus_rfkill_hotplug(struct asus_wmi *asus) |
401 | { | 367 | { |
402 | struct pci_dev *dev; | 368 | struct pci_dev *dev; |
403 | struct pci_bus *bus; | 369 | struct pci_bus *bus; |
@@ -405,16 +371,16 @@ static void eeepc_rfkill_hotplug(struct eeepc_wmi *eeepc) | |||
405 | bool absent; | 371 | bool absent; |
406 | u32 l; | 372 | u32 l; |
407 | 373 | ||
408 | mutex_lock(&eeepc->wmi_lock); | 374 | mutex_lock(&asus->wmi_lock); |
409 | blocked = eeepc_wlan_rfkill_blocked(eeepc); | 375 | blocked = asus_wlan_rfkill_blocked(asus); |
410 | mutex_unlock(&eeepc->wmi_lock); | 376 | mutex_unlock(&asus->wmi_lock); |
411 | 377 | ||
412 | mutex_lock(&eeepc->hotplug_lock); | 378 | mutex_lock(&asus->hotplug_lock); |
413 | 379 | ||
414 | if (eeepc->wlan_rfkill) | 380 | if (asus->wlan_rfkill) |
415 | rfkill_set_sw_state(eeepc->wlan_rfkill, blocked); | 381 | rfkill_set_sw_state(asus->wlan_rfkill, blocked); |
416 | 382 | ||
417 | if (eeepc->hotplug_slot) { | 383 | if (asus->hotplug_slot) { |
418 | bus = pci_find_bus(0, 1); | 384 | bus = pci_find_bus(0, 1); |
419 | if (!bus) { | 385 | if (!bus) { |
420 | pr_warning("Unable to find PCI bus 1?\n"); | 386 | pr_warning("Unable to find PCI bus 1?\n"); |
@@ -429,11 +395,11 @@ static void eeepc_rfkill_hotplug(struct eeepc_wmi *eeepc) | |||
429 | 395 | ||
430 | if (blocked != absent) { | 396 | if (blocked != absent) { |
431 | pr_warning("BIOS says wireless lan is %s, " | 397 | pr_warning("BIOS says wireless lan is %s, " |
432 | "but the pci device is %s\n", | 398 | "but the pci device is %s\n", |
433 | blocked ? "blocked" : "unblocked", | 399 | blocked ? "blocked" : "unblocked", |
434 | absent ? "absent" : "present"); | 400 | absent ? "absent" : "present"); |
435 | pr_warning("skipped wireless hotplug as probably " | 401 | pr_warning("skipped wireless hotplug as probably " |
436 | "inappropriate for this model\n"); | 402 | "inappropriate for this model\n"); |
437 | goto out_unlock; | 403 | goto out_unlock; |
438 | } | 404 | } |
439 | 405 | ||
@@ -460,28 +426,27 @@ static void eeepc_rfkill_hotplug(struct eeepc_wmi *eeepc) | |||
460 | } | 426 | } |
461 | 427 | ||
462 | out_unlock: | 428 | out_unlock: |
463 | mutex_unlock(&eeepc->hotplug_lock); | 429 | mutex_unlock(&asus->hotplug_lock); |
464 | } | 430 | } |
465 | 431 | ||
466 | static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) | 432 | static void asus_rfkill_notify(acpi_handle handle, u32 event, void *data) |
467 | { | 433 | { |
468 | struct eeepc_wmi *eeepc = data; | 434 | struct asus_wmi *asus = data; |
469 | 435 | ||
470 | if (event != ACPI_NOTIFY_BUS_CHECK) | 436 | if (event != ACPI_NOTIFY_BUS_CHECK) |
471 | return; | 437 | return; |
472 | 438 | ||
473 | /* | 439 | /* |
474 | * We can't call directly eeepc_rfkill_hotplug because most | 440 | * We can't call directly asus_rfkill_hotplug because most |
475 | * of the time WMBC is still being executed and not reetrant. | 441 | * of the time WMBC is still being executed and not reetrant. |
476 | * There is currently no way to tell ACPICA that we want this | 442 | * There is currently no way to tell ACPICA that we want this |
477 | * method to be serialized, we schedule a eeepc_rfkill_hotplug | 443 | * method to be serialized, we schedule a asus_rfkill_hotplug |
478 | * call later, in a safer context. | 444 | * call later, in a safer context. |
479 | */ | 445 | */ |
480 | queue_work(eeepc->hotplug_workqueue, &eeepc->hotplug_work); | 446 | queue_work(asus->hotplug_workqueue, &asus->hotplug_work); |
481 | } | 447 | } |
482 | 448 | ||
483 | static int eeepc_register_rfkill_notifier(struct eeepc_wmi *eeepc, | 449 | static int asus_register_rfkill_notifier(struct asus_wmi *asus, char *node) |
484 | char *node) | ||
485 | { | 450 | { |
486 | acpi_status status; | 451 | acpi_status status; |
487 | acpi_handle handle; | 452 | acpi_handle handle; |
@@ -491,8 +456,7 @@ static int eeepc_register_rfkill_notifier(struct eeepc_wmi *eeepc, | |||
491 | if (ACPI_SUCCESS(status)) { | 456 | if (ACPI_SUCCESS(status)) { |
492 | status = acpi_install_notify_handler(handle, | 457 | status = acpi_install_notify_handler(handle, |
493 | ACPI_SYSTEM_NOTIFY, | 458 | ACPI_SYSTEM_NOTIFY, |
494 | eeepc_rfkill_notify, | 459 | asus_rfkill_notify, asus); |
495 | eeepc); | ||
496 | if (ACPI_FAILURE(status)) | 460 | if (ACPI_FAILURE(status)) |
497 | pr_warning("Failed to register notify on %s\n", node); | 461 | pr_warning("Failed to register notify on %s\n", node); |
498 | } else | 462 | } else |
@@ -501,8 +465,7 @@ static int eeepc_register_rfkill_notifier(struct eeepc_wmi *eeepc, | |||
501 | return 0; | 465 | return 0; |
502 | } | 466 | } |
503 | 467 | ||
504 | static void eeepc_unregister_rfkill_notifier(struct eeepc_wmi *eeepc, | 468 | static void asus_unregister_rfkill_notifier(struct asus_wmi *asus, char *node) |
505 | char *node) | ||
506 | { | 469 | { |
507 | acpi_status status = AE_OK; | 470 | acpi_status status = AE_OK; |
508 | acpi_handle handle; | 471 | acpi_handle handle; |
@@ -511,18 +474,18 @@ static void eeepc_unregister_rfkill_notifier(struct eeepc_wmi *eeepc, | |||
511 | 474 | ||
512 | if (ACPI_SUCCESS(status)) { | 475 | if (ACPI_SUCCESS(status)) { |
513 | status = acpi_remove_notify_handler(handle, | 476 | status = acpi_remove_notify_handler(handle, |
514 | ACPI_SYSTEM_NOTIFY, | 477 | ACPI_SYSTEM_NOTIFY, |
515 | eeepc_rfkill_notify); | 478 | asus_rfkill_notify); |
516 | if (ACPI_FAILURE(status)) | 479 | if (ACPI_FAILURE(status)) |
517 | pr_err("Error removing rfkill notify handler %s\n", | 480 | pr_err("Error removing rfkill notify handler %s\n", |
518 | node); | 481 | node); |
519 | } | 482 | } |
520 | } | 483 | } |
521 | 484 | ||
522 | static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot, | 485 | static int asus_get_adapter_status(struct hotplug_slot *hotplug_slot, |
523 | u8 *value) | 486 | u8 *value) |
524 | { | 487 | { |
525 | int result = eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WLAN); | 488 | int result = asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WLAN); |
526 | 489 | ||
527 | if (result < 0) | 490 | if (result < 0) |
528 | return result; | 491 | return result; |
@@ -531,27 +494,27 @@ static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot, | |||
531 | return 0; | 494 | return 0; |
532 | } | 495 | } |
533 | 496 | ||
534 | static void eeepc_cleanup_pci_hotplug(struct hotplug_slot *hotplug_slot) | 497 | static void asus_cleanup_pci_hotplug(struct hotplug_slot *hotplug_slot) |
535 | { | 498 | { |
536 | kfree(hotplug_slot->info); | 499 | kfree(hotplug_slot->info); |
537 | kfree(hotplug_slot); | 500 | kfree(hotplug_slot); |
538 | } | 501 | } |
539 | 502 | ||
540 | static struct hotplug_slot_ops eeepc_hotplug_slot_ops = { | 503 | static struct hotplug_slot_ops asus_hotplug_slot_ops = { |
541 | .owner = THIS_MODULE, | 504 | .owner = THIS_MODULE, |
542 | .get_adapter_status = eeepc_get_adapter_status, | 505 | .get_adapter_status = asus_get_adapter_status, |
543 | .get_power_status = eeepc_get_adapter_status, | 506 | .get_power_status = asus_get_adapter_status, |
544 | }; | 507 | }; |
545 | 508 | ||
546 | static void eeepc_hotplug_work(struct work_struct *work) | 509 | static void asus_hotplug_work(struct work_struct *work) |
547 | { | 510 | { |
548 | struct eeepc_wmi *eeepc; | 511 | struct asus_wmi *asus; |
549 | 512 | ||
550 | eeepc = container_of(work, struct eeepc_wmi, hotplug_work); | 513 | asus = container_of(work, struct asus_wmi, hotplug_work); |
551 | eeepc_rfkill_hotplug(eeepc); | 514 | asus_rfkill_hotplug(asus); |
552 | } | 515 | } |
553 | 516 | ||
554 | static int eeepc_setup_pci_hotplug(struct eeepc_wmi *eeepc) | 517 | static int asus_setup_pci_hotplug(struct asus_wmi *asus) |
555 | { | 518 | { |
556 | int ret = -ENOMEM; | 519 | int ret = -ENOMEM; |
557 | struct pci_bus *bus = pci_find_bus(0, 1); | 520 | struct pci_bus *bus = pci_find_bus(0, 1); |
@@ -561,29 +524,29 @@ static int eeepc_setup_pci_hotplug(struct eeepc_wmi *eeepc) | |||
561 | return -ENODEV; | 524 | return -ENODEV; |
562 | } | 525 | } |
563 | 526 | ||
564 | eeepc->hotplug_workqueue = | 527 | asus->hotplug_workqueue = |
565 | create_singlethread_workqueue("hotplug_workqueue"); | 528 | create_singlethread_workqueue("hotplug_workqueue"); |
566 | if (!eeepc->hotplug_workqueue) | 529 | if (!asus->hotplug_workqueue) |
567 | goto error_workqueue; | 530 | goto error_workqueue; |
568 | 531 | ||
569 | INIT_WORK(&eeepc->hotplug_work, eeepc_hotplug_work); | 532 | INIT_WORK(&asus->hotplug_work, asus_hotplug_work); |
570 | 533 | ||
571 | eeepc->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 534 | asus->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
572 | if (!eeepc->hotplug_slot) | 535 | if (!asus->hotplug_slot) |
573 | goto error_slot; | 536 | goto error_slot; |
574 | 537 | ||
575 | eeepc->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), | 538 | asus->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), |
576 | GFP_KERNEL); | 539 | GFP_KERNEL); |
577 | if (!eeepc->hotplug_slot->info) | 540 | if (!asus->hotplug_slot->info) |
578 | goto error_info; | 541 | goto error_info; |
579 | 542 | ||
580 | eeepc->hotplug_slot->private = eeepc; | 543 | asus->hotplug_slot->private = asus; |
581 | eeepc->hotplug_slot->release = &eeepc_cleanup_pci_hotplug; | 544 | asus->hotplug_slot->release = &asus_cleanup_pci_hotplug; |
582 | eeepc->hotplug_slot->ops = &eeepc_hotplug_slot_ops; | 545 | asus->hotplug_slot->ops = &asus_hotplug_slot_ops; |
583 | eeepc_get_adapter_status(eeepc->hotplug_slot, | 546 | asus_get_adapter_status(asus->hotplug_slot, |
584 | &eeepc->hotplug_slot->info->adapter_status); | 547 | &asus->hotplug_slot->info->adapter_status); |
585 | 548 | ||
586 | ret = pci_hp_register(eeepc->hotplug_slot, bus, 0, "eeepc-wifi"); | 549 | ret = pci_hp_register(asus->hotplug_slot, bus, 0, "asus-wifi"); |
587 | if (ret) { | 550 | if (ret) { |
588 | pr_err("Unable to register hotplug slot - %d\n", ret); | 551 | pr_err("Unable to register hotplug slot - %d\n", ret); |
589 | goto error_register; | 552 | goto error_register; |
@@ -592,12 +555,12 @@ static int eeepc_setup_pci_hotplug(struct eeepc_wmi *eeepc) | |||
592 | return 0; | 555 | return 0; |
593 | 556 | ||
594 | error_register: | 557 | error_register: |
595 | kfree(eeepc->hotplug_slot->info); | 558 | kfree(asus->hotplug_slot->info); |
596 | error_info: | 559 | error_info: |
597 | kfree(eeepc->hotplug_slot); | 560 | kfree(asus->hotplug_slot); |
598 | eeepc->hotplug_slot = NULL; | 561 | asus->hotplug_slot = NULL; |
599 | error_slot: | 562 | error_slot: |
600 | destroy_workqueue(eeepc->hotplug_workqueue); | 563 | destroy_workqueue(asus->hotplug_workqueue); |
601 | error_workqueue: | 564 | error_workqueue: |
602 | return ret; | 565 | return ret; |
603 | } | 566 | } |
@@ -605,13 +568,13 @@ error_workqueue: | |||
605 | /* | 568 | /* |
606 | * Rfkill devices | 569 | * Rfkill devices |
607 | */ | 570 | */ |
608 | static int eeepc_rfkill_set(void *data, bool blocked) | 571 | static int asus_rfkill_set(void *data, bool blocked) |
609 | { | 572 | { |
610 | int dev_id = (unsigned long)data; | 573 | int dev_id = (unsigned long)data; |
611 | u32 ctrl_param = !blocked; | 574 | u32 ctrl_param = !blocked; |
612 | acpi_status status; | 575 | acpi_status status; |
613 | 576 | ||
614 | status = eeepc_wmi_set_devstate(dev_id, ctrl_param, NULL); | 577 | status = asus_wmi_set_devstate(dev_id, ctrl_param, NULL); |
615 | 578 | ||
616 | if (ACPI_FAILURE(status)) | 579 | if (ACPI_FAILURE(status)) |
617 | return -EIO; | 580 | return -EIO; |
@@ -619,68 +582,67 @@ static int eeepc_rfkill_set(void *data, bool blocked) | |||
619 | return 0; | 582 | return 0; |
620 | } | 583 | } |
621 | 584 | ||
622 | static void eeepc_rfkill_query(struct rfkill *rfkill, void *data) | 585 | static void asus_rfkill_query(struct rfkill *rfkill, void *data) |
623 | { | 586 | { |
624 | int dev_id = (unsigned long)data; | 587 | int dev_id = (unsigned long)data; |
625 | int result; | 588 | int result; |
626 | 589 | ||
627 | result = eeepc_wmi_get_devstate_simple(dev_id); | 590 | result = asus_wmi_get_devstate_simple(dev_id); |
628 | 591 | ||
629 | if (result < 0) | 592 | if (result < 0) |
630 | return ; | 593 | return; |
631 | 594 | ||
632 | rfkill_set_sw_state(rfkill, !result); | 595 | rfkill_set_sw_state(rfkill, !result); |
633 | } | 596 | } |
634 | 597 | ||
635 | static int eeepc_rfkill_wlan_set(void *data, bool blocked) | 598 | static int asus_rfkill_wlan_set(void *data, bool blocked) |
636 | { | 599 | { |
637 | struct eeepc_wmi *eeepc = data; | 600 | struct asus_wmi *asus = data; |
638 | int ret; | 601 | int ret; |
639 | 602 | ||
640 | /* | 603 | /* |
641 | * This handler is enabled only if hotplug is enabled. | 604 | * This handler is enabled only if hotplug is enabled. |
642 | * In this case, the eeepc_wmi_set_devstate() will | 605 | * In this case, the asus_wmi_set_devstate() will |
643 | * trigger a wmi notification and we need to wait | 606 | * trigger a wmi notification and we need to wait |
644 | * this call to finish before being able to call | 607 | * this call to finish before being able to call |
645 | * any wmi method | 608 | * any wmi method |
646 | */ | 609 | */ |
647 | mutex_lock(&eeepc->wmi_lock); | 610 | mutex_lock(&asus->wmi_lock); |
648 | ret = eeepc_rfkill_set((void *)(long)EEEPC_WMI_DEVID_WLAN, blocked); | 611 | ret = asus_rfkill_set((void *)(long)ASUS_WMI_DEVID_WLAN, blocked); |
649 | mutex_unlock(&eeepc->wmi_lock); | 612 | mutex_unlock(&asus->wmi_lock); |
650 | return ret; | 613 | return ret; |
651 | } | 614 | } |
652 | 615 | ||
653 | static void eeepc_rfkill_wlan_query(struct rfkill *rfkill, void *data) | 616 | static void asus_rfkill_wlan_query(struct rfkill *rfkill, void *data) |
654 | { | 617 | { |
655 | eeepc_rfkill_query(rfkill, (void *)(long)EEEPC_WMI_DEVID_WLAN); | 618 | asus_rfkill_query(rfkill, (void *)(long)ASUS_WMI_DEVID_WLAN); |
656 | } | 619 | } |
657 | 620 | ||
658 | static const struct rfkill_ops eeepc_rfkill_wlan_ops = { | 621 | static const struct rfkill_ops asus_rfkill_wlan_ops = { |
659 | .set_block = eeepc_rfkill_wlan_set, | 622 | .set_block = asus_rfkill_wlan_set, |
660 | .query = eeepc_rfkill_wlan_query, | 623 | .query = asus_rfkill_wlan_query, |
661 | }; | 624 | }; |
662 | 625 | ||
663 | static const struct rfkill_ops eeepc_rfkill_ops = { | 626 | static const struct rfkill_ops asus_rfkill_ops = { |
664 | .set_block = eeepc_rfkill_set, | 627 | .set_block = asus_rfkill_set, |
665 | .query = eeepc_rfkill_query, | 628 | .query = asus_rfkill_query, |
666 | }; | 629 | }; |
667 | 630 | ||
668 | static int eeepc_new_rfkill(struct eeepc_wmi *eeepc, | 631 | static int asus_new_rfkill(struct asus_wmi *asus, |
669 | struct rfkill **rfkill, | 632 | struct rfkill **rfkill, |
670 | const char *name, | 633 | const char *name, enum rfkill_type type, int dev_id) |
671 | enum rfkill_type type, int dev_id) | ||
672 | { | 634 | { |
673 | int result = eeepc_wmi_get_devstate_simple(dev_id); | 635 | int result = asus_wmi_get_devstate_simple(dev_id); |
674 | 636 | ||
675 | if (result < 0) | 637 | if (result < 0) |
676 | return result; | 638 | return result; |
677 | 639 | ||
678 | if (dev_id == EEEPC_WMI_DEVID_WLAN && eeepc->hotplug_wireless) | 640 | if (dev_id == ASUS_WMI_DEVID_WLAN && asus->driver->hotplug_wireless) |
679 | *rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type, | 641 | *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, |
680 | &eeepc_rfkill_wlan_ops, eeepc); | 642 | &asus_rfkill_wlan_ops, asus); |
681 | else | 643 | else |
682 | *rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type, | 644 | *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, |
683 | &eeepc_rfkill_ops, (void *)(long)dev_id); | 645 | &asus_rfkill_ops, (void *)(long)dev_id); |
684 | 646 | ||
685 | if (!*rfkill) | 647 | if (!*rfkill) |
686 | return -EINVAL; | 648 | return -EINVAL; |
@@ -695,82 +657,82 @@ static int eeepc_new_rfkill(struct eeepc_wmi *eeepc, | |||
695 | return 0; | 657 | return 0; |
696 | } | 658 | } |
697 | 659 | ||
698 | static void eeepc_wmi_rfkill_exit(struct eeepc_wmi *eeepc) | 660 | static void asus_wmi_rfkill_exit(struct asus_wmi *asus) |
699 | { | 661 | { |
700 | eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); | 662 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); |
701 | eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); | 663 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); |
702 | eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); | 664 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); |
703 | if (eeepc->wlan_rfkill) { | 665 | if (asus->wlan_rfkill) { |
704 | rfkill_unregister(eeepc->wlan_rfkill); | 666 | rfkill_unregister(asus->wlan_rfkill); |
705 | rfkill_destroy(eeepc->wlan_rfkill); | 667 | rfkill_destroy(asus->wlan_rfkill); |
706 | eeepc->wlan_rfkill = NULL; | 668 | asus->wlan_rfkill = NULL; |
707 | } | 669 | } |
708 | /* | 670 | /* |
709 | * Refresh pci hotplug in case the rfkill state was changed after | 671 | * Refresh pci hotplug in case the rfkill state was changed after |
710 | * eeepc_unregister_rfkill_notifier() | 672 | * asus_unregister_rfkill_notifier() |
711 | */ | 673 | */ |
712 | eeepc_rfkill_hotplug(eeepc); | 674 | asus_rfkill_hotplug(asus); |
713 | if (eeepc->hotplug_slot) | 675 | if (asus->hotplug_slot) |
714 | pci_hp_deregister(eeepc->hotplug_slot); | 676 | pci_hp_deregister(asus->hotplug_slot); |
715 | if (eeepc->hotplug_workqueue) | 677 | if (asus->hotplug_workqueue) |
716 | destroy_workqueue(eeepc->hotplug_workqueue); | 678 | destroy_workqueue(asus->hotplug_workqueue); |
717 | 679 | ||
718 | if (eeepc->bluetooth_rfkill) { | 680 | if (asus->bluetooth_rfkill) { |
719 | rfkill_unregister(eeepc->bluetooth_rfkill); | 681 | rfkill_unregister(asus->bluetooth_rfkill); |
720 | rfkill_destroy(eeepc->bluetooth_rfkill); | 682 | rfkill_destroy(asus->bluetooth_rfkill); |
721 | eeepc->bluetooth_rfkill = NULL; | 683 | asus->bluetooth_rfkill = NULL; |
722 | } | 684 | } |
723 | if (eeepc->wimax_rfkill) { | 685 | if (asus->wimax_rfkill) { |
724 | rfkill_unregister(eeepc->wimax_rfkill); | 686 | rfkill_unregister(asus->wimax_rfkill); |
725 | rfkill_destroy(eeepc->wimax_rfkill); | 687 | rfkill_destroy(asus->wimax_rfkill); |
726 | eeepc->wimax_rfkill = NULL; | 688 | asus->wimax_rfkill = NULL; |
727 | } | 689 | } |
728 | if (eeepc->wwan3g_rfkill) { | 690 | if (asus->wwan3g_rfkill) { |
729 | rfkill_unregister(eeepc->wwan3g_rfkill); | 691 | rfkill_unregister(asus->wwan3g_rfkill); |
730 | rfkill_destroy(eeepc->wwan3g_rfkill); | 692 | rfkill_destroy(asus->wwan3g_rfkill); |
731 | eeepc->wwan3g_rfkill = NULL; | 693 | asus->wwan3g_rfkill = NULL; |
732 | } | 694 | } |
733 | } | 695 | } |
734 | 696 | ||
735 | static int eeepc_wmi_rfkill_init(struct eeepc_wmi *eeepc) | 697 | static int asus_wmi_rfkill_init(struct asus_wmi *asus) |
736 | { | 698 | { |
737 | int result = 0; | 699 | int result = 0; |
738 | 700 | ||
739 | mutex_init(&eeepc->hotplug_lock); | 701 | mutex_init(&asus->hotplug_lock); |
740 | mutex_init(&eeepc->wmi_lock); | 702 | mutex_init(&asus->wmi_lock); |
741 | 703 | ||
742 | result = eeepc_new_rfkill(eeepc, &eeepc->wlan_rfkill, | 704 | result = asus_new_rfkill(asus, &asus->wlan_rfkill, |
743 | "eeepc-wlan", RFKILL_TYPE_WLAN, | 705 | "asus-wlan", RFKILL_TYPE_WLAN, |
744 | EEEPC_WMI_DEVID_WLAN); | 706 | ASUS_WMI_DEVID_WLAN); |
745 | 707 | ||
746 | if (result && result != -ENODEV) | 708 | if (result && result != -ENODEV) |
747 | goto exit; | 709 | goto exit; |
748 | 710 | ||
749 | result = eeepc_new_rfkill(eeepc, &eeepc->bluetooth_rfkill, | 711 | result = asus_new_rfkill(asus, &asus->bluetooth_rfkill, |
750 | "eeepc-bluetooth", RFKILL_TYPE_BLUETOOTH, | 712 | "asus-bluetooth", RFKILL_TYPE_BLUETOOTH, |
751 | EEEPC_WMI_DEVID_BLUETOOTH); | 713 | ASUS_WMI_DEVID_BLUETOOTH); |
752 | 714 | ||
753 | if (result && result != -ENODEV) | 715 | if (result && result != -ENODEV) |
754 | goto exit; | 716 | goto exit; |
755 | 717 | ||
756 | result = eeepc_new_rfkill(eeepc, &eeepc->wimax_rfkill, | 718 | result = asus_new_rfkill(asus, &asus->wimax_rfkill, |
757 | "eeepc-wimax", RFKILL_TYPE_WIMAX, | 719 | "asus-wimax", RFKILL_TYPE_WIMAX, |
758 | EEEPC_WMI_DEVID_WIMAX); | 720 | ASUS_WMI_DEVID_WIMAX); |
759 | 721 | ||
760 | if (result && result != -ENODEV) | 722 | if (result && result != -ENODEV) |
761 | goto exit; | 723 | goto exit; |
762 | 724 | ||
763 | result = eeepc_new_rfkill(eeepc, &eeepc->wwan3g_rfkill, | 725 | result = asus_new_rfkill(asus, &asus->wwan3g_rfkill, |
764 | "eeepc-wwan3g", RFKILL_TYPE_WWAN, | 726 | "asus-wwan3g", RFKILL_TYPE_WWAN, |
765 | EEEPC_WMI_DEVID_WWAN3G); | 727 | ASUS_WMI_DEVID_WWAN3G); |
766 | 728 | ||
767 | if (result && result != -ENODEV) | 729 | if (result && result != -ENODEV) |
768 | goto exit; | 730 | goto exit; |
769 | 731 | ||
770 | if (!eeepc->hotplug_wireless) | 732 | if (!asus->driver->hotplug_wireless) |
771 | goto exit; | 733 | goto exit; |
772 | 734 | ||
773 | result = eeepc_setup_pci_hotplug(eeepc); | 735 | result = asus_setup_pci_hotplug(asus); |
774 | /* | 736 | /* |
775 | * If we get -EBUSY then something else is handling the PCI hotplug - | 737 | * If we get -EBUSY then something else is handling the PCI hotplug - |
776 | * don't fail in this case | 738 | * don't fail in this case |
@@ -778,18 +740,18 @@ static int eeepc_wmi_rfkill_init(struct eeepc_wmi *eeepc) | |||
778 | if (result == -EBUSY) | 740 | if (result == -EBUSY) |
779 | result = 0; | 741 | result = 0; |
780 | 742 | ||
781 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); | 743 | asus_register_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); |
782 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); | 744 | asus_register_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); |
783 | eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); | 745 | asus_register_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); |
784 | /* | 746 | /* |
785 | * Refresh pci hotplug in case the rfkill state was changed during | 747 | * Refresh pci hotplug in case the rfkill state was changed during |
786 | * setup. | 748 | * setup. |
787 | */ | 749 | */ |
788 | eeepc_rfkill_hotplug(eeepc); | 750 | asus_rfkill_hotplug(asus); |
789 | 751 | ||
790 | exit: | 752 | exit: |
791 | if (result && result != -ENODEV) | 753 | if (result && result != -ENODEV) |
792 | eeepc_wmi_rfkill_exit(eeepc); | 754 | asus_wmi_rfkill_exit(asus); |
793 | 755 | ||
794 | if (result == -ENODEV) | 756 | if (result == -ENODEV) |
795 | result = 0; | 757 | result = 0; |
@@ -802,7 +764,7 @@ exit: | |||
802 | */ | 764 | */ |
803 | static int read_backlight_power(void) | 765 | static int read_backlight_power(void) |
804 | { | 766 | { |
805 | int ret = eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_BACKLIGHT); | 767 | int ret = asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_BACKLIGHT); |
806 | 768 | ||
807 | if (ret < 0) | 769 | if (ret < 0) |
808 | return ret; | 770 | return ret; |
@@ -815,12 +777,12 @@ static int read_brightness(struct backlight_device *bd) | |||
815 | u32 retval; | 777 | u32 retval; |
816 | acpi_status status; | 778 | acpi_status status; |
817 | 779 | ||
818 | status = eeepc_wmi_get_devstate(EEEPC_WMI_DEVID_BRIGHTNESS, &retval); | 780 | status = asus_wmi_get_devstate(ASUS_WMI_DEVID_BRIGHTNESS, &retval); |
819 | 781 | ||
820 | if (ACPI_FAILURE(status)) | 782 | if (ACPI_FAILURE(status)) |
821 | return -EIO; | 783 | return -EIO; |
822 | else | 784 | else |
823 | return retval & EEEPC_WMI_DSTS_BRIGHTNESS_MASK; | 785 | return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK; |
824 | } | 786 | } |
825 | 787 | ||
826 | static int update_bl_status(struct backlight_device *bd) | 788 | static int update_bl_status(struct backlight_device *bd) |
@@ -831,8 +793,8 @@ static int update_bl_status(struct backlight_device *bd) | |||
831 | 793 | ||
832 | ctrl_param = bd->props.brightness; | 794 | ctrl_param = bd->props.brightness; |
833 | 795 | ||
834 | status = eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_BRIGHTNESS, | 796 | status = asus_wmi_set_devstate(ASUS_WMI_DEVID_BRIGHTNESS, |
835 | ctrl_param, NULL); | 797 | ctrl_param, NULL); |
836 | 798 | ||
837 | if (ACPI_FAILURE(status)) | 799 | if (ACPI_FAILURE(status)) |
838 | return -EIO; | 800 | return -EIO; |
@@ -840,8 +802,8 @@ static int update_bl_status(struct backlight_device *bd) | |||
840 | power = read_backlight_power(); | 802 | power = read_backlight_power(); |
841 | if (power != -ENODEV && bd->props.power != power) { | 803 | if (power != -ENODEV && bd->props.power != power) { |
842 | ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK); | 804 | ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK); |
843 | status = eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_BACKLIGHT, | 805 | status = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, |
844 | ctrl_param, NULL); | 806 | ctrl_param, NULL); |
845 | 807 | ||
846 | if (ACPI_FAILURE(status)) | 808 | if (ACPI_FAILURE(status)) |
847 | return -EIO; | 809 | return -EIO; |
@@ -849,14 +811,14 @@ static int update_bl_status(struct backlight_device *bd) | |||
849 | return 0; | 811 | return 0; |
850 | } | 812 | } |
851 | 813 | ||
852 | static const struct backlight_ops eeepc_wmi_bl_ops = { | 814 | static const struct backlight_ops asus_wmi_bl_ops = { |
853 | .get_brightness = read_brightness, | 815 | .get_brightness = read_brightness, |
854 | .update_status = update_bl_status, | 816 | .update_status = update_bl_status, |
855 | }; | 817 | }; |
856 | 818 | ||
857 | static int eeepc_wmi_backlight_notify(struct eeepc_wmi *eeepc, int code) | 819 | static int asus_wmi_backlight_notify(struct asus_wmi *asus, int code) |
858 | { | 820 | { |
859 | struct backlight_device *bd = eeepc->backlight_device; | 821 | struct backlight_device *bd = asus->backlight_device; |
860 | int old = bd->props.brightness; | 822 | int old = bd->props.brightness; |
861 | int new = old; | 823 | int new = old; |
862 | 824 | ||
@@ -872,15 +834,15 @@ static int eeepc_wmi_backlight_notify(struct eeepc_wmi *eeepc, int code) | |||
872 | return old; | 834 | return old; |
873 | } | 835 | } |
874 | 836 | ||
875 | static int eeepc_wmi_backlight_init(struct eeepc_wmi *eeepc) | 837 | static int asus_wmi_backlight_init(struct asus_wmi *asus) |
876 | { | 838 | { |
877 | struct backlight_device *bd; | 839 | struct backlight_device *bd; |
878 | struct backlight_properties props; | 840 | struct backlight_properties props; |
879 | int max; | 841 | int max; |
880 | int power; | 842 | int power; |
881 | 843 | ||
882 | max = eeepc_wmi_get_devstate_bits(EEEPC_WMI_DEVID_BRIGHTNESS, | 844 | max = asus_wmi_get_devstate_bits(ASUS_WMI_DEVID_BRIGHTNESS, |
883 | EEEPC_WMI_DSTS_MAX_BRIGTH_MASK); | 845 | ASUS_WMI_DSTS_MAX_BRIGTH_MASK); |
884 | power = read_backlight_power(); | 846 | power = read_backlight_power(); |
885 | 847 | ||
886 | if (max < 0 && power < 0) { | 848 | if (max < 0 && power < 0) { |
@@ -899,15 +861,15 @@ static int eeepc_wmi_backlight_init(struct eeepc_wmi *eeepc) | |||
899 | 861 | ||
900 | memset(&props, 0, sizeof(struct backlight_properties)); | 862 | memset(&props, 0, sizeof(struct backlight_properties)); |
901 | props.max_brightness = max; | 863 | props.max_brightness = max; |
902 | bd = backlight_device_register(EEEPC_WMI_FILE, | 864 | bd = backlight_device_register(asus->driver->name, |
903 | &eeepc->platform_device->dev, eeepc, | 865 | &asus->platform_device->dev, asus, |
904 | &eeepc_wmi_bl_ops, &props); | 866 | &asus_wmi_bl_ops, &props); |
905 | if (IS_ERR(bd)) { | 867 | if (IS_ERR(bd)) { |
906 | pr_err("Could not register backlight device\n"); | 868 | pr_err("Could not register backlight device\n"); |
907 | return PTR_ERR(bd); | 869 | return PTR_ERR(bd); |
908 | } | 870 | } |
909 | 871 | ||
910 | eeepc->backlight_device = bd; | 872 | asus->backlight_device = bd; |
911 | 873 | ||
912 | bd->props.brightness = read_brightness(bd); | 874 | bd->props.brightness = read_brightness(bd); |
913 | bd->props.power = power; | 875 | bd->props.power = power; |
@@ -916,17 +878,17 @@ static int eeepc_wmi_backlight_init(struct eeepc_wmi *eeepc) | |||
916 | return 0; | 878 | return 0; |
917 | } | 879 | } |
918 | 880 | ||
919 | static void eeepc_wmi_backlight_exit(struct eeepc_wmi *eeepc) | 881 | static void asus_wmi_backlight_exit(struct asus_wmi *asus) |
920 | { | 882 | { |
921 | if (eeepc->backlight_device) | 883 | if (asus->backlight_device) |
922 | backlight_device_unregister(eeepc->backlight_device); | 884 | backlight_device_unregister(asus->backlight_device); |
923 | 885 | ||
924 | eeepc->backlight_device = NULL; | 886 | asus->backlight_device = NULL; |
925 | } | 887 | } |
926 | 888 | ||
927 | static void eeepc_wmi_notify(u32 value, void *context) | 889 | static void asus_wmi_notify(u32 value, void *context) |
928 | { | 890 | { |
929 | struct eeepc_wmi *eeepc = context; | 891 | struct asus_wmi *asus = context; |
930 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; | 892 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; |
931 | union acpi_object *obj; | 893 | union acpi_object *obj; |
932 | acpi_status status; | 894 | acpi_status status; |
@@ -953,11 +915,10 @@ static void eeepc_wmi_notify(u32 value, void *context) | |||
953 | 915 | ||
954 | if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) { | 916 | if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) { |
955 | if (!acpi_video_backlight_support()) | 917 | if (!acpi_video_backlight_support()) |
956 | eeepc_wmi_backlight_notify(eeepc, orig_code); | 918 | asus_wmi_backlight_notify(asus, orig_code); |
957 | } | 919 | } |
958 | 920 | ||
959 | if (!sparse_keymap_report_event(eeepc->inputdev, | 921 | if (!sparse_keymap_report_event(asus->inputdev, code, 1, true)) |
960 | code, 1, true)) | ||
961 | pr_info("Unknown key %x pressed\n", code); | 922 | pr_info("Unknown key %x pressed\n", code); |
962 | } | 923 | } |
963 | 924 | ||
@@ -982,12 +943,12 @@ static ssize_t store_sys_wmi(int devid, const char *buf, size_t count) | |||
982 | u32 retval; | 943 | u32 retval; |
983 | int rv, value; | 944 | int rv, value; |
984 | 945 | ||
985 | value = eeepc_wmi_get_devstate_simple(devid); | 946 | value = asus_wmi_get_devstate_simple(devid); |
986 | if (value == -ENODEV) /* Check device presence */ | 947 | if (value == -ENODEV) /* Check device presence */ |
987 | return value; | 948 | return value; |
988 | 949 | ||
989 | rv = parse_arg(buf, count, &value); | 950 | rv = parse_arg(buf, count, &value); |
990 | status = eeepc_wmi_set_devstate(devid, value, &retval); | 951 | status = asus_wmi_set_devstate(devid, value, &retval); |
991 | 952 | ||
992 | if (ACPI_FAILURE(status)) | 953 | if (ACPI_FAILURE(status)) |
993 | return -EIO; | 954 | return -EIO; |
@@ -996,7 +957,7 @@ static ssize_t store_sys_wmi(int devid, const char *buf, size_t count) | |||
996 | 957 | ||
997 | static ssize_t show_sys_wmi(int devid, char *buf) | 958 | static ssize_t show_sys_wmi(int devid, char *buf) |
998 | { | 959 | { |
999 | int value = eeepc_wmi_get_devstate_simple(devid); | 960 | int value = asus_wmi_get_devstate_simple(devid); |
1000 | 961 | ||
1001 | if (value < 0) | 962 | if (value < 0) |
1002 | return value; | 963 | return value; |
@@ -1004,7 +965,7 @@ static ssize_t show_sys_wmi(int devid, char *buf) | |||
1004 | return sprintf(buf, "%d\n", value); | 965 | return sprintf(buf, "%d\n", value); |
1005 | } | 966 | } |
1006 | 967 | ||
1007 | #define EEEPC_WMI_CREATE_DEVICE_ATTR(_name, _mode, _cm) \ | 968 | #define ASUS_WMI_CREATE_DEVICE_ATTR(_name, _mode, _cm) \ |
1008 | static ssize_t show_##_name(struct device *dev, \ | 969 | static ssize_t show_##_name(struct device *dev, \ |
1009 | struct device_attribute *attr, \ | 970 | struct device_attribute *attr, \ |
1010 | char *buf) \ | 971 | char *buf) \ |
@@ -1025,15 +986,15 @@ static ssize_t show_sys_wmi(int devid, char *buf) | |||
1025 | .store = store_##_name, \ | 986 | .store = store_##_name, \ |
1026 | } | 987 | } |
1027 | 988 | ||
1028 | EEEPC_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, EEEPC_WMI_DEVID_TOUCHPAD); | 989 | ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD); |
1029 | EEEPC_WMI_CREATE_DEVICE_ATTR(camera, 0644, EEEPC_WMI_DEVID_CAMERA); | 990 | ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA); |
1030 | EEEPC_WMI_CREATE_DEVICE_ATTR(cardr, 0644, EEEPC_WMI_DEVID_CARDREADER); | 991 | ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER); |
1031 | 992 | ||
1032 | static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr, | 993 | static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr, |
1033 | const char *buf, size_t count) | 994 | const char *buf, size_t count) |
1034 | { | 995 | { |
1035 | int value; | 996 | int value; |
1036 | struct acpi_buffer input = { (acpi_size)sizeof(value), &value }; | 997 | struct acpi_buffer input = { (acpi_size) sizeof(value), &value }; |
1037 | acpi_status status; | 998 | acpi_status status; |
1038 | 999 | ||
1039 | if (!count || sscanf(buf, "%i", &value) != 1) | 1000 | if (!count || sscanf(buf, "%i", &value) != 1) |
@@ -1041,8 +1002,8 @@ static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr, | |||
1041 | if (value < 0 || value > 2) | 1002 | if (value < 0 || value > 2) |
1042 | return -EINVAL; | 1003 | return -EINVAL; |
1043 | 1004 | ||
1044 | status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID, | 1005 | status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, |
1045 | 1, EEEPC_WMI_METHODID_CFVS, &input, NULL); | 1006 | 1, ASUS_WMI_METHODID_CFVS, &input, NULL); |
1046 | 1007 | ||
1047 | if (ACPI_FAILURE(status)) | 1008 | if (ACPI_FAILURE(status)) |
1048 | return -EIO; | 1009 | return -EIO; |
@@ -1060,37 +1021,36 @@ static struct attribute *platform_attributes[] = { | |||
1060 | NULL | 1021 | NULL |
1061 | }; | 1022 | }; |
1062 | 1023 | ||
1063 | static mode_t eeepc_sysfs_is_visible(struct kobject *kobj, | 1024 | static mode_t asus_sysfs_is_visible(struct kobject *kobj, |
1064 | struct attribute *attr, | 1025 | struct attribute *attr, int idx) |
1065 | int idx) | ||
1066 | { | 1026 | { |
1067 | bool supported = true; | 1027 | bool supported = true; |
1068 | int devid = -1; | 1028 | int devid = -1; |
1069 | 1029 | ||
1070 | if (attr == &dev_attr_camera.attr) | 1030 | if (attr == &dev_attr_camera.attr) |
1071 | devid = EEEPC_WMI_DEVID_CAMERA; | 1031 | devid = ASUS_WMI_DEVID_CAMERA; |
1072 | else if (attr == &dev_attr_cardr.attr) | 1032 | else if (attr == &dev_attr_cardr.attr) |
1073 | devid = EEEPC_WMI_DEVID_CARDREADER; | 1033 | devid = ASUS_WMI_DEVID_CARDREADER; |
1074 | else if (attr == &dev_attr_touchpad.attr) | 1034 | else if (attr == &dev_attr_touchpad.attr) |
1075 | devid = EEEPC_WMI_DEVID_TOUCHPAD; | 1035 | devid = ASUS_WMI_DEVID_TOUCHPAD; |
1076 | 1036 | ||
1077 | if (devid != -1) | 1037 | if (devid != -1) |
1078 | supported = eeepc_wmi_get_devstate_simple(devid) != -ENODEV; | 1038 | supported = asus_wmi_get_devstate_simple(devid) != -ENODEV; |
1079 | 1039 | ||
1080 | return supported ? attr->mode : 0; | 1040 | return supported ? attr->mode : 0; |
1081 | } | 1041 | } |
1082 | 1042 | ||
1083 | static struct attribute_group platform_attribute_group = { | 1043 | static struct attribute_group platform_attribute_group = { |
1084 | .is_visible = eeepc_sysfs_is_visible, | 1044 | .is_visible = asus_sysfs_is_visible, |
1085 | .attrs = platform_attributes | 1045 | .attrs = platform_attributes |
1086 | }; | 1046 | }; |
1087 | 1047 | ||
1088 | static void eeepc_wmi_sysfs_exit(struct platform_device *device) | 1048 | static void asus_wmi_sysfs_exit(struct platform_device *device) |
1089 | { | 1049 | { |
1090 | sysfs_remove_group(&device->dev.kobj, &platform_attribute_group); | 1050 | sysfs_remove_group(&device->dev.kobj, &platform_attribute_group); |
1091 | } | 1051 | } |
1092 | 1052 | ||
1093 | static int eeepc_wmi_sysfs_init(struct platform_device *device) | 1053 | static int asus_wmi_sysfs_init(struct platform_device *device) |
1094 | { | 1054 | { |
1095 | return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); | 1055 | return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); |
1096 | } | 1056 | } |
@@ -1098,111 +1058,111 @@ static int eeepc_wmi_sysfs_init(struct platform_device *device) | |||
1098 | /* | 1058 | /* |
1099 | * Platform device | 1059 | * Platform device |
1100 | */ | 1060 | */ |
1101 | static int __init eeepc_wmi_platform_init(struct eeepc_wmi *eeepc) | 1061 | static int __init asus_wmi_platform_init(struct asus_wmi *asus) |
1102 | { | 1062 | { |
1103 | return eeepc_wmi_sysfs_init(eeepc->platform_device); | 1063 | return asus_wmi_sysfs_init(asus->platform_device); |
1104 | } | 1064 | } |
1105 | 1065 | ||
1106 | static void eeepc_wmi_platform_exit(struct eeepc_wmi *eeepc) | 1066 | static void asus_wmi_platform_exit(struct asus_wmi *asus) |
1107 | { | 1067 | { |
1108 | eeepc_wmi_sysfs_exit(eeepc->platform_device); | 1068 | asus_wmi_sysfs_exit(asus->platform_device); |
1109 | } | 1069 | } |
1110 | 1070 | ||
1111 | /* | 1071 | /* |
1112 | * debugfs | 1072 | * debugfs |
1113 | */ | 1073 | */ |
1114 | struct eeepc_wmi_debugfs_node { | 1074 | struct asus_wmi_debugfs_node { |
1115 | struct eeepc_wmi *eeepc; | 1075 | struct asus_wmi *asus; |
1116 | char *name; | 1076 | char *name; |
1117 | int (*show)(struct seq_file *m, void *data); | 1077 | int (*show) (struct seq_file *m, void *data); |
1118 | }; | 1078 | }; |
1119 | 1079 | ||
1120 | static int show_dsts(struct seq_file *m, void *data) | 1080 | static int show_dsts(struct seq_file *m, void *data) |
1121 | { | 1081 | { |
1122 | struct eeepc_wmi *eeepc = m->private; | 1082 | struct asus_wmi *asus = m->private; |
1123 | acpi_status status; | 1083 | acpi_status status; |
1124 | u32 retval = -1; | 1084 | u32 retval = -1; |
1125 | 1085 | ||
1126 | status = eeepc_wmi_get_devstate(eeepc->debug.dev_id, &retval); | 1086 | status = asus_wmi_get_devstate(asus->debug.dev_id, &retval); |
1127 | 1087 | ||
1128 | if (ACPI_FAILURE(status)) | 1088 | if (ACPI_FAILURE(status)) |
1129 | return -EIO; | 1089 | return -EIO; |
1130 | 1090 | ||
1131 | seq_printf(m, "DSTS(%x) = %x\n", eeepc->debug.dev_id, retval); | 1091 | seq_printf(m, "DSTS(%x) = %x\n", asus->debug.dev_id, retval); |
1132 | 1092 | ||
1133 | return 0; | 1093 | return 0; |
1134 | } | 1094 | } |
1135 | 1095 | ||
1136 | static int show_devs(struct seq_file *m, void *data) | 1096 | static int show_devs(struct seq_file *m, void *data) |
1137 | { | 1097 | { |
1138 | struct eeepc_wmi *eeepc = m->private; | 1098 | struct asus_wmi *asus = m->private; |
1139 | acpi_status status; | 1099 | acpi_status status; |
1140 | u32 retval = -1; | 1100 | u32 retval = -1; |
1141 | 1101 | ||
1142 | status = eeepc_wmi_set_devstate(eeepc->debug.dev_id, | 1102 | status = asus_wmi_set_devstate(asus->debug.dev_id, |
1143 | eeepc->debug.ctrl_param, &retval); | 1103 | asus->debug.ctrl_param, &retval); |
1144 | if (ACPI_FAILURE(status)) | 1104 | if (ACPI_FAILURE(status)) |
1145 | return -EIO; | 1105 | return -EIO; |
1146 | 1106 | ||
1147 | seq_printf(m, "DEVS(%x, %x) = %x\n", eeepc->debug.dev_id, | 1107 | seq_printf(m, "DEVS(%x, %x) = %x\n", asus->debug.dev_id, |
1148 | eeepc->debug.ctrl_param, retval); | 1108 | asus->debug.ctrl_param, retval); |
1149 | 1109 | ||
1150 | return 0; | 1110 | return 0; |
1151 | } | 1111 | } |
1152 | 1112 | ||
1153 | static struct eeepc_wmi_debugfs_node eeepc_wmi_debug_files[] = { | 1113 | static struct asus_wmi_debugfs_node asus_wmi_debug_files[] = { |
1154 | { NULL, "devs", show_devs }, | 1114 | {NULL, "devs", show_devs}, |
1155 | { NULL, "dsts", show_dsts }, | 1115 | {NULL, "dsts", show_dsts}, |
1156 | }; | 1116 | }; |
1157 | 1117 | ||
1158 | static int eeepc_wmi_debugfs_open(struct inode *inode, struct file *file) | 1118 | static int asus_wmi_debugfs_open(struct inode *inode, struct file *file) |
1159 | { | 1119 | { |
1160 | struct eeepc_wmi_debugfs_node *node = inode->i_private; | 1120 | struct asus_wmi_debugfs_node *node = inode->i_private; |
1161 | 1121 | ||
1162 | return single_open(file, node->show, node->eeepc); | 1122 | return single_open(file, node->show, node->asus); |
1163 | } | 1123 | } |
1164 | 1124 | ||
1165 | static const struct file_operations eeepc_wmi_debugfs_io_ops = { | 1125 | static const struct file_operations asus_wmi_debugfs_io_ops = { |
1166 | .owner = THIS_MODULE, | 1126 | .owner = THIS_MODULE, |
1167 | .open = eeepc_wmi_debugfs_open, | 1127 | .open = asus_wmi_debugfs_open, |
1168 | .read = seq_read, | 1128 | .read = seq_read, |
1169 | .llseek = seq_lseek, | 1129 | .llseek = seq_lseek, |
1170 | .release = single_release, | 1130 | .release = single_release, |
1171 | }; | 1131 | }; |
1172 | 1132 | ||
1173 | static void eeepc_wmi_debugfs_exit(struct eeepc_wmi *eeepc) | 1133 | static void asus_wmi_debugfs_exit(struct asus_wmi *asus) |
1174 | { | 1134 | { |
1175 | debugfs_remove_recursive(eeepc->debug.root); | 1135 | debugfs_remove_recursive(asus->debug.root); |
1176 | } | 1136 | } |
1177 | 1137 | ||
1178 | static int eeepc_wmi_debugfs_init(struct eeepc_wmi *eeepc) | 1138 | static int asus_wmi_debugfs_init(struct asus_wmi *asus) |
1179 | { | 1139 | { |
1180 | struct dentry *dent; | 1140 | struct dentry *dent; |
1181 | int i; | 1141 | int i; |
1182 | 1142 | ||
1183 | eeepc->debug.root = debugfs_create_dir(EEEPC_WMI_FILE, NULL); | 1143 | asus->debug.root = debugfs_create_dir(asus->driver->name, NULL); |
1184 | if (!eeepc->debug.root) { | 1144 | if (!asus->debug.root) { |
1185 | pr_err("failed to create debugfs directory"); | 1145 | pr_err("failed to create debugfs directory"); |
1186 | goto error_debugfs; | 1146 | goto error_debugfs; |
1187 | } | 1147 | } |
1188 | 1148 | ||
1189 | dent = debugfs_create_x32("dev_id", S_IRUGO|S_IWUSR, | 1149 | dent = debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, |
1190 | eeepc->debug.root, &eeepc->debug.dev_id); | 1150 | asus->debug.root, &asus->debug.dev_id); |
1191 | if (!dent) | 1151 | if (!dent) |
1192 | goto error_debugfs; | 1152 | goto error_debugfs; |
1193 | 1153 | ||
1194 | dent = debugfs_create_x32("ctrl_param", S_IRUGO|S_IWUSR, | 1154 | dent = debugfs_create_x32("ctrl_param", S_IRUGO | S_IWUSR, |
1195 | eeepc->debug.root, &eeepc->debug.ctrl_param); | 1155 | asus->debug.root, &asus->debug.ctrl_param); |
1196 | if (!dent) | 1156 | if (!dent) |
1197 | goto error_debugfs; | 1157 | goto error_debugfs; |
1198 | 1158 | ||
1199 | for (i = 0; i < ARRAY_SIZE(eeepc_wmi_debug_files); i++) { | 1159 | for (i = 0; i < ARRAY_SIZE(asus_wmi_debug_files); i++) { |
1200 | struct eeepc_wmi_debugfs_node *node = &eeepc_wmi_debug_files[i]; | 1160 | struct asus_wmi_debugfs_node *node = &asus_wmi_debug_files[i]; |
1201 | 1161 | ||
1202 | node->eeepc = eeepc; | 1162 | node->asus = asus; |
1203 | dent = debugfs_create_file(node->name, S_IFREG | S_IRUGO, | 1163 | dent = debugfs_create_file(node->name, S_IFREG | S_IRUGO, |
1204 | eeepc->debug.root, node, | 1164 | asus->debug.root, node, |
1205 | &eeepc_wmi_debugfs_io_ops); | 1165 | &asus_wmi_debugfs_io_ops); |
1206 | if (!dent) { | 1166 | if (!dent) { |
1207 | pr_err("failed to create debug file: %s\n", node->name); | 1167 | pr_err("failed to create debug file: %s\n", node->name); |
1208 | goto error_debugfs; | 1168 | goto error_debugfs; |
@@ -1212,131 +1172,112 @@ static int eeepc_wmi_debugfs_init(struct eeepc_wmi *eeepc) | |||
1212 | return 0; | 1172 | return 0; |
1213 | 1173 | ||
1214 | error_debugfs: | 1174 | error_debugfs: |
1215 | eeepc_wmi_debugfs_exit(eeepc); | 1175 | asus_wmi_debugfs_exit(asus); |
1216 | return -ENOMEM; | 1176 | return -ENOMEM; |
1217 | } | 1177 | } |
1218 | 1178 | ||
1219 | /* | 1179 | /* |
1220 | * WMI Driver | 1180 | * WMI Driver |
1221 | */ | 1181 | */ |
1222 | static void eeepc_dmi_check(struct eeepc_wmi *eeepc) | 1182 | static int asus_wmi_add(struct platform_device *pdev) |
1223 | { | 1183 | { |
1224 | const char *model; | 1184 | struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); |
1225 | 1185 | struct asus_wmi_driver *wdrv = to_asus_wmi_driver(pdrv); | |
1226 | model = dmi_get_system_info(DMI_PRODUCT_NAME); | 1186 | struct asus_wmi *asus; |
1227 | if (!model) | ||
1228 | return; | ||
1229 | |||
1230 | /* | ||
1231 | * Whitelist for wlan hotplug | ||
1232 | * | ||
1233 | * Eeepc 1000H needs the current hotplug code to handle | ||
1234 | * Fn+F2 correctly. We may add other Eeepc here later, but | ||
1235 | * it seems that most of the laptops supported by eeepc-wmi | ||
1236 | * don't need to be on this list | ||
1237 | */ | ||
1238 | if (strcmp(model, "1000H") == 0) { | ||
1239 | eeepc->hotplug_wireless = true; | ||
1240 | pr_info("wlan hotplug enabled\n"); | ||
1241 | } | ||
1242 | } | ||
1243 | |||
1244 | static int __init eeepc_wmi_add(struct platform_device *pdev) | ||
1245 | { | ||
1246 | struct eeepc_wmi *eeepc; | ||
1247 | acpi_status status; | 1187 | acpi_status status; |
1248 | int err; | 1188 | int err; |
1249 | 1189 | ||
1250 | eeepc = kzalloc(sizeof(struct eeepc_wmi), GFP_KERNEL); | 1190 | asus = kzalloc(sizeof(struct asus_wmi), GFP_KERNEL); |
1251 | if (!eeepc) | 1191 | if (!asus) |
1252 | return -ENOMEM; | 1192 | return -ENOMEM; |
1253 | 1193 | ||
1254 | eeepc->platform_device = pdev; | 1194 | asus->driver = wdrv; |
1255 | platform_set_drvdata(eeepc->platform_device, eeepc); | 1195 | asus->platform_device = pdev; |
1196 | wdrv->platform_device = pdev; | ||
1197 | platform_set_drvdata(asus->platform_device, asus); | ||
1256 | 1198 | ||
1257 | eeepc->hotplug_wireless = hotplug_wireless; | 1199 | if (wdrv->quirks) |
1258 | eeepc_dmi_check(eeepc); | 1200 | wdrv->quirks(asus->driver); |
1259 | 1201 | ||
1260 | err = eeepc_wmi_platform_init(eeepc); | 1202 | err = asus_wmi_platform_init(asus); |
1261 | if (err) | 1203 | if (err) |
1262 | goto fail_platform; | 1204 | goto fail_platform; |
1263 | 1205 | ||
1264 | err = eeepc_wmi_input_init(eeepc); | 1206 | err = asus_wmi_input_init(asus); |
1265 | if (err) | 1207 | if (err) |
1266 | goto fail_input; | 1208 | goto fail_input; |
1267 | 1209 | ||
1268 | err = eeepc_wmi_led_init(eeepc); | 1210 | err = asus_wmi_led_init(asus); |
1269 | if (err) | 1211 | if (err) |
1270 | goto fail_leds; | 1212 | goto fail_leds; |
1271 | 1213 | ||
1272 | err = eeepc_wmi_rfkill_init(eeepc); | 1214 | err = asus_wmi_rfkill_init(asus); |
1273 | if (err) | 1215 | if (err) |
1274 | goto fail_rfkill; | 1216 | goto fail_rfkill; |
1275 | 1217 | ||
1276 | if (!acpi_video_backlight_support()) { | 1218 | if (!acpi_video_backlight_support()) { |
1277 | err = eeepc_wmi_backlight_init(eeepc); | 1219 | err = asus_wmi_backlight_init(asus); |
1278 | if (err && err != -ENODEV) | 1220 | if (err && err != -ENODEV) |
1279 | goto fail_backlight; | 1221 | goto fail_backlight; |
1280 | } else | 1222 | } else |
1281 | pr_info("Backlight controlled by ACPI video driver\n"); | 1223 | pr_info("Backlight controlled by ACPI video driver\n"); |
1282 | 1224 | ||
1283 | status = wmi_install_notify_handler(EEEPC_WMI_EVENT_GUID, | 1225 | status = wmi_install_notify_handler(asus->driver->event_guid, |
1284 | eeepc_wmi_notify, eeepc); | 1226 | asus_wmi_notify, asus); |
1285 | if (ACPI_FAILURE(status)) { | 1227 | if (ACPI_FAILURE(status)) { |
1286 | pr_err("Unable to register notify handler - %d\n", | 1228 | pr_err("Unable to register notify handler - %d\n", status); |
1287 | status); | ||
1288 | err = -ENODEV; | 1229 | err = -ENODEV; |
1289 | goto fail_wmi_handler; | 1230 | goto fail_wmi_handler; |
1290 | } | 1231 | } |
1291 | 1232 | ||
1292 | err = eeepc_wmi_debugfs_init(eeepc); | 1233 | err = asus_wmi_debugfs_init(asus); |
1293 | if (err) | 1234 | if (err) |
1294 | goto fail_debugfs; | 1235 | goto fail_debugfs; |
1295 | 1236 | ||
1296 | return 0; | 1237 | return 0; |
1297 | 1238 | ||
1298 | fail_debugfs: | 1239 | fail_debugfs: |
1299 | wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID); | 1240 | wmi_remove_notify_handler(asus->driver->event_guid); |
1300 | fail_wmi_handler: | 1241 | fail_wmi_handler: |
1301 | eeepc_wmi_backlight_exit(eeepc); | 1242 | asus_wmi_backlight_exit(asus); |
1302 | fail_backlight: | 1243 | fail_backlight: |
1303 | eeepc_wmi_rfkill_exit(eeepc); | 1244 | asus_wmi_rfkill_exit(asus); |
1304 | fail_rfkill: | 1245 | fail_rfkill: |
1305 | eeepc_wmi_led_exit(eeepc); | 1246 | asus_wmi_led_exit(asus); |
1306 | fail_leds: | 1247 | fail_leds: |
1307 | eeepc_wmi_input_exit(eeepc); | 1248 | asus_wmi_input_exit(asus); |
1308 | fail_input: | 1249 | fail_input: |
1309 | eeepc_wmi_platform_exit(eeepc); | 1250 | asus_wmi_platform_exit(asus); |
1310 | fail_platform: | 1251 | fail_platform: |
1311 | kfree(eeepc); | 1252 | kfree(asus); |
1312 | return err; | 1253 | return err; |
1313 | } | 1254 | } |
1314 | 1255 | ||
1315 | static int __exit eeepc_wmi_remove(struct platform_device *device) | 1256 | static int asus_wmi_remove(struct platform_device *device) |
1316 | { | 1257 | { |
1317 | struct eeepc_wmi *eeepc; | 1258 | struct asus_wmi *asus; |
1318 | 1259 | ||
1319 | eeepc = platform_get_drvdata(device); | 1260 | asus = platform_get_drvdata(device); |
1320 | wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID); | 1261 | wmi_remove_notify_handler(asus->driver->event_guid); |
1321 | eeepc_wmi_backlight_exit(eeepc); | 1262 | asus_wmi_backlight_exit(asus); |
1322 | eeepc_wmi_input_exit(eeepc); | 1263 | asus_wmi_input_exit(asus); |
1323 | eeepc_wmi_led_exit(eeepc); | 1264 | asus_wmi_led_exit(asus); |
1324 | eeepc_wmi_rfkill_exit(eeepc); | 1265 | asus_wmi_rfkill_exit(asus); |
1325 | eeepc_wmi_debugfs_exit(eeepc); | 1266 | asus_wmi_debugfs_exit(asus); |
1326 | eeepc_wmi_platform_exit(eeepc); | 1267 | asus_wmi_platform_exit(asus); |
1327 | 1268 | ||
1328 | kfree(eeepc); | 1269 | kfree(asus); |
1329 | return 0; | 1270 | return 0; |
1330 | } | 1271 | } |
1331 | 1272 | ||
1332 | /* | 1273 | /* |
1333 | * Platform driver - hibernate/resume callbacks | 1274 | * Platform driver - hibernate/resume callbacks |
1334 | */ | 1275 | */ |
1335 | static int eeepc_hotk_thaw(struct device *device) | 1276 | static int asus_hotk_thaw(struct device *device) |
1336 | { | 1277 | { |
1337 | struct eeepc_wmi *eeepc = dev_get_drvdata(device); | 1278 | struct asus_wmi *asus = dev_get_drvdata(device); |
1338 | 1279 | ||
1339 | if (eeepc->wlan_rfkill) { | 1280 | if (asus->wlan_rfkill) { |
1340 | bool wlan; | 1281 | bool wlan; |
1341 | 1282 | ||
1342 | /* | 1283 | /* |
@@ -1344,111 +1285,118 @@ static int eeepc_hotk_thaw(struct device *device) | |||
1344 | * during suspend. Normally it restores it on resume, but | 1285 | * during suspend. Normally it restores it on resume, but |
1345 | * we should kick it ourselves in case hibernation is aborted. | 1286 | * we should kick it ourselves in case hibernation is aborted. |
1346 | */ | 1287 | */ |
1347 | wlan = eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WLAN); | 1288 | wlan = asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WLAN); |
1348 | eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_WLAN, wlan, NULL); | 1289 | asus_wmi_set_devstate(ASUS_WMI_DEVID_WLAN, wlan, NULL); |
1349 | } | 1290 | } |
1350 | 1291 | ||
1351 | return 0; | 1292 | return 0; |
1352 | } | 1293 | } |
1353 | 1294 | ||
1354 | static int eeepc_hotk_restore(struct device *device) | 1295 | static int asus_hotk_restore(struct device *device) |
1355 | { | 1296 | { |
1356 | struct eeepc_wmi *eeepc = dev_get_drvdata(device); | 1297 | struct asus_wmi *asus = dev_get_drvdata(device); |
1357 | int bl; | 1298 | int bl; |
1358 | 1299 | ||
1359 | /* Refresh both wlan rfkill state and pci hotplug */ | 1300 | /* Refresh both wlan rfkill state and pci hotplug */ |
1360 | if (eeepc->wlan_rfkill) | 1301 | if (asus->wlan_rfkill) |
1361 | eeepc_rfkill_hotplug(eeepc); | 1302 | asus_rfkill_hotplug(asus); |
1362 | 1303 | ||
1363 | if (eeepc->bluetooth_rfkill) { | 1304 | if (asus->bluetooth_rfkill) { |
1364 | bl = !eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_BLUETOOTH); | 1305 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_BLUETOOTH); |
1365 | rfkill_set_sw_state(eeepc->bluetooth_rfkill, bl); | 1306 | rfkill_set_sw_state(asus->bluetooth_rfkill, bl); |
1366 | } | 1307 | } |
1367 | if (eeepc->wimax_rfkill) { | 1308 | if (asus->wimax_rfkill) { |
1368 | bl = !eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WIMAX); | 1309 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WIMAX); |
1369 | rfkill_set_sw_state(eeepc->wimax_rfkill, bl); | 1310 | rfkill_set_sw_state(asus->wimax_rfkill, bl); |
1370 | } | 1311 | } |
1371 | if (eeepc->wwan3g_rfkill) { | 1312 | if (asus->wwan3g_rfkill) { |
1372 | bl = !eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WWAN3G); | 1313 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WWAN3G); |
1373 | rfkill_set_sw_state(eeepc->wwan3g_rfkill, bl); | 1314 | rfkill_set_sw_state(asus->wwan3g_rfkill, bl); |
1374 | } | 1315 | } |
1375 | 1316 | ||
1376 | return 0; | 1317 | return 0; |
1377 | } | 1318 | } |
1378 | 1319 | ||
1379 | static const struct dev_pm_ops eeepc_pm_ops = { | 1320 | static const struct dev_pm_ops asus_pm_ops = { |
1380 | .thaw = eeepc_hotk_thaw, | 1321 | .thaw = asus_hotk_thaw, |
1381 | .restore = eeepc_hotk_restore, | 1322 | .restore = asus_hotk_restore, |
1382 | }; | ||
1383 | |||
1384 | static struct platform_driver platform_driver = { | ||
1385 | .remove = __exit_p(eeepc_wmi_remove), | ||
1386 | .driver = { | ||
1387 | .name = EEEPC_WMI_FILE, | ||
1388 | .owner = THIS_MODULE, | ||
1389 | .pm = &eeepc_pm_ops, | ||
1390 | }, | ||
1391 | }; | 1323 | }; |
1392 | 1324 | ||
1393 | static acpi_status __init eeepc_wmi_parse_device(acpi_handle handle, u32 level, | 1325 | static int asus_wmi_probe(struct platform_device *pdev) |
1394 | void *context, void **retval) | ||
1395 | { | 1326 | { |
1396 | pr_warning("Found legacy ATKD device (%s)", EEEPC_ACPI_HID); | 1327 | struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); |
1397 | *(bool *)context = true; | 1328 | struct asus_wmi_driver *wdrv = to_asus_wmi_driver(pdrv); |
1398 | return AE_CTRL_TERMINATE; | 1329 | int ret; |
1399 | } | ||
1400 | |||
1401 | static int __init eeepc_wmi_check_atkd(void) | ||
1402 | { | ||
1403 | acpi_status status; | ||
1404 | bool found = false; | ||
1405 | |||
1406 | status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device, | ||
1407 | &found, NULL); | ||
1408 | |||
1409 | if (ACPI_FAILURE(status) || !found) | ||
1410 | return 0; | ||
1411 | return -1; | ||
1412 | } | ||
1413 | 1330 | ||
1414 | static int __init eeepc_wmi_probe(struct platform_device *pdev) | 1331 | if (!wmi_has_guid(ASUS_WMI_MGMT_GUID)) { |
1415 | { | 1332 | pr_warning("Management GUID not found\n"); |
1416 | if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID) || | ||
1417 | !wmi_has_guid(EEEPC_WMI_MGMT_GUID)) { | ||
1418 | pr_warning("No known WMI GUID found\n"); | ||
1419 | return -ENODEV; | 1333 | return -ENODEV; |
1420 | } | 1334 | } |
1421 | 1335 | ||
1422 | if (eeepc_wmi_check_atkd()) { | 1336 | if (wdrv->event_guid && !wmi_has_guid(wdrv->event_guid)) { |
1423 | pr_warning("WMI device present, but legacy ATKD device is also " | 1337 | pr_warning("Event GUID not found\n"); |
1424 | "present and enabled."); | ||
1425 | pr_warning("You probably booted with acpi_osi=\"Linux\" or " | ||
1426 | "acpi_osi=\"!Windows 2009\""); | ||
1427 | pr_warning("Can't load eeepc-wmi, use default acpi_osi " | ||
1428 | "(preferred) or eeepc-laptop"); | ||
1429 | return -ENODEV; | 1338 | return -ENODEV; |
1430 | } | 1339 | } |
1431 | 1340 | ||
1432 | return eeepc_wmi_add(pdev); | 1341 | if (wdrv->probe) { |
1342 | ret = wdrv->probe(pdev); | ||
1343 | if (ret) | ||
1344 | return ret; | ||
1345 | } | ||
1346 | |||
1347 | return asus_wmi_add(pdev); | ||
1433 | } | 1348 | } |
1434 | 1349 | ||
1435 | static struct platform_device *platform_device; | 1350 | static bool used; |
1436 | 1351 | ||
1437 | static int __init eeepc_wmi_init(void) | 1352 | int asus_wmi_register_driver(struct asus_wmi_driver *driver) |
1438 | { | 1353 | { |
1439 | platform_device = platform_create_bundle(&platform_driver, | 1354 | struct platform_driver *platform_driver; |
1440 | eeepc_wmi_probe, | 1355 | struct platform_device *platform_device; |
1356 | |||
1357 | if (used) | ||
1358 | return -EBUSY; | ||
1359 | |||
1360 | platform_driver = &driver->platform_driver; | ||
1361 | platform_driver->remove = asus_wmi_remove; | ||
1362 | platform_driver->driver.owner = driver->owner; | ||
1363 | platform_driver->driver.name = driver->name; | ||
1364 | platform_driver->driver.pm = &asus_pm_ops; | ||
1365 | |||
1366 | platform_device = platform_create_bundle(platform_driver, | ||
1367 | asus_wmi_probe, | ||
1441 | NULL, 0, NULL, 0); | 1368 | NULL, 0, NULL, 0); |
1442 | if (IS_ERR(platform_device)) | 1369 | if (IS_ERR(platform_device)) |
1443 | return PTR_ERR(platform_device); | 1370 | return PTR_ERR(platform_device); |
1371 | |||
1372 | used = true; | ||
1373 | return 0; | ||
1374 | } | ||
1375 | EXPORT_SYMBOL_GPL(asus_wmi_register_driver); | ||
1376 | |||
1377 | void asus_wmi_unregister_driver(struct asus_wmi_driver *driver) | ||
1378 | { | ||
1379 | platform_device_unregister(driver->platform_device); | ||
1380 | platform_driver_unregister(&driver->platform_driver); | ||
1381 | used = false; | ||
1382 | } | ||
1383 | EXPORT_SYMBOL_GPL(asus_wmi_unregister_driver); | ||
1384 | |||
1385 | static int __init asus_wmi_init(void) | ||
1386 | { | ||
1387 | if (!wmi_has_guid(ASUS_WMI_MGMT_GUID)) { | ||
1388 | pr_info("Asus Management GUID not found"); | ||
1389 | return -ENODEV; | ||
1390 | } | ||
1391 | |||
1392 | pr_info("ASUS WMI generic driver loaded"); | ||
1444 | return 0; | 1393 | return 0; |
1445 | } | 1394 | } |
1446 | 1395 | ||
1447 | static void __exit eeepc_wmi_exit(void) | 1396 | static void __exit asus_wmi_exit(void) |
1448 | { | 1397 | { |
1449 | platform_device_unregister(platform_device); | 1398 | pr_info("ASUS WMI generic driver unloaded"); |
1450 | platform_driver_unregister(&platform_driver); | ||
1451 | } | 1399 | } |
1452 | 1400 | ||
1453 | module_init(eeepc_wmi_init); | 1401 | module_init(asus_wmi_init); |
1454 | module_exit(eeepc_wmi_exit); | 1402 | module_exit(asus_wmi_exit); |
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h new file mode 100644 index 000000000000..c044522c8766 --- /dev/null +++ b/drivers/platform/x86/asus-wmi.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Asus PC WMI hotkey driver | ||
3 | * | ||
4 | * Copyright(C) 2010 Intel Corporation. | ||
5 | * Copyright(C) 2010-2011 Corentin Chary <corentin.chary@gmail.com> | ||
6 | * | ||
7 | * Portions based on wistron_btns.c: | ||
8 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> | ||
9 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> | ||
10 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | */ | ||
26 | |||
27 | #ifndef _ASUS_WMI_H_ | ||
28 | #define _ASUS_WMI_H_ | ||
29 | |||
30 | #include <linux/platform_device.h> | ||
31 | |||
32 | struct module; | ||
33 | struct key_entry; | ||
34 | struct asus_wmi; | ||
35 | |||
36 | struct asus_wmi_driver { | ||
37 | bool hotplug_wireless; | ||
38 | |||
39 | const char *name; | ||
40 | struct module *owner; | ||
41 | |||
42 | const char *event_guid; | ||
43 | |||
44 | const struct key_entry *keymap; | ||
45 | const char *input_name; | ||
46 | const char *input_phys; | ||
47 | |||
48 | int (*probe) (struct platform_device *device); | ||
49 | void (*quirks) (struct asus_wmi_driver *driver); | ||
50 | |||
51 | struct platform_driver platform_driver; | ||
52 | struct platform_device *platform_device; | ||
53 | }; | ||
54 | |||
55 | int asus_wmi_register_driver(struct asus_wmi_driver *driver); | ||
56 | void asus_wmi_unregister_driver(struct asus_wmi_driver *driver); | ||
57 | |||
58 | #endif /* !_ASUS_WMI_H_ */ | ||
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c new file mode 100644 index 000000000000..3a060aefc5f3 --- /dev/null +++ b/drivers/platform/x86/eeepc-wmi.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | * Eee PC WMI hotkey driver | ||
3 | * | ||
4 | * Copyright(C) 2010 Intel Corporation. | ||
5 | * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com> | ||
6 | * | ||
7 | * Portions based on wistron_btns.c: | ||
8 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> | ||
9 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> | ||
10 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | */ | ||
26 | |||
27 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
28 | |||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/module.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/input.h> | ||
33 | #include <linux/input/sparse-keymap.h> | ||
34 | #include <linux/dmi.h> | ||
35 | #include <acpi/acpi_bus.h> | ||
36 | |||
37 | #include "asus-wmi.h" | ||
38 | |||
39 | #define EEEPC_WMI_FILE "eeepc-wmi" | ||
40 | |||
41 | MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>"); | ||
42 | MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver"); | ||
43 | MODULE_LICENSE("GPL"); | ||
44 | |||
45 | #define EEEPC_ACPI_HID "ASUS010" /* old _HID used in eeepc-laptop */ | ||
46 | |||
47 | #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000" | ||
48 | |||
49 | MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID); | ||
50 | |||
51 | static bool hotplug_wireless; | ||
52 | |||
53 | module_param(hotplug_wireless, bool, 0444); | ||
54 | MODULE_PARM_DESC(hotplug_wireless, | ||
55 | "Enable hotplug for wireless device. " | ||
56 | "If your laptop needs that, please report to " | ||
57 | "acpi4asus-user@lists.sourceforge.net."); | ||
58 | |||
59 | static const struct key_entry eeepc_wmi_keymap[] = { | ||
60 | /* Sleep already handled via generic ACPI code */ | ||
61 | { KE_KEY, 0x30, { KEY_VOLUMEUP } }, | ||
62 | { KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, | ||
63 | { KE_KEY, 0x32, { KEY_MUTE } }, | ||
64 | { KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */ | ||
65 | { KE_KEY, 0x5d, { KEY_WLAN } }, | ||
66 | { KE_KEY, 0x6b, { KEY_F13 } }, /* Disable Touchpad */ | ||
67 | { KE_KEY, 0x82, { KEY_CAMERA } }, | ||
68 | { KE_KEY, 0x88, { KEY_WLAN } }, | ||
69 | { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } }, | ||
70 | { KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */ | ||
71 | { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */ | ||
72 | { KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } }, | ||
73 | { KE_END, 0}, | ||
74 | }; | ||
75 | |||
76 | static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level, | ||
77 | void *context, void **retval) | ||
78 | { | ||
79 | pr_warning("Found legacy ATKD device (%s)", EEEPC_ACPI_HID); | ||
80 | *(bool *)context = true; | ||
81 | return AE_CTRL_TERMINATE; | ||
82 | } | ||
83 | |||
84 | static int eeepc_wmi_check_atkd(void) | ||
85 | { | ||
86 | acpi_status status; | ||
87 | bool found = false; | ||
88 | |||
89 | status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device, | ||
90 | &found, NULL); | ||
91 | |||
92 | if (ACPI_FAILURE(status) || !found) | ||
93 | return 0; | ||
94 | return -1; | ||
95 | } | ||
96 | |||
97 | static int eeepc_wmi_probe(struct platform_device *pdev) | ||
98 | { | ||
99 | if (eeepc_wmi_check_atkd()) { | ||
100 | pr_warning("WMI device present, but legacy ATKD device is also " | ||
101 | "present and enabled."); | ||
102 | pr_warning("You probably booted with acpi_osi=\"Linux\" or " | ||
103 | "acpi_osi=\"!Windows 2009\""); | ||
104 | pr_warning("Can't load eeepc-wmi, use default acpi_osi " | ||
105 | "(preferred) or eeepc-laptop"); | ||
106 | return -EBUSY; | ||
107 | } | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static void eeepc_dmi_check(struct asus_wmi_driver *driver) | ||
112 | { | ||
113 | const char *model; | ||
114 | |||
115 | model = dmi_get_system_info(DMI_PRODUCT_NAME); | ||
116 | if (!model) | ||
117 | return; | ||
118 | |||
119 | /* | ||
120 | * Whitelist for wlan hotplug | ||
121 | * | ||
122 | * Asus 1000H needs the current hotplug code to handle | ||
123 | * Fn+F2 correctly. We may add other Asus here later, but | ||
124 | * it seems that most of the laptops supported by asus-wmi | ||
125 | * don't need to be on this list | ||
126 | */ | ||
127 | if (strcmp(model, "1000H") == 0) { | ||
128 | driver->hotplug_wireless = true; | ||
129 | pr_info("wlan hotplug enabled\n"); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | static void eeepc_wmi_quirks(struct asus_wmi_driver *driver) | ||
134 | { | ||
135 | driver->hotplug_wireless = hotplug_wireless; | ||
136 | eeepc_dmi_check(driver); | ||
137 | } | ||
138 | |||
139 | static struct asus_wmi_driver asus_wmi_driver = { | ||
140 | .name = EEEPC_WMI_FILE, | ||
141 | .owner = THIS_MODULE, | ||
142 | .event_guid = EEEPC_WMI_EVENT_GUID, | ||
143 | .keymap = eeepc_wmi_keymap, | ||
144 | .input_name = "Eee PC WMI hotkeys", | ||
145 | .input_phys = EEEPC_WMI_FILE "/input0", | ||
146 | .probe = eeepc_wmi_probe, | ||
147 | .quirks = eeepc_wmi_quirks, | ||
148 | }; | ||
149 | |||
150 | |||
151 | static int __init eeepc_wmi_init(void) | ||
152 | { | ||
153 | return asus_wmi_register_driver(&asus_wmi_driver); | ||
154 | } | ||
155 | |||
156 | static void __exit eeepc_wmi_exit(void) | ||
157 | { | ||
158 | asus_wmi_unregister_driver(&asus_wmi_driver); | ||
159 | } | ||
160 | |||
161 | module_init(eeepc_wmi_init); | ||
162 | module_exit(eeepc_wmi_exit); | ||