blob: 1a0bfd43f8f022d4a16b1a34eb992be69ae2ecb5 [file] [log] [blame]
Matthew Garrettad8f07c2009-01-07 18:08:56 -08001/*
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
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>
Stuart Hayes116ee772010-02-10 14:12:13 -050025#include <linux/mm.h>
Matthew Garrett814cb8a2009-12-09 18:23:36 +000026#include <linux/i8042.h>
Len Browncad73122009-01-09 17:23:38 -050027#include "../../firmware/dcdbas.h"
Matthew Garrettad8f07c2009-01-07 18:08:56 -080028
29#define BRIGHTNESS_TOKEN 0x7d
30
31/* This structure will be modified by the firmware when we enter
32 * system management mode, hence the volatiles */
33
34struct calling_interface_buffer {
35 u16 class;
36 u16 select;
37 volatile u32 input[4];
38 volatile u32 output[4];
39} __packed;
40
41struct calling_interface_token {
42 u16 tokenID;
43 u16 location;
44 union {
45 u16 value;
46 u16 stringlength;
47 };
48};
49
50struct calling_interface_structure {
51 struct dmi_header header;
52 u16 cmdIOAddress;
53 u8 cmdIOCode;
54 u32 supportedCmds;
55 struct calling_interface_token tokens[];
56} __packed;
57
58static int da_command_address;
59static int da_command_code;
60static int da_num_tokens;
61static struct calling_interface_token *da_tokens;
62
Alan Jenkinsada32482009-08-19 15:06:49 +010063static struct platform_driver platform_driver = {
64 .driver = {
65 .name = "dell-laptop",
66 .owner = THIS_MODULE,
67 }
68};
69
70static struct platform_device *platform_device;
Matthew Garrettad8f07c2009-01-07 18:08:56 -080071static struct backlight_device *dell_backlight_device;
72static struct rfkill *wifi_rfkill;
73static struct rfkill *bluetooth_rfkill;
74static struct rfkill *wwan_rfkill;
75
76static const struct dmi_system_id __initdata dell_device_table[] = {
77 {
78 .ident = "Dell laptop",
79 .matches = {
80 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
81 DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
82 },
83 },
84 { }
85};
86
Mario Limoncielloe5fefd02010-02-09 17:41:03 -050087static struct dmi_system_id __devinitdata dell_blacklist[] = {
88 /* Supported by compal-laptop */
89 {
90 .ident = "Dell Mini 9",
91 .matches = {
92 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
93 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 910"),
94 },
95 },
96 {
97 .ident = "Dell Mini 10",
98 .matches = {
99 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
100 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1010"),
101 },
102 },
103 {
104 .ident = "Dell Mini 10v",
105 .matches = {
106 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
107 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1011"),
108 },
109 },
110 {
111 .ident = "Dell Inspiron 11z",
112 .matches = {
113 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
114 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1110"),
115 },
116 },
117 {
118 .ident = "Dell Mini 12",
119 .matches = {
120 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
121 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1210"),
122 },
123 },
124 {}
125};
126
Stuart Hayes116ee772010-02-10 14:12:13 -0500127static struct calling_interface_buffer *buffer;
128struct page *bufferpage;
129DEFINE_MUTEX(buffer_mutex);
130
131static void get_buffer(void)
132{
133 mutex_lock(&buffer_mutex);
134 memset(buffer, 0, sizeof(struct calling_interface_buffer));
135}
136
137static void release_buffer(void)
138{
139 mutex_unlock(&buffer_mutex);
140}
141
Alan Jenkins4788df42009-08-19 15:06:50 +0100142static void __init parse_da_table(const struct dmi_header *dm)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800143{
144 /* Final token is a terminator, so we don't want to copy it */
145 int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1;
146 struct calling_interface_structure *table =
147 container_of(dm, struct calling_interface_structure, header);
148
149 /* 4 bytes of table header, plus 7 bytes of Dell header, plus at least
150 6 bytes of entry */
151
152 if (dm->length < 17)
153 return;
154
155 da_command_address = table->cmdIOAddress;
156 da_command_code = table->cmdIOCode;
157
158 da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
159 sizeof(struct calling_interface_token),
160 GFP_KERNEL);
161
162 if (!da_tokens)
163 return;
164
165 memcpy(da_tokens+da_num_tokens, table->tokens,
166 sizeof(struct calling_interface_token) * tokens);
167
168 da_num_tokens += tokens;
169}
170
Alan Jenkins4788df42009-08-19 15:06:50 +0100171static void __init find_tokens(const struct dmi_header *dm, void *dummy)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800172{
173 switch (dm->type) {
174 case 0xd4: /* Indexed IO */
175 break;
176 case 0xd5: /* Protected Area Type 1 */
177 break;
178 case 0xd6: /* Protected Area Type 2 */
179 break;
180 case 0xda: /* Calling interface */
181 parse_da_table(dm);
182 break;
183 }
184}
185
186static 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
194 return -1;
195}
196
197static struct calling_interface_buffer *
198dell_send_request(struct calling_interface_buffer *buffer, int class,
199 int select)
200{
201 struct smi_cmd command;
202
203 command.magic = SMI_CMD_MAGIC;
204 command.command_address = da_command_address;
205 command.command_code = da_command_code;
206 command.ebx = virt_to_phys(buffer);
207 command.ecx = 0x42534931;
208
209 buffer->class = class;
210 buffer->select = select;
211
212 dcdbas_smi_request(&command);
213
214 return buffer;
215}
216
217/* Derived from information in DellWirelessCtl.cpp:
218 Class 17, select 11 is radio control. It returns an array of 32-bit values.
219
220 result[0]: return code
221 result[1]:
222 Bit 0: Hardware switch supported
223 Bit 1: Wifi locator supported
224 Bit 2: Wifi is supported
225 Bit 3: Bluetooth is supported
226 Bit 4: WWAN is supported
227 Bit 5: Wireless keyboard supported
228 Bits 6-7: Reserved
229 Bit 8: Wifi is installed
230 Bit 9: Bluetooth is installed
231 Bit 10: WWAN is installed
232 Bits 11-15: Reserved
233 Bit 16: Hardware switch is on
234 Bit 17: Wifi is blocked
235 Bit 18: Bluetooth is blocked
236 Bit 19: WWAN is blocked
237 Bits 20-31: Reserved
238 result[2]: NVRAM size in bytes
239 result[3]: NVRAM format version number
240*/
241
Johannes Berg19d337d2009-06-02 13:01:37 +0200242static int dell_rfkill_set(void *data, bool blocked)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800243{
Johannes Berg624f0de2009-06-15 16:26:47 +0200244 int disable = blocked ? 1 : 0;
Johannes Berg19d337d2009-06-02 13:01:37 +0200245 unsigned long radio = (unsigned long)data;
Stuart Hayes116ee772010-02-10 14:12:13 -0500246 int ret = 0;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800247
Stuart Hayes116ee772010-02-10 14:12:13 -0500248 get_buffer();
249 dell_send_request(buffer, 17, 11);
Mario Limoncielloec1722a2010-02-09 14:11:05 -0500250
Stuart Hayes116ee772010-02-10 14:12:13 -0500251 if (!(buffer->output[1] & BIT(16))) {
252 ret = -EINVAL;
253 goto out;
254 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800255
Stuart Hayes116ee772010-02-10 14:12:13 -0500256 buffer->input[0] = (1 | (radio<<8) | (disable << 16));
257 dell_send_request(buffer, 17, 11);
258
259out:
260 release_buffer();
261 return ret;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800262}
263
Johannes Berg19d337d2009-06-02 13:01:37 +0200264static void dell_rfkill_query(struct rfkill *rfkill, void *data)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800265{
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800266 int status;
Johannes Berg19d337d2009-06-02 13:01:37 +0200267 int bit = (unsigned long)data + 16;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800268
Stuart Hayes116ee772010-02-10 14:12:13 -0500269 get_buffer();
270 dell_send_request(buffer, 17, 11);
271 status = buffer->output[1];
272 release_buffer();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800273
Matthew Garrette1fbf342009-07-31 03:25:38 +0100274 rfkill_set_sw_state(rfkill, !!(status & BIT(bit)));
275 rfkill_set_hw_state(rfkill, !(status & BIT(16)));
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800276}
277
Johannes Berg19d337d2009-06-02 13:01:37 +0200278static const struct rfkill_ops dell_rfkill_ops = {
279 .set_block = dell_rfkill_set,
280 .query = dell_rfkill_query,
281};
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800282
Matthew Garrett814cb8a2009-12-09 18:23:36 +0000283static void dell_update_rfkill(struct work_struct *ignored)
284{
285 if (wifi_rfkill)
286 dell_rfkill_query(wifi_rfkill, (void *)1);
287 if (bluetooth_rfkill)
288 dell_rfkill_query(bluetooth_rfkill, (void *)2);
289 if (wwan_rfkill)
290 dell_rfkill_query(wwan_rfkill, (void *)3);
291}
292static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill);
293
294
Alan Jenkins4788df42009-08-19 15:06:50 +0100295static int __init dell_setup_rfkill(void)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800296{
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800297 int status;
298 int ret;
299
Mario Limoncielloe5fefd02010-02-09 17:41:03 -0500300 if (dmi_check_system(dell_blacklist)) {
301 printk(KERN_INFO "dell-laptop: Blacklisted hardware detected - "
302 "not enabling rfkill\n");
303 return 0;
304 }
305
Stuart Hayes116ee772010-02-10 14:12:13 -0500306 get_buffer();
307 dell_send_request(buffer, 17, 11);
308 status = buffer->output[1];
309 release_buffer();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800310
311 if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
Alan Jenkinsada32482009-08-19 15:06:49 +0100312 wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev,
313 RFKILL_TYPE_WLAN,
Johannes Berg19d337d2009-06-02 13:01:37 +0200314 &dell_rfkill_ops, (void *) 1);
315 if (!wifi_rfkill) {
316 ret = -ENOMEM;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800317 goto err_wifi;
Johannes Berg19d337d2009-06-02 13:01:37 +0200318 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800319 ret = rfkill_register(wifi_rfkill);
320 if (ret)
321 goto err_wifi;
322 }
323
324 if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
Alan Jenkinsada32482009-08-19 15:06:49 +0100325 bluetooth_rfkill = rfkill_alloc("dell-bluetooth",
326 &platform_device->dev,
Johannes Berg19d337d2009-06-02 13:01:37 +0200327 RFKILL_TYPE_BLUETOOTH,
328 &dell_rfkill_ops, (void *) 2);
329 if (!bluetooth_rfkill) {
330 ret = -ENOMEM;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800331 goto err_bluetooth;
Johannes Berg19d337d2009-06-02 13:01:37 +0200332 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800333 ret = rfkill_register(bluetooth_rfkill);
334 if (ret)
335 goto err_bluetooth;
336 }
337
338 if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
Alan Jenkinsada32482009-08-19 15:06:49 +0100339 wwan_rfkill = rfkill_alloc("dell-wwan",
340 &platform_device->dev,
341 RFKILL_TYPE_WWAN,
Johannes Berg19d337d2009-06-02 13:01:37 +0200342 &dell_rfkill_ops, (void *) 3);
343 if (!wwan_rfkill) {
344 ret = -ENOMEM;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800345 goto err_wwan;
Johannes Berg19d337d2009-06-02 13:01:37 +0200346 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800347 ret = rfkill_register(wwan_rfkill);
348 if (ret)
349 goto err_wwan;
350 }
351
352 return 0;
353err_wwan:
Johannes Berg19d337d2009-06-02 13:01:37 +0200354 rfkill_destroy(wwan_rfkill);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800355 if (bluetooth_rfkill)
Johannes Berg19d337d2009-06-02 13:01:37 +0200356 rfkill_unregister(bluetooth_rfkill);
357err_bluetooth:
358 rfkill_destroy(bluetooth_rfkill);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800359 if (wifi_rfkill)
Johannes Berg19d337d2009-06-02 13:01:37 +0200360 rfkill_unregister(wifi_rfkill);
361err_wifi:
362 rfkill_destroy(wifi_rfkill);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800363
364 return ret;
365}
366
Alan Jenkins4311bb22009-08-19 15:06:48 +0100367static void dell_cleanup_rfkill(void)
368{
369 if (wifi_rfkill) {
370 rfkill_unregister(wifi_rfkill);
371 rfkill_destroy(wifi_rfkill);
372 }
373 if (bluetooth_rfkill) {
374 rfkill_unregister(bluetooth_rfkill);
375 rfkill_destroy(bluetooth_rfkill);
376 }
377 if (wwan_rfkill) {
378 rfkill_unregister(wwan_rfkill);
379 rfkill_destroy(wwan_rfkill);
380 }
381}
382
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800383static int dell_send_intensity(struct backlight_device *bd)
384{
Stuart Hayes116ee772010-02-10 14:12:13 -0500385 int ret = 0;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800386
Stuart Hayes116ee772010-02-10 14:12:13 -0500387 get_buffer();
388 buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
389 buffer->input[1] = bd->props.brightness;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800390
Stuart Hayes116ee772010-02-10 14:12:13 -0500391 if (buffer->input[0] == -1) {
392 ret = -ENODEV;
393 goto out;
394 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800395
396 if (power_supply_is_system_supplied() > 0)
Stuart Hayes116ee772010-02-10 14:12:13 -0500397 dell_send_request(buffer, 1, 2);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800398 else
Stuart Hayes116ee772010-02-10 14:12:13 -0500399 dell_send_request(buffer, 1, 1);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800400
Stuart Hayes116ee772010-02-10 14:12:13 -0500401out:
402 release_buffer();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800403 return 0;
404}
405
406static int dell_get_intensity(struct backlight_device *bd)
407{
Stuart Hayes116ee772010-02-10 14:12:13 -0500408 int ret = 0;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800409
Stuart Hayes116ee772010-02-10 14:12:13 -0500410 get_buffer();
411 buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800412
Stuart Hayes116ee772010-02-10 14:12:13 -0500413 if (buffer->input[0] == -1) {
414 ret = -ENODEV;
415 goto out;
416 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800417
418 if (power_supply_is_system_supplied() > 0)
Stuart Hayes116ee772010-02-10 14:12:13 -0500419 dell_send_request(buffer, 0, 2);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800420 else
Stuart Hayes116ee772010-02-10 14:12:13 -0500421 dell_send_request(buffer, 0, 1);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800422
Stuart Hayes116ee772010-02-10 14:12:13 -0500423out:
424 release_buffer();
425 if (ret)
426 return ret;
427 return buffer->output[1];
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800428}
429
430static struct backlight_ops dell_ops = {
431 .get_brightness = dell_get_intensity,
432 .update_status = dell_send_intensity,
433};
434
Matthew Garrett814cb8a2009-12-09 18:23:36 +0000435bool dell_laptop_i8042_filter(unsigned char data, unsigned char str,
436 struct serio *port)
437{
438 static bool extended;
439
440 if (str & 0x20)
441 return false;
442
443 if (unlikely(data == 0xe0)) {
444 extended = true;
445 return false;
446 } else if (unlikely(extended)) {
447 switch (data) {
448 case 0x8:
449 schedule_delayed_work(&dell_rfkill_work,
450 round_jiffies_relative(HZ));
451 break;
452 }
453 extended = false;
454 }
455
456 return false;
457}
458
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800459static int __init dell_init(void)
460{
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800461 int max_intensity = 0;
462 int ret;
463
464 if (!dmi_check_system(dell_device_table))
465 return -ENODEV;
466
Jean Delvaree7a19c562009-03-30 21:46:44 +0200467 dmi_walk(find_tokens, NULL);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800468
469 if (!da_tokens) {
470 printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n");
471 return -ENODEV;
472 }
473
Alan Jenkinsada32482009-08-19 15:06:49 +0100474 ret = platform_driver_register(&platform_driver);
475 if (ret)
476 goto fail_platform_driver;
477 platform_device = platform_device_alloc("dell-laptop", -1);
478 if (!platform_device) {
479 ret = -ENOMEM;
480 goto fail_platform_device1;
481 }
482 ret = platform_device_add(platform_device);
483 if (ret)
484 goto fail_platform_device2;
485
Stuart Hayes116ee772010-02-10 14:12:13 -0500486 /*
487 * Allocate buffer below 4GB for SMI data--only 32-bit physical addr
488 * is passed to SMI handler.
489 */
490 bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32);
491
492 if (!bufferpage)
493 goto fail_buffer;
494 buffer = page_address(bufferpage);
495 mutex_init(&buffer_mutex);
496
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800497 ret = dell_setup_rfkill();
498
499 if (ret) {
500 printk(KERN_WARNING "dell-laptop: Unable to setup rfkill\n");
Alan Jenkins71e9dc72009-08-19 15:06:47 +0100501 goto fail_rfkill;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800502 }
503
Matthew Garrett814cb8a2009-12-09 18:23:36 +0000504 ret = i8042_install_filter(dell_laptop_i8042_filter);
505 if (ret) {
506 printk(KERN_WARNING
507 "dell-laptop: Unable to install key filter\n");
508 goto fail_filter;
509 }
510
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800511#ifdef CONFIG_ACPI
512 /* In the event of an ACPI backlight being available, don't
513 * register the platform controller.
514 */
515 if (acpi_video_backlight_support())
516 return 0;
517#endif
518
Stuart Hayes116ee772010-02-10 14:12:13 -0500519 get_buffer();
520 buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
521 if (buffer->input[0] != -1) {
522 dell_send_request(buffer, 0, 2);
523 max_intensity = buffer->output[3];
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800524 }
Stuart Hayes116ee772010-02-10 14:12:13 -0500525 release_buffer();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800526
527 if (max_intensity) {
528 dell_backlight_device = backlight_device_register(
529 "dell_backlight",
Alan Jenkinsada32482009-08-19 15:06:49 +0100530 &platform_device->dev, NULL,
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800531 &dell_ops);
532
533 if (IS_ERR(dell_backlight_device)) {
534 ret = PTR_ERR(dell_backlight_device);
535 dell_backlight_device = NULL;
Alan Jenkins71e9dc72009-08-19 15:06:47 +0100536 goto fail_backlight;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800537 }
538
539 dell_backlight_device->props.max_brightness = max_intensity;
540 dell_backlight_device->props.brightness =
541 dell_get_intensity(dell_backlight_device);
542 backlight_update_status(dell_backlight_device);
543 }
544
545 return 0;
Alan Jenkins71e9dc72009-08-19 15:06:47 +0100546
547fail_backlight:
Matthew Garrett814cb8a2009-12-09 18:23:36 +0000548 i8042_remove_filter(dell_laptop_i8042_filter);
549fail_filter:
Alan Jenkins4311bb22009-08-19 15:06:48 +0100550 dell_cleanup_rfkill();
Alan Jenkins71e9dc72009-08-19 15:06:47 +0100551fail_rfkill:
Stuart Hayes116ee772010-02-10 14:12:13 -0500552 free_page((unsigned long)bufferpage);
553fail_buffer:
Alan Jenkinsada32482009-08-19 15:06:49 +0100554 platform_device_del(platform_device);
555fail_platform_device2:
556 platform_device_put(platform_device);
557fail_platform_device1:
558 platform_driver_unregister(&platform_driver);
559fail_platform_driver:
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800560 kfree(da_tokens);
561 return ret;
562}
563
564static void __exit dell_exit(void)
565{
Matthew Garrett814cb8a2009-12-09 18:23:36 +0000566 cancel_delayed_work_sync(&dell_rfkill_work);
567 i8042_remove_filter(dell_laptop_i8042_filter);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800568 backlight_device_unregister(dell_backlight_device);
Alan Jenkins4311bb22009-08-19 15:06:48 +0100569 dell_cleanup_rfkill();
Matthew Garrettfacd61d2010-02-09 14:03:04 -0500570 if (platform_device) {
571 platform_device_del(platform_device);
572 platform_driver_unregister(&platform_driver);
573 }
Matthew Garrette5512602010-02-09 14:05:01 -0500574 kfree(da_tokens);
Stuart Hayes116ee772010-02-10 14:12:13 -0500575 free_page((unsigned long)buffer);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800576}
577
578module_init(dell_init);
579module_exit(dell_exit);
580
581MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
582MODULE_DESCRIPTION("Dell laptop driver");
583MODULE_LICENSE("GPL");
584MODULE_ALIAS("dmi:*svnDellInc.:*:ct8:*");