dell-laptop.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. /*
  2. * Driver for Dell laptop extras
  3. *
  4. * Copyright (c) Red Hat <mjg@redhat.com>
  5. *
  6. * Based on documentation in the libsmbios package, Copyright (C) 2005 Dell
  7. * Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/backlight.h>
  19. #include <linux/err.h>
  20. #include <linux/dmi.h>
  21. #include <linux/io.h>
  22. #include <linux/rfkill.h>
  23. #include <linux/power_supply.h>
  24. #include <linux/acpi.h>
  25. #include <linux/mm.h>
  26. #include <linux/i8042.h>
  27. #include <linux/slab.h>
  28. #include <linux/debugfs.h>
  29. #include <linux/seq_file.h>
  30. #include "../../firmware/dcdbas.h"
  31. #define BRIGHTNESS_TOKEN 0x7d
  32. /* This structure will be modified by the firmware when we enter
  33. * system management mode, hence the volatiles */
  34. struct calling_interface_buffer {
  35. u16 class;
  36. u16 select;
  37. volatile u32 input[4];
  38. volatile u32 output[4];
  39. } __packed;
  40. struct calling_interface_token {
  41. u16 tokenID;
  42. u16 location;
  43. union {
  44. u16 value;
  45. u16 stringlength;
  46. };
  47. };
  48. struct calling_interface_structure {
  49. struct dmi_header header;
  50. u16 cmdIOAddress;
  51. u8 cmdIOCode;
  52. u32 supportedCmds;
  53. struct calling_interface_token tokens[];
  54. } __packed;
  55. static int da_command_address;
  56. static int da_command_code;
  57. static int da_num_tokens;
  58. static struct calling_interface_token *da_tokens;
  59. static struct platform_driver platform_driver = {
  60. .driver = {
  61. .name = "dell-laptop",
  62. .owner = THIS_MODULE,
  63. }
  64. };
  65. static struct platform_device *platform_device;
  66. static struct backlight_device *dell_backlight_device;
  67. static struct rfkill *wifi_rfkill;
  68. static struct rfkill *bluetooth_rfkill;
  69. static struct rfkill *wwan_rfkill;
  70. static const struct dmi_system_id __initdata dell_device_table[] = {
  71. {
  72. .ident = "Dell laptop",
  73. .matches = {
  74. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  75. DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
  76. },
  77. },
  78. {
  79. .matches = {
  80. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  81. DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /*Laptop*/
  82. },
  83. },
  84. {
  85. .ident = "Dell Computer Corporation",
  86. .matches = {
  87. DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
  88. DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
  89. },
  90. },
  91. { }
  92. };
  93. static struct dmi_system_id __devinitdata dell_blacklist[] = {
  94. /* Supported by compal-laptop */
  95. {
  96. .ident = "Dell Mini 9",
  97. .matches = {
  98. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  99. DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 910"),
  100. },
  101. },
  102. {
  103. .ident = "Dell Mini 10",
  104. .matches = {
  105. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  106. DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1010"),
  107. },
  108. },
  109. {
  110. .ident = "Dell Mini 10v",
  111. .matches = {
  112. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  113. DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1011"),
  114. },
  115. },
  116. {
  117. .ident = "Dell Mini 1012",
  118. .matches = {
  119. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  120. DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1012"),
  121. },
  122. },
  123. {
  124. .ident = "Dell Inspiron 11z",
  125. .matches = {
  126. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  127. DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1110"),
  128. },
  129. },
  130. {
  131. .ident = "Dell Mini 12",
  132. .matches = {
  133. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  134. DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1210"),
  135. },
  136. },
  137. {}
  138. };
  139. static struct calling_interface_buffer *buffer;
  140. static struct page *bufferpage;
  141. static DEFINE_MUTEX(buffer_mutex);
  142. static int hwswitch_state;
  143. static void get_buffer(void)
  144. {
  145. mutex_lock(&buffer_mutex);
  146. memset(buffer, 0, sizeof(struct calling_interface_buffer));
  147. }
  148. static void release_buffer(void)
  149. {
  150. mutex_unlock(&buffer_mutex);
  151. }
  152. static void __init parse_da_table(const struct dmi_header *dm)
  153. {
  154. /* Final token is a terminator, so we don't want to copy it */
  155. int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1;
  156. struct calling_interface_structure *table =
  157. container_of(dm, struct calling_interface_structure, header);
  158. /* 4 bytes of table header, plus 7 bytes of Dell header, plus at least
  159. 6 bytes of entry */
  160. if (dm->length < 17)
  161. return;
  162. da_command_address = table->cmdIOAddress;
  163. da_command_code = table->cmdIOCode;
  164. da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
  165. sizeof(struct calling_interface_token),
  166. GFP_KERNEL);
  167. if (!da_tokens)
  168. return;
  169. memcpy(da_tokens+da_num_tokens, table->tokens,
  170. sizeof(struct calling_interface_token) * tokens);
  171. da_num_tokens += tokens;
  172. }
  173. static void __init find_tokens(const struct dmi_header *dm, void *dummy)
  174. {
  175. switch (dm->type) {
  176. case 0xd4: /* Indexed IO */
  177. break;
  178. case 0xd5: /* Protected Area Type 1 */
  179. break;
  180. case 0xd6: /* Protected Area Type 2 */
  181. break;
  182. case 0xda: /* Calling interface */
  183. parse_da_table(dm);
  184. break;
  185. }
  186. }
  187. static int find_token_location(int tokenid)
  188. {
  189. int i;
  190. for (i = 0; i < da_num_tokens; i++) {
  191. if (da_tokens[i].tokenID == tokenid)
  192. return da_tokens[i].location;
  193. }
  194. return -1;
  195. }
  196. static struct calling_interface_buffer *
  197. dell_send_request(struct calling_interface_buffer *buffer, int class,
  198. int select)
  199. {
  200. struct smi_cmd command;
  201. command.magic = SMI_CMD_MAGIC;
  202. command.command_address = da_command_address;
  203. command.command_code = da_command_code;
  204. command.ebx = virt_to_phys(buffer);
  205. command.ecx = 0x42534931;
  206. buffer->class = class;
  207. buffer->select = select;
  208. dcdbas_smi_request(&command);
  209. return buffer;
  210. }
  211. /* Derived from information in DellWirelessCtl.cpp:
  212. Class 17, select 11 is radio control. It returns an array of 32-bit values.
  213. Input byte 0 = 0: Wireless information
  214. result[0]: return code
  215. result[1]:
  216. Bit 0: Hardware switch supported
  217. Bit 1: Wifi locator supported
  218. Bit 2: Wifi is supported
  219. Bit 3: Bluetooth is supported
  220. Bit 4: WWAN is supported
  221. Bit 5: Wireless keyboard supported
  222. Bits 6-7: Reserved
  223. Bit 8: Wifi is installed
  224. Bit 9: Bluetooth is installed
  225. Bit 10: WWAN is installed
  226. Bits 11-15: Reserved
  227. Bit 16: Hardware switch is on
  228. Bit 17: Wifi is blocked
  229. Bit 18: Bluetooth is blocked
  230. Bit 19: WWAN is blocked
  231. Bits 20-31: Reserved
  232. result[2]: NVRAM size in bytes
  233. result[3]: NVRAM format version number
  234. Input byte 0 = 2: Wireless switch configuration
  235. result[0]: return code
  236. result[1]:
  237. Bit 0: Wifi controlled by switch
  238. Bit 1: Bluetooth controlled by switch
  239. Bit 2: WWAN controlled by switch
  240. Bits 3-6: Reserved
  241. Bit 7: Wireless switch config locked
  242. Bit 8: Wifi locator enabled
  243. Bits 9-14: Reserved
  244. Bit 15: Wifi locator setting locked
  245. Bits 16-31: Reserved
  246. */
  247. static int dell_rfkill_set(void *data, bool blocked)
  248. {
  249. int disable = blocked ? 1 : 0;
  250. unsigned long radio = (unsigned long)data;
  251. int hwswitch_bit = (unsigned long)data - 1;
  252. int ret = 0;
  253. get_buffer();
  254. dell_send_request(buffer, 17, 11);
  255. /* If the hardware switch controls this radio, and the hardware
  256. switch is disabled, don't allow changing the software state */
  257. if ((hwswitch_state & BIT(hwswitch_bit)) &&
  258. !(buffer->output[1] & BIT(16))) {
  259. ret = -EINVAL;
  260. goto out;
  261. }
  262. buffer->input[0] = (1 | (radio<<8) | (disable << 16));
  263. dell_send_request(buffer, 17, 11);
  264. out:
  265. release_buffer();
  266. return ret;
  267. }
  268. static void dell_rfkill_query(struct rfkill *rfkill, void *data)
  269. {
  270. int status;
  271. int bit = (unsigned long)data + 16;
  272. int hwswitch_bit = (unsigned long)data - 1;
  273. get_buffer();
  274. dell_send_request(buffer, 17, 11);
  275. status = buffer->output[1];
  276. release_buffer();
  277. rfkill_set_sw_state(rfkill, !!(status & BIT(bit)));
  278. if (hwswitch_state & (BIT(hwswitch_bit)))
  279. rfkill_set_hw_state(rfkill, !(status & BIT(16)));
  280. }
  281. static const struct rfkill_ops dell_rfkill_ops = {
  282. .set_block = dell_rfkill_set,
  283. .query = dell_rfkill_query,
  284. };
  285. static struct dentry *dell_laptop_dir;
  286. static int dell_debugfs_show(struct seq_file *s, void *data)
  287. {
  288. int status;
  289. get_buffer();
  290. dell_send_request(buffer, 17, 11);
  291. status = buffer->output[1];
  292. release_buffer();
  293. seq_printf(s, "status:\t0x%X\n", status);
  294. seq_printf(s, "Bit 0 : Hardware switch supported: %lu\n",
  295. status & BIT(0));
  296. seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n",
  297. (status & BIT(1)) >> 1);
  298. seq_printf(s, "Bit 2 : Wifi is supported: %lu\n",
  299. (status & BIT(2)) >> 2);
  300. seq_printf(s, "Bit 3 : Bluetooth is supported: %lu\n",
  301. (status & BIT(3)) >> 3);
  302. seq_printf(s, "Bit 4 : WWAN is supported: %lu\n",
  303. (status & BIT(4)) >> 4);
  304. seq_printf(s, "Bit 5 : Wireless keyboard supported: %lu\n",
  305. (status & BIT(5)) >> 5);
  306. seq_printf(s, "Bit 8 : Wifi is installed: %lu\n",
  307. (status & BIT(8)) >> 8);
  308. seq_printf(s, "Bit 9 : Bluetooth is installed: %lu\n",
  309. (status & BIT(9)) >> 9);
  310. seq_printf(s, "Bit 10: WWAN is installed: %lu\n",
  311. (status & BIT(10)) >> 10);
  312. seq_printf(s, "Bit 16: Hardware switch is on: %lu\n",
  313. (status & BIT(16)) >> 16);
  314. seq_printf(s, "Bit 17: Wifi is blocked: %lu\n",
  315. (status & BIT(17)) >> 17);
  316. seq_printf(s, "Bit 18: Bluetooth is blocked: %lu\n",
  317. (status & BIT(18)) >> 18);
  318. seq_printf(s, "Bit 19: WWAN is blocked: %lu\n",
  319. (status & BIT(19)) >> 19);
  320. seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state);
  321. seq_printf(s, "Bit 0 : Wifi controlled by switch: %lu\n",
  322. hwswitch_state & BIT(0));
  323. seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n",
  324. (hwswitch_state & BIT(1)) >> 1);
  325. seq_printf(s, "Bit 2 : WWAN controlled by switch: %lu\n",
  326. (hwswitch_state & BIT(2)) >> 2);
  327. seq_printf(s, "Bit 7 : Wireless switch config locked: %lu\n",
  328. (hwswitch_state & BIT(7)) >> 7);
  329. seq_printf(s, "Bit 8 : Wifi locator enabled: %lu\n",
  330. (hwswitch_state & BIT(8)) >> 8);
  331. seq_printf(s, "Bit 15: Wifi locator setting locked: %lu\n",
  332. (hwswitch_state & BIT(15)) >> 15);
  333. return 0;
  334. }
  335. static int dell_debugfs_open(struct inode *inode, struct file *file)
  336. {
  337. return single_open(file, dell_debugfs_show, inode->i_private);
  338. }
  339. static const struct file_operations dell_debugfs_fops = {
  340. .owner = THIS_MODULE,
  341. .open = dell_debugfs_open,
  342. .read = seq_read,
  343. .llseek = seq_lseek,
  344. .release = single_release,
  345. };
  346. static void dell_update_rfkill(struct work_struct *ignored)
  347. {
  348. if (wifi_rfkill)
  349. dell_rfkill_query(wifi_rfkill, (void *)1);
  350. if (bluetooth_rfkill)
  351. dell_rfkill_query(bluetooth_rfkill, (void *)2);
  352. if (wwan_rfkill)
  353. dell_rfkill_query(wwan_rfkill, (void *)3);
  354. }
  355. static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill);
  356. static int __init dell_setup_rfkill(void)
  357. {
  358. int status;
  359. int ret;
  360. if (dmi_check_system(dell_blacklist)) {
  361. pr_info("Blacklisted hardware detected - not enabling rfkill\n");
  362. return 0;
  363. }
  364. get_buffer();
  365. dell_send_request(buffer, 17, 11);
  366. status = buffer->output[1];
  367. buffer->input[0] = 0x2;
  368. dell_send_request(buffer, 17, 11);
  369. hwswitch_state = buffer->output[1];
  370. release_buffer();
  371. if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
  372. wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev,
  373. RFKILL_TYPE_WLAN,
  374. &dell_rfkill_ops, (void *) 1);
  375. if (!wifi_rfkill) {
  376. ret = -ENOMEM;
  377. goto err_wifi;
  378. }
  379. ret = rfkill_register(wifi_rfkill);
  380. if (ret)
  381. goto err_wifi;
  382. }
  383. if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
  384. bluetooth_rfkill = rfkill_alloc("dell-bluetooth",
  385. &platform_device->dev,
  386. RFKILL_TYPE_BLUETOOTH,
  387. &dell_rfkill_ops, (void *) 2);
  388. if (!bluetooth_rfkill) {
  389. ret = -ENOMEM;
  390. goto err_bluetooth;
  391. }
  392. ret = rfkill_register(bluetooth_rfkill);
  393. if (ret)
  394. goto err_bluetooth;
  395. }
  396. if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
  397. wwan_rfkill = rfkill_alloc("dell-wwan",
  398. &platform_device->dev,
  399. RFKILL_TYPE_WWAN,
  400. &dell_rfkill_ops, (void *) 3);
  401. if (!wwan_rfkill) {
  402. ret = -ENOMEM;
  403. goto err_wwan;
  404. }
  405. ret = rfkill_register(wwan_rfkill);
  406. if (ret)
  407. goto err_wwan;
  408. }
  409. return 0;
  410. err_wwan:
  411. rfkill_destroy(wwan_rfkill);
  412. if (bluetooth_rfkill)
  413. rfkill_unregister(bluetooth_rfkill);
  414. err_bluetooth:
  415. rfkill_destroy(bluetooth_rfkill);
  416. if (wifi_rfkill)
  417. rfkill_unregister(wifi_rfkill);
  418. err_wifi:
  419. rfkill_destroy(wifi_rfkill);
  420. return ret;
  421. }
  422. static void dell_cleanup_rfkill(void)
  423. {
  424. if (wifi_rfkill) {
  425. rfkill_unregister(wifi_rfkill);
  426. rfkill_destroy(wifi_rfkill);
  427. }
  428. if (bluetooth_rfkill) {
  429. rfkill_unregister(bluetooth_rfkill);
  430. rfkill_destroy(bluetooth_rfkill);
  431. }
  432. if (wwan_rfkill) {
  433. rfkill_unregister(wwan_rfkill);
  434. rfkill_destroy(wwan_rfkill);
  435. }
  436. }
  437. static int dell_send_intensity(struct backlight_device *bd)
  438. {
  439. int ret = 0;
  440. get_buffer();
  441. buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
  442. buffer->input[1] = bd->props.brightness;
  443. if (buffer->input[0] == -1) {
  444. ret = -ENODEV;
  445. goto out;
  446. }
  447. if (power_supply_is_system_supplied() > 0)
  448. dell_send_request(buffer, 1, 2);
  449. else
  450. dell_send_request(buffer, 1, 1);
  451. out:
  452. release_buffer();
  453. return 0;
  454. }
  455. static int dell_get_intensity(struct backlight_device *bd)
  456. {
  457. int ret = 0;
  458. get_buffer();
  459. buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
  460. if (buffer->input[0] == -1) {
  461. ret = -ENODEV;
  462. goto out;
  463. }
  464. if (power_supply_is_system_supplied() > 0)
  465. dell_send_request(buffer, 0, 2);
  466. else
  467. dell_send_request(buffer, 0, 1);
  468. ret = buffer->output[1];
  469. out:
  470. release_buffer();
  471. return ret;
  472. }
  473. static const struct backlight_ops dell_ops = {
  474. .get_brightness = dell_get_intensity,
  475. .update_status = dell_send_intensity,
  476. };
  477. static bool dell_laptop_i8042_filter(unsigned char data, unsigned char str,
  478. struct serio *port)
  479. {
  480. static bool extended;
  481. if (str & 0x20)
  482. return false;
  483. if (unlikely(data == 0xe0)) {
  484. extended = true;
  485. return false;
  486. } else if (unlikely(extended)) {
  487. switch (data) {
  488. case 0x8:
  489. schedule_delayed_work(&dell_rfkill_work,
  490. round_jiffies_relative(HZ));
  491. break;
  492. }
  493. extended = false;
  494. }
  495. return false;
  496. }
  497. static int __init dell_init(void)
  498. {
  499. int max_intensity = 0;
  500. int ret;
  501. if (!dmi_check_system(dell_device_table))
  502. return -ENODEV;
  503. dmi_walk(find_tokens, NULL);
  504. if (!da_tokens) {
  505. pr_info("Unable to find dmi tokens\n");
  506. return -ENODEV;
  507. }
  508. ret = platform_driver_register(&platform_driver);
  509. if (ret)
  510. goto fail_platform_driver;
  511. platform_device = platform_device_alloc("dell-laptop", -1);
  512. if (!platform_device) {
  513. ret = -ENOMEM;
  514. goto fail_platform_device1;
  515. }
  516. ret = platform_device_add(platform_device);
  517. if (ret)
  518. goto fail_platform_device2;
  519. /*
  520. * Allocate buffer below 4GB for SMI data--only 32-bit physical addr
  521. * is passed to SMI handler.
  522. */
  523. bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32);
  524. if (!bufferpage)
  525. goto fail_buffer;
  526. buffer = page_address(bufferpage);
  527. ret = dell_setup_rfkill();
  528. if (ret) {
  529. pr_warn("Unable to setup rfkill\n");
  530. goto fail_rfkill;
  531. }
  532. ret = i8042_install_filter(dell_laptop_i8042_filter);
  533. if (ret) {
  534. pr_warn("Unable to install key filter\n");
  535. goto fail_filter;
  536. }
  537. dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
  538. if (dell_laptop_dir != NULL)
  539. debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
  540. &dell_debugfs_fops);
  541. #ifdef CONFIG_ACPI
  542. /* In the event of an ACPI backlight being available, don't
  543. * register the platform controller.
  544. */
  545. if (acpi_video_backlight_support())
  546. return 0;
  547. #endif
  548. get_buffer();
  549. buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
  550. if (buffer->input[0] != -1) {
  551. dell_send_request(buffer, 0, 2);
  552. max_intensity = buffer->output[3];
  553. }
  554. release_buffer();
  555. if (max_intensity) {
  556. struct backlight_properties props;
  557. memset(&props, 0, sizeof(struct backlight_properties));
  558. props.type = BACKLIGHT_PLATFORM;
  559. props.max_brightness = max_intensity;
  560. dell_backlight_device = backlight_device_register("dell_backlight",
  561. &platform_device->dev,
  562. NULL,
  563. &dell_ops,
  564. &props);
  565. if (IS_ERR(dell_backlight_device)) {
  566. ret = PTR_ERR(dell_backlight_device);
  567. dell_backlight_device = NULL;
  568. goto fail_backlight;
  569. }
  570. dell_backlight_device->props.brightness =
  571. dell_get_intensity(dell_backlight_device);
  572. backlight_update_status(dell_backlight_device);
  573. }
  574. return 0;
  575. fail_backlight:
  576. i8042_remove_filter(dell_laptop_i8042_filter);
  577. cancel_delayed_work_sync(&dell_rfkill_work);
  578. fail_filter:
  579. dell_cleanup_rfkill();
  580. fail_rfkill:
  581. free_page((unsigned long)bufferpage);
  582. fail_buffer:
  583. platform_device_del(platform_device);
  584. fail_platform_device2:
  585. platform_device_put(platform_device);
  586. fail_platform_device1:
  587. platform_driver_unregister(&platform_driver);
  588. fail_platform_driver:
  589. kfree(da_tokens);
  590. return ret;
  591. }
  592. static void __exit dell_exit(void)
  593. {
  594. debugfs_remove_recursive(dell_laptop_dir);
  595. i8042_remove_filter(dell_laptop_i8042_filter);
  596. cancel_delayed_work_sync(&dell_rfkill_work);
  597. backlight_device_unregister(dell_backlight_device);
  598. dell_cleanup_rfkill();
  599. if (platform_device) {
  600. platform_device_unregister(platform_device);
  601. platform_driver_unregister(&platform_driver);
  602. }
  603. kfree(da_tokens);
  604. free_page((unsigned long)buffer);
  605. }
  606. module_init(dell_init);
  607. module_exit(dell_exit);
  608. MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
  609. MODULE_DESCRIPTION("Dell laptop driver");
  610. MODULE_LICENSE("GPL");
  611. MODULE_ALIAS("dmi:*svnDellInc.:*:ct8:*");
  612. MODULE_ALIAS("dmi:*svnDellInc.:*:ct9:*");
  613. MODULE_ALIAS("dmi:*svnDellComputerCorporation.:*:ct8:*");