wmi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /*
  2. * ACPI-WMI mapping driver
  3. *
  4. * Copyright (C) 2007-2008 Carlos Corbacho <carlos@strangeworlds.co.uk>
  5. *
  6. * GUID parsing code from ldm.c is:
  7. * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
  8. * Copyright (c) 2001-2007 Anton Altaparmakov
  9. * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
  10. *
  11. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or (at
  16. * your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful, but
  19. * WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  26. *
  27. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/init.h>
  31. #include <linux/types.h>
  32. #include <linux/list.h>
  33. #include <linux/acpi.h>
  34. #include <acpi/acpi_bus.h>
  35. #include <acpi/acpi_drivers.h>
  36. ACPI_MODULE_NAME("wmi");
  37. MODULE_AUTHOR("Carlos Corbacho");
  38. MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
  39. MODULE_LICENSE("GPL");
  40. #define ACPI_WMI_CLASS "wmi"
  41. #undef PREFIX
  42. #define PREFIX "ACPI: WMI: "
  43. static DEFINE_MUTEX(wmi_data_lock);
  44. struct guid_block {
  45. char guid[16];
  46. union {
  47. char object_id[2];
  48. struct {
  49. unsigned char notify_id;
  50. unsigned char reserved;
  51. };
  52. };
  53. u8 instance_count;
  54. u8 flags;
  55. };
  56. struct wmi_block {
  57. struct list_head list;
  58. struct guid_block gblock;
  59. acpi_handle handle;
  60. wmi_notify_handler handler;
  61. void *handler_data;
  62. };
  63. static struct wmi_block wmi_blocks;
  64. /*
  65. * If the GUID data block is marked as expensive, we must enable and
  66. * explicitily disable data collection.
  67. */
  68. #define ACPI_WMI_EXPENSIVE 0x1
  69. #define ACPI_WMI_METHOD 0x2 /* GUID is a method */
  70. #define ACPI_WMI_STRING 0x4 /* GUID takes & returns a string */
  71. #define ACPI_WMI_EVENT 0x8 /* GUID is an event */
  72. static int acpi_wmi_remove(struct acpi_device *device, int type);
  73. static int acpi_wmi_add(struct acpi_device *device);
  74. static const struct acpi_device_id wmi_device_ids[] = {
  75. {"PNP0C14", 0},
  76. {"pnp0c14", 0},
  77. {"", 0},
  78. };
  79. MODULE_DEVICE_TABLE(acpi, wmi_device_ids);
  80. static struct acpi_driver acpi_wmi_driver = {
  81. .name = "wmi",
  82. .class = ACPI_WMI_CLASS,
  83. .ids = wmi_device_ids,
  84. .ops = {
  85. .add = acpi_wmi_add,
  86. .remove = acpi_wmi_remove,
  87. },
  88. };
  89. /*
  90. * GUID parsing functions
  91. */
  92. /**
  93. * wmi_parse_hexbyte - Convert a ASCII hex number to a byte
  94. * @src: Pointer to at least 2 characters to convert.
  95. *
  96. * Convert a two character ASCII hex string to a number.
  97. *
  98. * Return: 0-255 Success, the byte was parsed correctly
  99. * -1 Error, an invalid character was supplied
  100. */
  101. static int wmi_parse_hexbyte(const u8 *src)
  102. {
  103. unsigned int x; /* For correct wrapping */
  104. int h;
  105. /* high part */
  106. x = src[0];
  107. if (x - '0' <= '9' - '0') {
  108. h = x - '0';
  109. } else if (x - 'a' <= 'f' - 'a') {
  110. h = x - 'a' + 10;
  111. } else if (x - 'A' <= 'F' - 'A') {
  112. h = x - 'A' + 10;
  113. } else {
  114. return -1;
  115. }
  116. h <<= 4;
  117. /* low part */
  118. x = src[1];
  119. if (x - '0' <= '9' - '0')
  120. return h | (x - '0');
  121. if (x - 'a' <= 'f' - 'a')
  122. return h | (x - 'a' + 10);
  123. if (x - 'A' <= 'F' - 'A')
  124. return h | (x - 'A' + 10);
  125. return -1;
  126. }
  127. /**
  128. * wmi_swap_bytes - Rearrange GUID bytes to match GUID binary
  129. * @src: Memory block holding binary GUID (16 bytes)
  130. * @dest: Memory block to hold byte swapped binary GUID (16 bytes)
  131. *
  132. * Byte swap a binary GUID to match it's real GUID value
  133. */
  134. static void wmi_swap_bytes(u8 *src, u8 *dest)
  135. {
  136. int i;
  137. for (i = 0; i <= 3; i++)
  138. memcpy(dest + i, src + (3 - i), 1);
  139. for (i = 0; i <= 1; i++)
  140. memcpy(dest + 4 + i, src + (5 - i), 1);
  141. for (i = 0; i <= 1; i++)
  142. memcpy(dest + 6 + i, src + (7 - i), 1);
  143. memcpy(dest + 8, src + 8, 8);
  144. }
  145. /**
  146. * wmi_parse_guid - Convert GUID from ASCII to binary
  147. * @src: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
  148. * @dest: Memory block to hold binary GUID (16 bytes)
  149. *
  150. * N.B. The GUID need not be NULL terminated.
  151. *
  152. * Return: 'true' @dest contains binary GUID
  153. * 'false' @dest contents are undefined
  154. */
  155. static bool wmi_parse_guid(const u8 *src, u8 *dest)
  156. {
  157. static const int size[] = { 4, 2, 2, 2, 6 };
  158. int i, j, v;
  159. if (src[8] != '-' || src[13] != '-' ||
  160. src[18] != '-' || src[23] != '-')
  161. return false;
  162. for (j = 0; j < 5; j++, src++) {
  163. for (i = 0; i < size[j]; i++, src += 2, *dest++ = v) {
  164. v = wmi_parse_hexbyte(src);
  165. if (v < 0)
  166. return false;
  167. }
  168. }
  169. return true;
  170. }
  171. static bool find_guid(const char *guid_string, struct wmi_block **out)
  172. {
  173. char tmp[16], guid_input[16];
  174. struct wmi_block *wblock;
  175. struct guid_block *block;
  176. struct list_head *p;
  177. wmi_parse_guid(guid_string, tmp);
  178. wmi_swap_bytes(tmp, guid_input);
  179. list_for_each(p, &wmi_blocks.list) {
  180. wblock = list_entry(p, struct wmi_block, list);
  181. block = &wblock->gblock;
  182. if (memcmp(block->guid, guid_input, 16) == 0) {
  183. if (out)
  184. *out = wblock;
  185. return 1;
  186. }
  187. }
  188. return 0;
  189. }
  190. /*
  191. * Exported WMI functions
  192. */
  193. /**
  194. * wmi_evaluate_method - Evaluate a WMI method
  195. * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
  196. * @instance: Instance index
  197. * @method_id: Method ID to call
  198. * &in: Buffer containing input for the method call
  199. * &out: Empty buffer to return the method results
  200. *
  201. * Call an ACPI-WMI method
  202. */
  203. acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
  204. u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
  205. {
  206. struct guid_block *block = NULL;
  207. struct wmi_block *wblock = NULL;
  208. acpi_handle handle;
  209. acpi_status status;
  210. struct acpi_object_list input;
  211. union acpi_object params[3];
  212. char method[4] = "WM";
  213. if (!find_guid(guid_string, &wblock))
  214. return AE_BAD_ADDRESS;
  215. block = &wblock->gblock;
  216. handle = wblock->handle;
  217. if (!(block->flags & ACPI_WMI_METHOD))
  218. return AE_BAD_DATA;
  219. if (block->instance_count < instance)
  220. return AE_BAD_PARAMETER;
  221. input.count = 2;
  222. input.pointer = params;
  223. params[0].type = ACPI_TYPE_INTEGER;
  224. params[0].integer.value = instance;
  225. params[1].type = ACPI_TYPE_INTEGER;
  226. params[1].integer.value = method_id;
  227. if (in) {
  228. input.count = 3;
  229. if (block->flags & ACPI_WMI_STRING) {
  230. params[2].type = ACPI_TYPE_STRING;
  231. } else {
  232. params[2].type = ACPI_TYPE_BUFFER;
  233. }
  234. params[2].buffer.length = in->length;
  235. params[2].buffer.pointer = in->pointer;
  236. }
  237. strncat(method, block->object_id, 2);
  238. status = acpi_evaluate_object(handle, method, &input, out);
  239. return status;
  240. }
  241. EXPORT_SYMBOL_GPL(wmi_evaluate_method);
  242. /**
  243. * wmi_query_block - Return contents of a WMI block
  244. * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
  245. * @instance: Instance index
  246. * &out: Empty buffer to return the contents of the data block to
  247. *
  248. * Return the contents of an ACPI-WMI data block to a buffer
  249. */
  250. acpi_status wmi_query_block(const char *guid_string, u8 instance,
  251. struct acpi_buffer *out)
  252. {
  253. struct guid_block *block = NULL;
  254. struct wmi_block *wblock = NULL;
  255. acpi_handle handle;
  256. acpi_status status, wc_status = AE_ERROR;
  257. struct acpi_object_list input, wc_input;
  258. union acpi_object wc_params[1], wq_params[1];
  259. char method[4];
  260. char wc_method[4] = "WC";
  261. if (!guid_string || !out)
  262. return AE_BAD_PARAMETER;
  263. if (!find_guid(guid_string, &wblock))
  264. return AE_BAD_ADDRESS;
  265. block = &wblock->gblock;
  266. handle = wblock->handle;
  267. if (block->instance_count < instance)
  268. return AE_BAD_PARAMETER;
  269. /* Check GUID is a data block */
  270. if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
  271. return AE_BAD_ADDRESS;
  272. input.count = 1;
  273. input.pointer = wq_params;
  274. wq_params[0].type = ACPI_TYPE_INTEGER;
  275. wq_params[0].integer.value = instance;
  276. /*
  277. * If ACPI_WMI_EXPENSIVE, call the relevant WCxx method first to
  278. * enable collection.
  279. */
  280. if (block->flags & ACPI_WMI_EXPENSIVE) {
  281. wc_input.count = 1;
  282. wc_input.pointer = wc_params;
  283. wc_params[0].type = ACPI_TYPE_INTEGER;
  284. wc_params[0].integer.value = 1;
  285. strncat(wc_method, block->object_id, 2);
  286. /*
  287. * Some GUIDs break the specification by declaring themselves
  288. * expensive, but have no corresponding WCxx method. So we
  289. * should not fail if this happens.
  290. */
  291. wc_status = acpi_evaluate_object(handle, wc_method,
  292. &wc_input, NULL);
  293. }
  294. strcpy(method, "WQ");
  295. strncat(method, block->object_id, 2);
  296. status = acpi_evaluate_object(handle, method, NULL, out);
  297. /*
  298. * If ACPI_WMI_EXPENSIVE, call the relevant WCxx method, even if
  299. * the WQxx method failed - we should disable collection anyway.
  300. */
  301. if ((block->flags & ACPI_WMI_EXPENSIVE) && wc_status) {
  302. wc_params[0].integer.value = 0;
  303. status = acpi_evaluate_object(handle,
  304. wc_method, &wc_input, NULL);
  305. }
  306. return status;
  307. }
  308. EXPORT_SYMBOL_GPL(wmi_query_block);
  309. /**
  310. * wmi_set_block - Write to a WMI block
  311. * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
  312. * @instance: Instance index
  313. * &in: Buffer containing new values for the data block
  314. *
  315. * Write the contents of the input buffer to an ACPI-WMI data block
  316. */
  317. acpi_status wmi_set_block(const char *guid_string, u8 instance,
  318. const struct acpi_buffer *in)
  319. {
  320. struct guid_block *block = NULL;
  321. struct wmi_block *wblock = NULL;
  322. acpi_handle handle;
  323. struct acpi_object_list input;
  324. union acpi_object params[2];
  325. char method[4] = "WS";
  326. if (!guid_string || !in)
  327. return AE_BAD_DATA;
  328. if (!find_guid(guid_string, &wblock))
  329. return AE_BAD_ADDRESS;
  330. block = &wblock->gblock;
  331. handle = wblock->handle;
  332. if (block->instance_count < instance)
  333. return AE_BAD_PARAMETER;
  334. /* Check GUID is a data block */
  335. if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
  336. return AE_BAD_ADDRESS;
  337. input.count = 2;
  338. input.pointer = params;
  339. params[0].type = ACPI_TYPE_INTEGER;
  340. params[0].integer.value = instance;
  341. if (block->flags & ACPI_WMI_STRING) {
  342. params[1].type = ACPI_TYPE_STRING;
  343. } else {
  344. params[1].type = ACPI_TYPE_BUFFER;
  345. }
  346. params[1].buffer.length = in->length;
  347. params[1].buffer.pointer = in->pointer;
  348. strncat(method, block->object_id, 2);
  349. return acpi_evaluate_object(handle, method, &input, NULL);
  350. }
  351. EXPORT_SYMBOL_GPL(wmi_set_block);
  352. /**
  353. * wmi_install_notify_handler - Register handler for WMI events
  354. * @handler: Function to handle notifications
  355. * @data: Data to be returned to handler when event is fired
  356. *
  357. * Register a handler for events sent to the ACPI-WMI mapper device.
  358. */
  359. acpi_status wmi_install_notify_handler(const char *guid,
  360. wmi_notify_handler handler, void *data)
  361. {
  362. struct wmi_block *block;
  363. if (!guid || !handler)
  364. return AE_BAD_PARAMETER;
  365. find_guid(guid, &block);
  366. if (!block)
  367. return AE_NOT_EXIST;
  368. if (block->handler)
  369. return AE_ALREADY_ACQUIRED;
  370. block->handler = handler;
  371. block->handler_data = data;
  372. return AE_OK;
  373. }
  374. EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
  375. /**
  376. * wmi_uninstall_notify_handler - Unregister handler for WMI events
  377. *
  378. * Unregister handler for events sent to the ACPI-WMI mapper device.
  379. */
  380. acpi_status wmi_remove_notify_handler(const char *guid)
  381. {
  382. struct wmi_block *block;
  383. if (!guid)
  384. return AE_BAD_PARAMETER;
  385. find_guid(guid, &block);
  386. if (!block)
  387. return AE_NOT_EXIST;
  388. if (!block->handler)
  389. return AE_NULL_ENTRY;
  390. block->handler = NULL;
  391. block->handler_data = NULL;
  392. return AE_OK;
  393. }
  394. EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
  395. /**
  396. * wmi_get_event_data - Get WMI data associated with an event
  397. *
  398. * @event - Event to find
  399. * &out - Buffer to hold event data
  400. *
  401. * Returns extra data associated with an event in WMI.
  402. */
  403. acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
  404. {
  405. struct acpi_object_list input;
  406. union acpi_object params[1];
  407. struct guid_block *gblock;
  408. struct wmi_block *wblock;
  409. struct list_head *p;
  410. input.count = 1;
  411. input.pointer = params;
  412. params[0].type = ACPI_TYPE_INTEGER;
  413. params[0].integer.value = event;
  414. list_for_each(p, &wmi_blocks.list) {
  415. wblock = list_entry(p, struct wmi_block, list);
  416. gblock = &wblock->gblock;
  417. if ((gblock->flags & ACPI_WMI_EVENT) &&
  418. (gblock->notify_id == event))
  419. return acpi_evaluate_object(wblock->handle, "_WED",
  420. &input, out);
  421. }
  422. return AE_NOT_FOUND;
  423. }
  424. EXPORT_SYMBOL_GPL(wmi_get_event_data);
  425. /**
  426. * wmi_has_guid - Check if a GUID is available
  427. * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
  428. *
  429. * Check if a given GUID is defined by _WDG
  430. */
  431. bool wmi_has_guid(const char *guid_string)
  432. {
  433. return find_guid(guid_string, NULL);
  434. }
  435. EXPORT_SYMBOL_GPL(wmi_has_guid);
  436. /*
  437. * Parse the _WDG method for the GUID data blocks
  438. */
  439. static __init acpi_status parse_wdg(acpi_handle handle)
  440. {
  441. struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
  442. union acpi_object *obj;
  443. struct guid_block *gblock;
  444. struct wmi_block *wblock;
  445. acpi_status status;
  446. u32 i, total;
  447. status = acpi_evaluate_object(handle, "_WDG", NULL, &out);
  448. if (ACPI_FAILURE(status))
  449. return status;
  450. obj = (union acpi_object *) out.pointer;
  451. if (obj->type != ACPI_TYPE_BUFFER)
  452. return AE_ERROR;
  453. total = obj->buffer.length / sizeof(struct guid_block);
  454. gblock = kzalloc(obj->buffer.length, GFP_KERNEL);
  455. if (!gblock)
  456. return AE_NO_MEMORY;
  457. memcpy(gblock, obj->buffer.pointer, obj->buffer.length);
  458. for (i = 0; i < total; i++) {
  459. wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
  460. if (!wblock)
  461. return AE_NO_MEMORY;
  462. wblock->gblock = gblock[i];
  463. wblock->handle = handle;
  464. list_add_tail(&wblock->list, &wmi_blocks.list);
  465. }
  466. kfree(out.pointer);
  467. kfree(gblock);
  468. return status;
  469. }
  470. /*
  471. * WMI can have EmbeddedControl access regions. In which case, we just want to
  472. * hand these off to the EC driver.
  473. */
  474. static acpi_status
  475. acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
  476. u32 bits, acpi_integer * value,
  477. void *handler_context, void *region_context)
  478. {
  479. int result = 0, i = 0;
  480. u8 temp = 0;
  481. if ((address > 0xFF) || !value)
  482. return AE_BAD_PARAMETER;
  483. if (function != ACPI_READ && function != ACPI_WRITE)
  484. return AE_BAD_PARAMETER;
  485. if (bits != 8)
  486. return AE_BAD_PARAMETER;
  487. if (function == ACPI_READ) {
  488. result = ec_read(address, &temp);
  489. (*value) |= ((acpi_integer)temp) << i;
  490. } else {
  491. temp = 0xff & ((*value) >> i);
  492. result = ec_write(address, temp);
  493. }
  494. switch (result) {
  495. case -EINVAL:
  496. return AE_BAD_PARAMETER;
  497. break;
  498. case -ENODEV:
  499. return AE_NOT_FOUND;
  500. break;
  501. case -ETIME:
  502. return AE_TIME;
  503. break;
  504. default:
  505. return AE_OK;
  506. }
  507. }
  508. static void acpi_wmi_notify(acpi_handle handle, u32 event, void *data)
  509. {
  510. struct guid_block *block;
  511. struct wmi_block *wblock;
  512. struct list_head *p;
  513. struct acpi_device *device = data;
  514. list_for_each(p, &wmi_blocks.list) {
  515. wblock = list_entry(p, struct wmi_block, list);
  516. block = &wblock->gblock;
  517. if ((block->flags & ACPI_WMI_EVENT) &&
  518. (block->notify_id == event)) {
  519. if (wblock->handler)
  520. wblock->handler(event, wblock->handler_data);
  521. acpi_bus_generate_netlink_event(
  522. device->pnp.device_class, device->dev.bus_id,
  523. event, 0);
  524. break;
  525. }
  526. }
  527. }
  528. static int acpi_wmi_remove(struct acpi_device *device, int type)
  529. {
  530. acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
  531. acpi_wmi_notify);
  532. acpi_remove_address_space_handler(device->handle,
  533. ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler);
  534. return 0;
  535. }
  536. static int __init acpi_wmi_add(struct acpi_device *device)
  537. {
  538. acpi_status status;
  539. int result = 0;
  540. status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
  541. acpi_wmi_notify, device);
  542. if (ACPI_FAILURE(status)) {
  543. printk(KERN_ERR PREFIX "Error installing notify handler\n");
  544. return -ENODEV;
  545. }
  546. status = acpi_install_address_space_handler(device->handle,
  547. ACPI_ADR_SPACE_EC,
  548. &acpi_wmi_ec_space_handler,
  549. NULL, NULL);
  550. if (ACPI_FAILURE(status))
  551. return -ENODEV;
  552. status = parse_wdg(device->handle);
  553. if (ACPI_FAILURE(status)) {
  554. printk(KERN_ERR PREFIX "Error installing EC region handler\n");
  555. return -ENODEV;
  556. }
  557. return result;
  558. }
  559. static int __init acpi_wmi_init(void)
  560. {
  561. acpi_status result;
  562. INIT_LIST_HEAD(&wmi_blocks.list);
  563. if (acpi_disabled)
  564. return -ENODEV;
  565. result = acpi_bus_register_driver(&acpi_wmi_driver);
  566. if (result < 0) {
  567. printk(KERN_INFO PREFIX "Error loading mapper\n");
  568. } else {
  569. printk(KERN_INFO PREFIX "Mapper loaded\n");
  570. }
  571. return result;
  572. }
  573. static void __exit acpi_wmi_exit(void)
  574. {
  575. struct list_head *p, *tmp;
  576. struct wmi_block *wblock;
  577. acpi_bus_unregister_driver(&acpi_wmi_driver);
  578. list_for_each_safe(p, tmp, &wmi_blocks.list) {
  579. wblock = list_entry(p, struct wmi_block, list);
  580. list_del(p);
  581. kfree(wblock);
  582. }
  583. printk(KERN_INFO PREFIX "Mapper unloaded\n");
  584. }
  585. subsys_initcall(acpi_wmi_init);
  586. module_exit(acpi_wmi_exit);