Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Corentin Chary and committed by
Matthew Garrett
e12e6d94 5b799d4f

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