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