wistron_btns.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*
  2. * Wistron laptop button driver
  3. * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
  4. * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
  5. * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
  6. *
  7. * You can redistribute and/or modify this program under the terms of the
  8. * GNU General Public License version 2 as published by the Free Software
  9. * Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  14. * Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. #include <linux/io.h>
  21. #include <linux/dmi.h>
  22. #include <linux/init.h>
  23. #include <linux/input.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/kernel.h>
  26. #include <linux/mc146818rtc.h>
  27. #include <linux/module.h>
  28. #include <linux/preempt.h>
  29. #include <linux/string.h>
  30. #include <linux/timer.h>
  31. #include <linux/types.h>
  32. #include <linux/platform_device.h>
  33. /*
  34. * Number of attempts to read data from queue per poll;
  35. * the queue can hold up to 31 entries
  36. */
  37. #define MAX_POLL_ITERATIONS 64
  38. #define POLL_FREQUENCY 10 /* Number of polls per second */
  39. #if POLL_FREQUENCY > HZ
  40. #error "POLL_FREQUENCY too high"
  41. #endif
  42. /* BIOS subsystem IDs */
  43. #define WIFI 0x35
  44. #define BLUETOOTH 0x34
  45. MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
  46. MODULE_DESCRIPTION("Wistron laptop button driver");
  47. MODULE_LICENSE("GPL v2");
  48. MODULE_VERSION("0.1");
  49. static int force; /* = 0; */
  50. module_param(force, bool, 0);
  51. MODULE_PARM_DESC(force, "Load even if computer is not in database");
  52. static char *keymap_name; /* = NULL; */
  53. module_param_named(keymap, keymap_name, charp, 0);
  54. MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected");
  55. static struct platform_device *wistron_device;
  56. /* BIOS interface implementation */
  57. static void __iomem *bios_entry_point; /* BIOS routine entry point */
  58. static void __iomem *bios_code_map_base;
  59. static void __iomem *bios_data_map_base;
  60. static u8 cmos_address;
  61. struct regs {
  62. u32 eax, ebx, ecx;
  63. };
  64. static void call_bios(struct regs *regs)
  65. {
  66. unsigned long flags;
  67. preempt_disable();
  68. local_irq_save(flags);
  69. asm volatile ("pushl %%ebp;"
  70. "movl %7, %%ebp;"
  71. "call *%6;"
  72. "popl %%ebp"
  73. : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx)
  74. : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
  75. "m" (bios_entry_point), "m" (bios_data_map_base)
  76. : "edx", "edi", "esi", "memory");
  77. local_irq_restore(flags);
  78. preempt_enable();
  79. }
  80. static ssize_t __init locate_wistron_bios(void __iomem *base)
  81. {
  82. static unsigned char __initdata signature[] =
  83. { 0x42, 0x21, 0x55, 0x30 };
  84. ssize_t offset;
  85. for (offset = 0; offset < 0x10000; offset += 0x10) {
  86. if (check_signature(base + offset, signature,
  87. sizeof(signature)) != 0)
  88. return offset;
  89. }
  90. return -1;
  91. }
  92. static int __init map_bios(void)
  93. {
  94. void __iomem *base;
  95. ssize_t offset;
  96. u32 entry_point;
  97. base = ioremap(0xF0000, 0x10000); /* Can't fail */
  98. offset = locate_wistron_bios(base);
  99. if (offset < 0) {
  100. printk(KERN_ERR "wistron_btns: BIOS entry point not found\n");
  101. iounmap(base);
  102. return -ENODEV;
  103. }
  104. entry_point = readl(base + offset + 5);
  105. printk(KERN_DEBUG
  106. "wistron_btns: BIOS signature found at %p, entry point %08X\n",
  107. base + offset, entry_point);
  108. if (entry_point >= 0xF0000) {
  109. bios_code_map_base = base;
  110. bios_entry_point = bios_code_map_base + (entry_point & 0xFFFF);
  111. } else {
  112. iounmap(base);
  113. bios_code_map_base = ioremap(entry_point & ~0x3FFF, 0x4000);
  114. if (bios_code_map_base == NULL) {
  115. printk(KERN_ERR
  116. "wistron_btns: Can't map BIOS code at %08X\n",
  117. entry_point & ~0x3FFF);
  118. goto err;
  119. }
  120. bios_entry_point = bios_code_map_base + (entry_point & 0x3FFF);
  121. }
  122. /* The Windows driver maps 0x10000 bytes, we keep only one page... */
  123. bios_data_map_base = ioremap(0x400, 0xc00);
  124. if (bios_data_map_base == NULL) {
  125. printk(KERN_ERR "wistron_btns: Can't map BIOS data\n");
  126. goto err_code;
  127. }
  128. return 0;
  129. err_code:
  130. iounmap(bios_code_map_base);
  131. err:
  132. return -ENOMEM;
  133. }
  134. static inline void unmap_bios(void)
  135. {
  136. iounmap(bios_code_map_base);
  137. iounmap(bios_data_map_base);
  138. }
  139. /* BIOS calls */
  140. static u16 bios_pop_queue(void)
  141. {
  142. struct regs regs;
  143. memset(&regs, 0, sizeof (regs));
  144. regs.eax = 0x9610;
  145. regs.ebx = 0x061C;
  146. regs.ecx = 0x0000;
  147. call_bios(&regs);
  148. return regs.eax;
  149. }
  150. static void __devinit bios_attach(void)
  151. {
  152. struct regs regs;
  153. memset(&regs, 0, sizeof (regs));
  154. regs.eax = 0x9610;
  155. regs.ebx = 0x012E;
  156. call_bios(&regs);
  157. }
  158. static void bios_detach(void)
  159. {
  160. struct regs regs;
  161. memset(&regs, 0, sizeof (regs));
  162. regs.eax = 0x9610;
  163. regs.ebx = 0x002E;
  164. call_bios(&regs);
  165. }
  166. static u8 __devinit bios_get_cmos_address(void)
  167. {
  168. struct regs regs;
  169. memset(&regs, 0, sizeof (regs));
  170. regs.eax = 0x9610;
  171. regs.ebx = 0x051C;
  172. call_bios(&regs);
  173. return regs.ecx;
  174. }
  175. static u16 __devinit bios_get_default_setting(u8 subsys)
  176. {
  177. struct regs regs;
  178. memset(&regs, 0, sizeof (regs));
  179. regs.eax = 0x9610;
  180. regs.ebx = 0x0200 | subsys;
  181. call_bios(&regs);
  182. return regs.eax;
  183. }
  184. static void bios_set_state(u8 subsys, int enable)
  185. {
  186. struct regs regs;
  187. memset(&regs, 0, sizeof (regs));
  188. regs.eax = 0x9610;
  189. regs.ebx = (enable ? 0x0100 : 0x0000) | subsys;
  190. call_bios(&regs);
  191. }
  192. /* Hardware database */
  193. struct key_entry {
  194. char type; /* See KE_* below */
  195. u8 code;
  196. unsigned keycode; /* For KE_KEY */
  197. };
  198. enum { KE_END, KE_KEY, KE_WIFI, KE_BLUETOOTH };
  199. static const struct key_entry *keymap; /* = NULL; Current key map */
  200. static int have_wifi;
  201. static int have_bluetooth;
  202. static int __init dmi_matched(struct dmi_system_id *dmi)
  203. {
  204. const struct key_entry *key;
  205. keymap = dmi->driver_data;
  206. for (key = keymap; key->type != KE_END; key++) {
  207. if (key->type == KE_WIFI)
  208. have_wifi = 1;
  209. else if (key->type == KE_BLUETOOTH)
  210. have_bluetooth = 1;
  211. }
  212. return 1;
  213. }
  214. static struct key_entry keymap_empty[] = {
  215. { KE_END, 0 }
  216. };
  217. static struct key_entry keymap_fs_amilo_pro_v2000[] = {
  218. { KE_KEY, 0x01, KEY_HELP },
  219. { KE_KEY, 0x11, KEY_PROG1 },
  220. { KE_KEY, 0x12, KEY_PROG2 },
  221. { KE_WIFI, 0x30, 0 },
  222. { KE_KEY, 0x31, KEY_MAIL },
  223. { KE_KEY, 0x36, KEY_WWW },
  224. { KE_END, 0 }
  225. };
  226. static struct key_entry keymap_fujitsu_n3510[] = {
  227. { KE_KEY, 0x11, KEY_PROG1 },
  228. { KE_KEY, 0x12, KEY_PROG2 },
  229. { KE_KEY, 0x36, KEY_WWW },
  230. { KE_KEY, 0x31, KEY_MAIL },
  231. { KE_KEY, 0x71, KEY_STOPCD },
  232. { KE_KEY, 0x72, KEY_PLAYPAUSE },
  233. { KE_KEY, 0x74, KEY_REWIND },
  234. { KE_KEY, 0x78, KEY_FORWARD },
  235. { KE_END, 0 }
  236. };
  237. static struct key_entry keymap_wistron_ms2111[] = {
  238. { KE_KEY, 0x11, KEY_PROG1 },
  239. { KE_KEY, 0x12, KEY_PROG2 },
  240. { KE_KEY, 0x13, KEY_PROG3 },
  241. { KE_KEY, 0x31, KEY_MAIL },
  242. { KE_KEY, 0x36, KEY_WWW },
  243. { KE_END, 0 }
  244. };
  245. static struct key_entry keymap_wistron_ms2141[] = {
  246. { KE_KEY, 0x11, KEY_PROG1 },
  247. { KE_KEY, 0x12, KEY_PROG2 },
  248. { KE_WIFI, 0x30, 0 },
  249. { KE_KEY, 0x22, KEY_REWIND },
  250. { KE_KEY, 0x23, KEY_FORWARD },
  251. { KE_KEY, 0x24, KEY_PLAYPAUSE },
  252. { KE_KEY, 0x25, KEY_STOPCD },
  253. { KE_KEY, 0x31, KEY_MAIL },
  254. { KE_KEY, 0x36, KEY_WWW },
  255. { KE_END, 0 }
  256. };
  257. static struct key_entry keymap_acer_aspire_1500[] = {
  258. { KE_KEY, 0x11, KEY_PROG1 },
  259. { KE_KEY, 0x12, KEY_PROG2 },
  260. { KE_WIFI, 0x30, 0 },
  261. { KE_KEY, 0x31, KEY_MAIL },
  262. { KE_KEY, 0x36, KEY_WWW },
  263. { KE_BLUETOOTH, 0x44, 0 },
  264. { KE_END, 0 }
  265. };
  266. static struct key_entry keymap_acer_travelmate_240[] = {
  267. { KE_KEY, 0x31, KEY_MAIL },
  268. { KE_KEY, 0x36, KEY_WWW },
  269. { KE_KEY, 0x11, KEY_PROG1 },
  270. { KE_KEY, 0x12, KEY_PROG2 },
  271. { KE_BLUETOOTH, 0x44, 0 },
  272. { KE_WIFI, 0x30, 0 },
  273. { KE_END, 0 }
  274. };
  275. static struct key_entry keymap_aopen_1559as[] = {
  276. { KE_KEY, 0x01, KEY_HELP },
  277. { KE_KEY, 0x06, KEY_PROG3 },
  278. { KE_KEY, 0x11, KEY_PROG1 },
  279. { KE_KEY, 0x12, KEY_PROG2 },
  280. { KE_WIFI, 0x30, 0 },
  281. { KE_KEY, 0x31, KEY_MAIL },
  282. { KE_KEY, 0x36, KEY_WWW },
  283. { KE_END, 0 },
  284. };
  285. static struct key_entry keymap_fs_amilo_d88x0[] = {
  286. { KE_KEY, 0x01, KEY_HELP },
  287. { KE_KEY, 0x08, KEY_MUTE },
  288. { KE_KEY, 0x31, KEY_MAIL },
  289. { KE_KEY, 0x36, KEY_WWW },
  290. { KE_KEY, 0x11, KEY_PROG1 },
  291. { KE_KEY, 0x12, KEY_PROG2 },
  292. { KE_KEY, 0x13, KEY_PROG3 },
  293. { KE_END, 0 }
  294. };
  295. /*
  296. * If your machine is not here (which is currently rather likely), please send
  297. * a list of buttons and their key codes (reported when loading this module
  298. * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
  299. */
  300. static struct dmi_system_id dmi_ids[] __initdata = {
  301. {
  302. .callback = dmi_matched,
  303. .ident = "Fujitsu-Siemens Amilo Pro V2000",
  304. .matches = {
  305. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  306. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"),
  307. },
  308. .driver_data = keymap_fs_amilo_pro_v2000
  309. },
  310. {
  311. .callback = dmi_matched,
  312. .ident = "Fujitsu-Siemens Amilo M7400",
  313. .matches = {
  314. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  315. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO M "),
  316. },
  317. .driver_data = keymap_fs_amilo_pro_v2000
  318. },
  319. {
  320. .callback = dmi_matched,
  321. .ident = "Fujitsu N3510",
  322. .matches = {
  323. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  324. DMI_MATCH(DMI_PRODUCT_NAME, "N3510"),
  325. },
  326. .driver_data = keymap_fujitsu_n3510
  327. },
  328. {
  329. .callback = dmi_matched,
  330. .ident = "Acer Aspire 1500",
  331. .matches = {
  332. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  333. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"),
  334. },
  335. .driver_data = keymap_acer_aspire_1500
  336. },
  337. {
  338. .callback = dmi_matched,
  339. .ident = "Acer TravelMate 240",
  340. .matches = {
  341. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  342. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 240"),
  343. },
  344. .driver_data = keymap_acer_travelmate_240
  345. },
  346. {
  347. .callback = dmi_matched,
  348. .ident = "Acer TravelMate 2424NWXCi",
  349. .matches = {
  350. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  351. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2420"),
  352. },
  353. .driver_data = keymap_acer_travelmate_240
  354. },
  355. {
  356. .callback = dmi_matched,
  357. .ident = "AOpen 1559AS",
  358. .matches = {
  359. DMI_MATCH(DMI_PRODUCT_NAME, "E2U"),
  360. DMI_MATCH(DMI_BOARD_NAME, "E2U"),
  361. },
  362. .driver_data = keymap_aopen_1559as
  363. },
  364. {
  365. .callback = dmi_matched,
  366. .ident = "Medion MD 9783",
  367. .matches = {
  368. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  369. DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"),
  370. },
  371. .driver_data = keymap_wistron_ms2111
  372. },
  373. {
  374. .callback = dmi_matched,
  375. .ident = "Fujitsu Siemens Amilo D88x0",
  376. .matches = {
  377. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  378. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO D"),
  379. },
  380. .driver_data = keymap_fs_amilo_d88x0
  381. },
  382. { NULL, }
  383. };
  384. static int __init select_keymap(void)
  385. {
  386. if (keymap_name != NULL) {
  387. if (strcmp (keymap_name, "1557/MS2141") == 0)
  388. keymap = keymap_wistron_ms2141;
  389. else {
  390. printk(KERN_ERR "wistron_btns: Keymap unknown\n");
  391. return -EINVAL;
  392. }
  393. }
  394. dmi_check_system(dmi_ids);
  395. if (keymap == NULL) {
  396. if (!force) {
  397. printk(KERN_ERR "wistron_btns: System unknown\n");
  398. return -ENODEV;
  399. }
  400. keymap = keymap_empty;
  401. }
  402. return 0;
  403. }
  404. /* Input layer interface */
  405. static struct input_dev *input_dev;
  406. static int __devinit setup_input_dev(void)
  407. {
  408. const struct key_entry *key;
  409. int error;
  410. input_dev = input_allocate_device();
  411. if (!input_dev)
  412. return -ENOMEM;
  413. input_dev->name = "Wistron laptop buttons";
  414. input_dev->phys = "wistron/input0";
  415. input_dev->id.bustype = BUS_HOST;
  416. input_dev->cdev.dev = &wistron_device->dev;
  417. for (key = keymap; key->type != KE_END; key++) {
  418. if (key->type == KE_KEY) {
  419. input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY);
  420. set_bit(key->keycode, input_dev->keybit);
  421. }
  422. }
  423. error = input_register_device(input_dev);
  424. if (error) {
  425. input_free_device(input_dev);
  426. return error;
  427. }
  428. return 0;
  429. }
  430. static void report_key(unsigned keycode)
  431. {
  432. input_report_key(input_dev, keycode, 1);
  433. input_sync(input_dev);
  434. input_report_key(input_dev, keycode, 0);
  435. input_sync(input_dev);
  436. }
  437. /* Driver core */
  438. static int wifi_enabled;
  439. static int bluetooth_enabled;
  440. static void poll_bios(unsigned long);
  441. static struct timer_list poll_timer = TIMER_INITIALIZER(poll_bios, 0, 0);
  442. static void handle_key(u8 code)
  443. {
  444. const struct key_entry *key;
  445. for (key = keymap; key->type != KE_END; key++) {
  446. if (code == key->code) {
  447. switch (key->type) {
  448. case KE_KEY:
  449. report_key(key->keycode);
  450. break;
  451. case KE_WIFI:
  452. if (have_wifi) {
  453. wifi_enabled = !wifi_enabled;
  454. bios_set_state(WIFI, wifi_enabled);
  455. }
  456. break;
  457. case KE_BLUETOOTH:
  458. if (have_bluetooth) {
  459. bluetooth_enabled = !bluetooth_enabled;
  460. bios_set_state(BLUETOOTH, bluetooth_enabled);
  461. }
  462. break;
  463. case KE_END:
  464. default:
  465. BUG();
  466. }
  467. return;
  468. }
  469. }
  470. printk(KERN_NOTICE "wistron_btns: Unknown key code %02X\n", code);
  471. }
  472. static void poll_bios(unsigned long discard)
  473. {
  474. u8 qlen;
  475. u16 val;
  476. for (;;) {
  477. qlen = CMOS_READ(cmos_address);
  478. if (qlen == 0)
  479. break;
  480. val = bios_pop_queue();
  481. if (val != 0 && !discard)
  482. handle_key((u8)val);
  483. }
  484. mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
  485. }
  486. static int __devinit wistron_probe(struct platform_device *dev)
  487. {
  488. int err = setup_input_dev();
  489. if (err)
  490. return err;
  491. bios_attach();
  492. cmos_address = bios_get_cmos_address();
  493. if (have_wifi) {
  494. u16 wifi = bios_get_default_setting(WIFI);
  495. if (wifi & 1)
  496. wifi_enabled = (wifi & 2) ? 1 : 0;
  497. else
  498. have_wifi = 0;
  499. if (have_wifi)
  500. bios_set_state(WIFI, wifi_enabled);
  501. }
  502. if (have_bluetooth) {
  503. u16 bt = bios_get_default_setting(BLUETOOTH);
  504. if (bt & 1)
  505. bluetooth_enabled = (bt & 2) ? 1 : 0;
  506. else
  507. have_bluetooth = 0;
  508. if (have_bluetooth)
  509. bios_set_state(BLUETOOTH, bluetooth_enabled);
  510. }
  511. poll_bios(1); /* Flush stale event queue and arm timer */
  512. return 0;
  513. }
  514. static int __devexit wistron_remove(struct platform_device *dev)
  515. {
  516. del_timer_sync(&poll_timer);
  517. input_unregister_device(input_dev);
  518. bios_detach();
  519. return 0;
  520. }
  521. #ifdef CONFIG_PM
  522. static int wistron_suspend(struct platform_device *dev, pm_message_t state)
  523. {
  524. del_timer_sync(&poll_timer);
  525. if (have_wifi)
  526. bios_set_state(WIFI, 0);
  527. if (have_bluetooth)
  528. bios_set_state(BLUETOOTH, 0);
  529. return 0;
  530. }
  531. static int wistron_resume(struct platform_device *dev)
  532. {
  533. if (have_wifi)
  534. bios_set_state(WIFI, wifi_enabled);
  535. if (have_bluetooth)
  536. bios_set_state(BLUETOOTH, bluetooth_enabled);
  537. poll_bios(1);
  538. return 0;
  539. }
  540. #else
  541. #define wistron_suspend NULL
  542. #define wistron_resume NULL
  543. #endif
  544. static struct platform_driver wistron_driver = {
  545. .driver = {
  546. .name = "wistron-bios",
  547. .owner = THIS_MODULE,
  548. },
  549. .probe = wistron_probe,
  550. .remove = __devexit_p(wistron_remove),
  551. .suspend = wistron_suspend,
  552. .resume = wistron_resume,
  553. };
  554. static int __init wb_module_init(void)
  555. {
  556. int err;
  557. err = select_keymap();
  558. if (err)
  559. return err;
  560. err = map_bios();
  561. if (err)
  562. return err;
  563. err = platform_driver_register(&wistron_driver);
  564. if (err)
  565. goto err_unmap_bios;
  566. wistron_device = platform_device_alloc("wistron-bios", -1);
  567. if (!wistron_device) {
  568. err = -ENOMEM;
  569. goto err_unregister_driver;
  570. }
  571. err = platform_device_add(wistron_device);
  572. if (err)
  573. goto err_free_device;
  574. return 0;
  575. err_free_device:
  576. platform_device_put(wistron_device);
  577. err_unregister_driver:
  578. platform_driver_unregister(&wistron_driver);
  579. err_unmap_bios:
  580. unmap_bios();
  581. return err;
  582. }
  583. static void __exit wb_module_exit(void)
  584. {
  585. platform_device_unregister(wistron_device);
  586. platform_driver_unregister(&wistron_driver);
  587. unmap_bios();
  588. }
  589. module_init(wb_module_init);
  590. module_exit(wb_module_exit);