hp-wmi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /*
  2. * HP WMI hotkeys
  3. *
  4. * Copyright (C) 2008 Red Hat <mjg@redhat.com>
  5. *
  6. * Portions based on wistron_btns.c:
  7. * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
  8. * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
  9. * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/slab.h>
  29. #include <linux/types.h>
  30. #include <linux/input.h>
  31. #include <acpi/acpi_drivers.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/acpi.h>
  34. #include <linux/rfkill.h>
  35. #include <linux/string.h>
  36. MODULE_AUTHOR("Matthew Garrett <mjg59@srcf.ucam.org>");
  37. MODULE_DESCRIPTION("HP laptop WMI hotkeys driver");
  38. MODULE_LICENSE("GPL");
  39. MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C");
  40. MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
  41. #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"
  42. #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"
  43. #define HPWMI_DISPLAY_QUERY 0x1
  44. #define HPWMI_HDDTEMP_QUERY 0x2
  45. #define HPWMI_ALS_QUERY 0x3
  46. #define HPWMI_HARDWARE_QUERY 0x4
  47. #define HPWMI_WIRELESS_QUERY 0x5
  48. #define HPWMI_HOTKEY_QUERY 0xc
  49. enum hp_wmi_radio {
  50. HPWMI_WIFI = 0,
  51. HPWMI_BLUETOOTH = 1,
  52. HPWMI_WWAN = 2,
  53. };
  54. static int __devinit hp_wmi_bios_setup(struct platform_device *device);
  55. static int __exit hp_wmi_bios_remove(struct platform_device *device);
  56. static int hp_wmi_resume_handler(struct device *device);
  57. struct bios_args {
  58. u32 signature;
  59. u32 command;
  60. u32 commandtype;
  61. u32 datasize;
  62. u32 data;
  63. };
  64. struct bios_return {
  65. u32 sigpass;
  66. u32 return_code;
  67. u32 value;
  68. };
  69. struct key_entry {
  70. char type; /* See KE_* below */
  71. u16 code;
  72. u16 keycode;
  73. };
  74. enum { KE_KEY, KE_END };
  75. static struct key_entry hp_wmi_keymap[] = {
  76. {KE_KEY, 0x02, KEY_BRIGHTNESSUP},
  77. {KE_KEY, 0x03, KEY_BRIGHTNESSDOWN},
  78. {KE_KEY, 0x20e6, KEY_PROG1},
  79. {KE_KEY, 0x2142, KEY_MEDIA},
  80. {KE_KEY, 0x213b, KEY_INFO},
  81. {KE_KEY, 0x2169, KEY_DIRECTION},
  82. {KE_KEY, 0x231b, KEY_HELP},
  83. {KE_END, 0}
  84. };
  85. static struct input_dev *hp_wmi_input_dev;
  86. static struct platform_device *hp_wmi_platform_dev;
  87. static struct rfkill *wifi_rfkill;
  88. static struct rfkill *bluetooth_rfkill;
  89. static struct rfkill *wwan_rfkill;
  90. static const struct dev_pm_ops hp_wmi_pm_ops = {
  91. .resume = hp_wmi_resume_handler,
  92. .restore = hp_wmi_resume_handler,
  93. };
  94. static struct platform_driver hp_wmi_driver = {
  95. .driver = {
  96. .name = "hp-wmi",
  97. .owner = THIS_MODULE,
  98. .pm = &hp_wmi_pm_ops,
  99. },
  100. .probe = hp_wmi_bios_setup,
  101. .remove = hp_wmi_bios_remove,
  102. };
  103. static int hp_wmi_perform_query(int query, int write, int value)
  104. {
  105. struct bios_return bios_return;
  106. acpi_status status;
  107. union acpi_object *obj;
  108. struct bios_args args = {
  109. .signature = 0x55434553,
  110. .command = write ? 0x2 : 0x1,
  111. .commandtype = query,
  112. .datasize = write ? 0x4 : 0,
  113. .data = value,
  114. };
  115. struct acpi_buffer input = { sizeof(struct bios_args), &args };
  116. struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
  117. status = wmi_evaluate_method(HPWMI_BIOS_GUID, 0, 0x3, &input, &output);
  118. obj = output.pointer;
  119. if (!obj)
  120. return -EINVAL;
  121. else if (obj->type != ACPI_TYPE_BUFFER) {
  122. kfree(obj);
  123. return -EINVAL;
  124. }
  125. bios_return = *((struct bios_return *)obj->buffer.pointer);
  126. kfree(obj);
  127. if (bios_return.return_code > 0)
  128. return bios_return.return_code * -1;
  129. else
  130. return bios_return.value;
  131. }
  132. static int hp_wmi_display_state(void)
  133. {
  134. return hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, 0);
  135. }
  136. static int hp_wmi_hddtemp_state(void)
  137. {
  138. return hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, 0);
  139. }
  140. static int hp_wmi_als_state(void)
  141. {
  142. return hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, 0);
  143. }
  144. static int hp_wmi_dock_state(void)
  145. {
  146. int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, 0);
  147. if (ret < 0)
  148. return ret;
  149. return ret & 0x1;
  150. }
  151. static int hp_wmi_tablet_state(void)
  152. {
  153. int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, 0);
  154. if (ret < 0)
  155. return ret;
  156. return (ret & 0x4) ? 1 : 0;
  157. }
  158. static int hp_wmi_set_block(void *data, bool blocked)
  159. {
  160. enum hp_wmi_radio r = (enum hp_wmi_radio) data;
  161. int query = BIT(r + 8) | ((!blocked) << r);
  162. return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
  163. }
  164. static const struct rfkill_ops hp_wmi_rfkill_ops = {
  165. .set_block = hp_wmi_set_block,
  166. };
  167. static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
  168. {
  169. int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
  170. int mask = 0x200 << (r * 8);
  171. if (wireless & mask)
  172. return false;
  173. else
  174. return true;
  175. }
  176. static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
  177. {
  178. int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
  179. int mask = 0x800 << (r * 8);
  180. if (wireless & mask)
  181. return false;
  182. else
  183. return true;
  184. }
  185. static ssize_t show_display(struct device *dev, struct device_attribute *attr,
  186. char *buf)
  187. {
  188. int value = hp_wmi_display_state();
  189. if (value < 0)
  190. return -EINVAL;
  191. return sprintf(buf, "%d\n", value);
  192. }
  193. static ssize_t show_hddtemp(struct device *dev, struct device_attribute *attr,
  194. char *buf)
  195. {
  196. int value = hp_wmi_hddtemp_state();
  197. if (value < 0)
  198. return -EINVAL;
  199. return sprintf(buf, "%d\n", value);
  200. }
  201. static ssize_t show_als(struct device *dev, struct device_attribute *attr,
  202. char *buf)
  203. {
  204. int value = hp_wmi_als_state();
  205. if (value < 0)
  206. return -EINVAL;
  207. return sprintf(buf, "%d\n", value);
  208. }
  209. static ssize_t show_dock(struct device *dev, struct device_attribute *attr,
  210. char *buf)
  211. {
  212. int value = hp_wmi_dock_state();
  213. if (value < 0)
  214. return -EINVAL;
  215. return sprintf(buf, "%d\n", value);
  216. }
  217. static ssize_t show_tablet(struct device *dev, struct device_attribute *attr,
  218. char *buf)
  219. {
  220. int value = hp_wmi_tablet_state();
  221. if (value < 0)
  222. return -EINVAL;
  223. return sprintf(buf, "%d\n", value);
  224. }
  225. static ssize_t set_als(struct device *dev, struct device_attribute *attr,
  226. const char *buf, size_t count)
  227. {
  228. u32 tmp = simple_strtoul(buf, NULL, 10);
  229. hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, tmp);
  230. return count;
  231. }
  232. static DEVICE_ATTR(display, S_IRUGO, show_display, NULL);
  233. static DEVICE_ATTR(hddtemp, S_IRUGO, show_hddtemp, NULL);
  234. static DEVICE_ATTR(als, S_IRUGO | S_IWUSR, show_als, set_als);
  235. static DEVICE_ATTR(dock, S_IRUGO, show_dock, NULL);
  236. static DEVICE_ATTR(tablet, S_IRUGO, show_tablet, NULL);
  237. static struct key_entry *hp_wmi_get_entry_by_scancode(unsigned int code)
  238. {
  239. struct key_entry *key;
  240. for (key = hp_wmi_keymap; key->type != KE_END; key++)
  241. if (code == key->code)
  242. return key;
  243. return NULL;
  244. }
  245. static struct key_entry *hp_wmi_get_entry_by_keycode(unsigned int keycode)
  246. {
  247. struct key_entry *key;
  248. for (key = hp_wmi_keymap; key->type != KE_END; key++)
  249. if (key->type == KE_KEY && keycode == key->keycode)
  250. return key;
  251. return NULL;
  252. }
  253. static int hp_wmi_getkeycode(struct input_dev *dev,
  254. unsigned int scancode, unsigned int *keycode)
  255. {
  256. struct key_entry *key = hp_wmi_get_entry_by_scancode(scancode);
  257. if (key && key->type == KE_KEY) {
  258. *keycode = key->keycode;
  259. return 0;
  260. }
  261. return -EINVAL;
  262. }
  263. static int hp_wmi_setkeycode(struct input_dev *dev,
  264. unsigned int scancode, unsigned int keycode)
  265. {
  266. struct key_entry *key;
  267. unsigned int old_keycode;
  268. key = hp_wmi_get_entry_by_scancode(scancode);
  269. if (key && key->type == KE_KEY) {
  270. old_keycode = key->keycode;
  271. key->keycode = keycode;
  272. set_bit(keycode, dev->keybit);
  273. if (!hp_wmi_get_entry_by_keycode(old_keycode))
  274. clear_bit(old_keycode, dev->keybit);
  275. return 0;
  276. }
  277. return -EINVAL;
  278. }
  279. static void hp_wmi_notify(u32 value, void *context)
  280. {
  281. struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
  282. static struct key_entry *key;
  283. union acpi_object *obj;
  284. int eventcode;
  285. acpi_status status;
  286. status = wmi_get_event_data(value, &response);
  287. if (status != AE_OK) {
  288. printk(KERN_INFO "hp-wmi: bad event status 0x%x\n", status);
  289. return;
  290. }
  291. obj = (union acpi_object *)response.pointer;
  292. if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
  293. printk(KERN_INFO "HP WMI: Unknown response received\n");
  294. kfree(obj);
  295. return;
  296. }
  297. eventcode = *((u8 *) obj->buffer.pointer);
  298. kfree(obj);
  299. if (eventcode == 0x4)
  300. eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
  301. 0);
  302. key = hp_wmi_get_entry_by_scancode(eventcode);
  303. if (key) {
  304. switch (key->type) {
  305. case KE_KEY:
  306. input_report_key(hp_wmi_input_dev,
  307. key->keycode, 1);
  308. input_sync(hp_wmi_input_dev);
  309. input_report_key(hp_wmi_input_dev,
  310. key->keycode, 0);
  311. input_sync(hp_wmi_input_dev);
  312. break;
  313. }
  314. } else if (eventcode == 0x1) {
  315. input_report_switch(hp_wmi_input_dev, SW_DOCK,
  316. hp_wmi_dock_state());
  317. input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
  318. hp_wmi_tablet_state());
  319. input_sync(hp_wmi_input_dev);
  320. } else if (eventcode == 0x5) {
  321. if (wifi_rfkill)
  322. rfkill_set_states(wifi_rfkill,
  323. hp_wmi_get_sw_state(HPWMI_WIFI),
  324. hp_wmi_get_hw_state(HPWMI_WIFI));
  325. if (bluetooth_rfkill)
  326. rfkill_set_states(bluetooth_rfkill,
  327. hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
  328. hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
  329. if (wwan_rfkill)
  330. rfkill_set_states(wwan_rfkill,
  331. hp_wmi_get_sw_state(HPWMI_WWAN),
  332. hp_wmi_get_hw_state(HPWMI_WWAN));
  333. } else
  334. printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
  335. eventcode);
  336. }
  337. static int __init hp_wmi_input_setup(void)
  338. {
  339. struct key_entry *key;
  340. int err;
  341. hp_wmi_input_dev = input_allocate_device();
  342. hp_wmi_input_dev->name = "HP WMI hotkeys";
  343. hp_wmi_input_dev->phys = "wmi/input0";
  344. hp_wmi_input_dev->id.bustype = BUS_HOST;
  345. hp_wmi_input_dev->getkeycode = hp_wmi_getkeycode;
  346. hp_wmi_input_dev->setkeycode = hp_wmi_setkeycode;
  347. for (key = hp_wmi_keymap; key->type != KE_END; key++) {
  348. switch (key->type) {
  349. case KE_KEY:
  350. set_bit(EV_KEY, hp_wmi_input_dev->evbit);
  351. set_bit(key->keycode, hp_wmi_input_dev->keybit);
  352. break;
  353. }
  354. }
  355. set_bit(EV_SW, hp_wmi_input_dev->evbit);
  356. set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
  357. set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
  358. /* Set initial hardware state */
  359. input_report_switch(hp_wmi_input_dev, SW_DOCK, hp_wmi_dock_state());
  360. input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
  361. hp_wmi_tablet_state());
  362. input_sync(hp_wmi_input_dev);
  363. err = input_register_device(hp_wmi_input_dev);
  364. if (err) {
  365. input_free_device(hp_wmi_input_dev);
  366. return err;
  367. }
  368. return 0;
  369. }
  370. static void cleanup_sysfs(struct platform_device *device)
  371. {
  372. device_remove_file(&device->dev, &dev_attr_display);
  373. device_remove_file(&device->dev, &dev_attr_hddtemp);
  374. device_remove_file(&device->dev, &dev_attr_als);
  375. device_remove_file(&device->dev, &dev_attr_dock);
  376. device_remove_file(&device->dev, &dev_attr_tablet);
  377. }
  378. static int __devinit hp_wmi_bios_setup(struct platform_device *device)
  379. {
  380. int err;
  381. int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
  382. err = device_create_file(&device->dev, &dev_attr_display);
  383. if (err)
  384. goto add_sysfs_error;
  385. err = device_create_file(&device->dev, &dev_attr_hddtemp);
  386. if (err)
  387. goto add_sysfs_error;
  388. err = device_create_file(&device->dev, &dev_attr_als);
  389. if (err)
  390. goto add_sysfs_error;
  391. err = device_create_file(&device->dev, &dev_attr_dock);
  392. if (err)
  393. goto add_sysfs_error;
  394. err = device_create_file(&device->dev, &dev_attr_tablet);
  395. if (err)
  396. goto add_sysfs_error;
  397. if (wireless & 0x1) {
  398. wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
  399. RFKILL_TYPE_WLAN,
  400. &hp_wmi_rfkill_ops,
  401. (void *) HPWMI_WIFI);
  402. rfkill_init_sw_state(wifi_rfkill,
  403. hp_wmi_get_sw_state(HPWMI_WIFI));
  404. rfkill_set_hw_state(wifi_rfkill,
  405. hp_wmi_get_hw_state(HPWMI_WIFI));
  406. err = rfkill_register(wifi_rfkill);
  407. if (err)
  408. goto register_wifi_error;
  409. }
  410. if (wireless & 0x2) {
  411. bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
  412. RFKILL_TYPE_BLUETOOTH,
  413. &hp_wmi_rfkill_ops,
  414. (void *) HPWMI_BLUETOOTH);
  415. rfkill_init_sw_state(bluetooth_rfkill,
  416. hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
  417. rfkill_set_hw_state(bluetooth_rfkill,
  418. hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
  419. err = rfkill_register(bluetooth_rfkill);
  420. if (err)
  421. goto register_bluetooth_error;
  422. }
  423. if (wireless & 0x4) {
  424. wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
  425. RFKILL_TYPE_WWAN,
  426. &hp_wmi_rfkill_ops,
  427. (void *) HPWMI_WWAN);
  428. rfkill_init_sw_state(wwan_rfkill,
  429. hp_wmi_get_sw_state(HPWMI_WWAN));
  430. rfkill_set_hw_state(wwan_rfkill,
  431. hp_wmi_get_hw_state(HPWMI_WWAN));
  432. err = rfkill_register(wwan_rfkill);
  433. if (err)
  434. goto register_wwan_err;
  435. }
  436. return 0;
  437. register_wwan_err:
  438. rfkill_destroy(wwan_rfkill);
  439. if (bluetooth_rfkill)
  440. rfkill_unregister(bluetooth_rfkill);
  441. register_bluetooth_error:
  442. rfkill_destroy(bluetooth_rfkill);
  443. if (wifi_rfkill)
  444. rfkill_unregister(wifi_rfkill);
  445. register_wifi_error:
  446. rfkill_destroy(wifi_rfkill);
  447. add_sysfs_error:
  448. cleanup_sysfs(device);
  449. return err;
  450. }
  451. static int __exit hp_wmi_bios_remove(struct platform_device *device)
  452. {
  453. cleanup_sysfs(device);
  454. if (wifi_rfkill) {
  455. rfkill_unregister(wifi_rfkill);
  456. rfkill_destroy(wifi_rfkill);
  457. }
  458. if (bluetooth_rfkill) {
  459. rfkill_unregister(bluetooth_rfkill);
  460. rfkill_destroy(bluetooth_rfkill);
  461. }
  462. if (wwan_rfkill) {
  463. rfkill_unregister(wwan_rfkill);
  464. rfkill_destroy(wwan_rfkill);
  465. }
  466. return 0;
  467. }
  468. static int hp_wmi_resume_handler(struct device *device)
  469. {
  470. /*
  471. * Hardware state may have changed while suspended, so trigger
  472. * input events for the current state. As this is a switch,
  473. * the input layer will only actually pass it on if the state
  474. * changed.
  475. */
  476. if (hp_wmi_input_dev) {
  477. input_report_switch(hp_wmi_input_dev, SW_DOCK,
  478. hp_wmi_dock_state());
  479. input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
  480. hp_wmi_tablet_state());
  481. input_sync(hp_wmi_input_dev);
  482. }
  483. if (wifi_rfkill)
  484. rfkill_set_states(wifi_rfkill,
  485. hp_wmi_get_sw_state(HPWMI_WIFI),
  486. hp_wmi_get_hw_state(HPWMI_WIFI));
  487. if (bluetooth_rfkill)
  488. rfkill_set_states(bluetooth_rfkill,
  489. hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
  490. hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
  491. if (wwan_rfkill)
  492. rfkill_set_states(wwan_rfkill,
  493. hp_wmi_get_sw_state(HPWMI_WWAN),
  494. hp_wmi_get_hw_state(HPWMI_WWAN));
  495. return 0;
  496. }
  497. static int __init hp_wmi_init(void)
  498. {
  499. int err;
  500. if (wmi_has_guid(HPWMI_EVENT_GUID)) {
  501. err = wmi_install_notify_handler(HPWMI_EVENT_GUID,
  502. hp_wmi_notify, NULL);
  503. if (ACPI_SUCCESS(err))
  504. hp_wmi_input_setup();
  505. }
  506. if (wmi_has_guid(HPWMI_BIOS_GUID)) {
  507. err = platform_driver_register(&hp_wmi_driver);
  508. if (err)
  509. return 0;
  510. hp_wmi_platform_dev = platform_device_alloc("hp-wmi", -1);
  511. if (!hp_wmi_platform_dev) {
  512. platform_driver_unregister(&hp_wmi_driver);
  513. return 0;
  514. }
  515. platform_device_add(hp_wmi_platform_dev);
  516. }
  517. return 0;
  518. }
  519. static void __exit hp_wmi_exit(void)
  520. {
  521. if (wmi_has_guid(HPWMI_EVENT_GUID)) {
  522. wmi_remove_notify_handler(HPWMI_EVENT_GUID);
  523. input_unregister_device(hp_wmi_input_dev);
  524. }
  525. if (hp_wmi_platform_dev) {
  526. platform_device_del(hp_wmi_platform_dev);
  527. platform_driver_unregister(&hp_wmi_driver);
  528. }
  529. }
  530. module_init(hp_wmi_init);
  531. module_exit(hp_wmi_exit);