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