blob: 5f78aac9b163bf21c957f0beccbdff80d095228a [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
Joe Percheseb889522011-03-29 15:21:37 -070014#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
Matthew Garrettad8f07c2009-01-07 18:08:56 -080016#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/backlight.h>
21#include <linux/err.h>
22#include <linux/dmi.h>
23#include <linux/io.h>
Matthew Garrettad8f07c2009-01-07 18:08:56 -080024#include <linux/power_supply.h>
25#include <linux/acpi.h>
Stuart Hayes116ee772010-02-10 14:12:13 -050026#include <linux/mm.h>
Matthew Garrett814cb8a2009-12-09 18:23:36 +000027#include <linux/i8042.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090028#include <linux/slab.h>
Keng-Yu Lin037accf2010-09-28 11:43:31 +080029#include <linux/debugfs.h>
30#include <linux/seq_file.h>
Len Browncad73122009-01-09 17:23:38 -050031#include "../../firmware/dcdbas.h"
Matthew Garrettad8f07c2009-01-07 18:08:56 -080032
33#define BRIGHTNESS_TOKEN 0x7d
34
35/* This structure will be modified by the firmware when we enter
36 * system management mode, hence the volatiles */
37
38struct calling_interface_buffer {
39 u16 class;
40 u16 select;
41 volatile u32 input[4];
42 volatile u32 output[4];
43} __packed;
44
45struct calling_interface_token {
46 u16 tokenID;
47 u16 location;
48 union {
49 u16 value;
50 u16 stringlength;
51 };
52};
53
54struct calling_interface_structure {
55 struct dmi_header header;
56 u16 cmdIOAddress;
57 u8 cmdIOCode;
58 u32 supportedCmds;
59 struct calling_interface_token tokens[];
60} __packed;
61
AceLan Kao2d8b90b2011-10-04 16:25:44 +080062struct quirk_entry {
63 u8 touchpad_led;
64};
65
66static struct quirk_entry *quirks;
67
68static struct quirk_entry quirk_dell_vostro_v130 = {
69 .touchpad_led = 1,
70};
71
72static int dmi_matched(const struct dmi_system_id *dmi)
73{
74 quirks = dmi->driver_data;
75 return 1;
76}
77
Matthew Garrettad8f07c2009-01-07 18:08:56 -080078static int da_command_address;
79static int da_command_code;
80static int da_num_tokens;
81static struct calling_interface_token *da_tokens;
82
Alan Jenkinsada32482009-08-19 15:06:49 +010083static struct platform_driver platform_driver = {
84 .driver = {
85 .name = "dell-laptop",
86 .owner = THIS_MODULE,
87 }
88};
89
90static struct platform_device *platform_device;
Matthew Garrettad8f07c2009-01-07 18:08:56 -080091static struct backlight_device *dell_backlight_device;
Matthew Garrettad8f07c2009-01-07 18:08:56 -080092
Uwe Kleine-König145047d2012-03-30 22:05:04 +020093static const struct dmi_system_id dell_device_table[] __initconst = {
Matthew Garrettad8f07c2009-01-07 18:08:56 -080094 {
95 .ident = "Dell laptop",
96 .matches = {
97 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
98 DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
99 },
100 },
Erik Andrencb6a7932010-02-14 11:53:23 -0500101 {
Rezwanul Kabir410d44c2010-06-23 12:02:43 -0500102 .matches = {
103 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
104 DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /*Laptop*/
105 },
106 },
107 {
Erik Andrencb6a7932010-02-14 11:53:23 -0500108 .ident = "Dell Computer Corporation",
109 .matches = {
110 DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
111 DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
112 },
113 },
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800114 { }
115};
Dmitry Torokhov35ae64f2011-11-14 00:25:00 -0800116MODULE_DEVICE_TABLE(dmi, dell_device_table);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800117
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800118static struct dmi_system_id __devinitdata dell_quirks[] = {
119 {
120 .callback = dmi_matched,
121 .ident = "Dell Vostro V130",
122 .matches = {
123 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
124 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V130"),
125 },
126 .driver_data = &quirk_dell_vostro_v130,
127 },
128 {
129 .callback = dmi_matched,
130 .ident = "Dell Vostro V131",
131 .matches = {
132 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
133 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
134 },
135 .driver_data = &quirk_dell_vostro_v130,
136 },
AceLan Kao2a748852011-11-17 15:30:42 +0800137 {
138 .callback = dmi_matched,
Ang Way Chuang57b31b22012-04-12 13:11:27 +0800139 .ident = "Dell Vostro 3350",
140 .matches = {
141 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
142 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3350"),
143 },
144 .driver_data = &quirk_dell_vostro_v130,
145 },
146 {
147 .callback = dmi_matched,
AceLan Kao2a748852011-11-17 15:30:42 +0800148 .ident = "Dell Vostro 3555",
149 .matches = {
150 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
151 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3555"),
152 },
153 .driver_data = &quirk_dell_vostro_v130,
154 },
155 {
156 .callback = dmi_matched,
157 .ident = "Dell Inspiron N311z",
158 .matches = {
159 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
160 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N311z"),
161 },
162 .driver_data = &quirk_dell_vostro_v130,
163 },
164 {
165 .callback = dmi_matched,
166 .ident = "Dell Inspiron M5110",
167 .matches = {
168 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
169 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron M5110"),
170 },
171 .driver_data = &quirk_dell_vostro_v130,
172 },
AceLan Kao7f839222012-04-20 11:47:26 +0800173 {
174 .callback = dmi_matched,
175 .ident = "Dell Vostro 3360",
176 .matches = {
177 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
178 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3360"),
179 },
180 .driver_data = &quirk_dell_vostro_v130,
181 },
182 {
183 .callback = dmi_matched,
184 .ident = "Dell Vostro 3460",
185 .matches = {
186 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
187 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3460"),
188 },
189 .driver_data = &quirk_dell_vostro_v130,
190 },
191 {
192 .callback = dmi_matched,
193 .ident = "Dell Vostro 3560",
194 .matches = {
195 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
196 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3560"),
197 },
198 .driver_data = &quirk_dell_vostro_v130,
199 },
AceLan Kaod0e0a4772012-05-22 12:38:51 +0800200 {
201 .callback = dmi_matched,
202 .ident = "Dell Vostro 3450",
203 .matches = {
204 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
205 DMI_MATCH(DMI_PRODUCT_NAME, "Dell System Vostro 3450"),
206 },
207 .driver_data = &quirk_dell_vostro_v130,
208 },
Martin Nyhusd62d4212012-03-15 18:25:48 +0100209 { }
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800210};
211
Stuart Hayes116ee772010-02-10 14:12:13 -0500212static struct calling_interface_buffer *buffer;
Ingo Molnar94d8f782010-03-01 09:43:52 -0500213static struct page *bufferpage;
214static DEFINE_MUTEX(buffer_mutex);
Stuart Hayes116ee772010-02-10 14:12:13 -0500215
Matthew Garrettc6760ac2010-02-10 14:44:03 -0500216static int hwswitch_state;
217
Stuart Hayes116ee772010-02-10 14:12:13 -0500218static void get_buffer(void)
219{
220 mutex_lock(&buffer_mutex);
221 memset(buffer, 0, sizeof(struct calling_interface_buffer));
222}
223
224static void release_buffer(void)
225{
226 mutex_unlock(&buffer_mutex);
227}
228
Alan Jenkins4788df42009-08-19 15:06:50 +0100229static void __init parse_da_table(const struct dmi_header *dm)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800230{
231 /* Final token is a terminator, so we don't want to copy it */
232 int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1;
233 struct calling_interface_structure *table =
234 container_of(dm, struct calling_interface_structure, header);
235
236 /* 4 bytes of table header, plus 7 bytes of Dell header, plus at least
237 6 bytes of entry */
238
239 if (dm->length < 17)
240 return;
241
242 da_command_address = table->cmdIOAddress;
243 da_command_code = table->cmdIOCode;
244
245 da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
246 sizeof(struct calling_interface_token),
247 GFP_KERNEL);
248
249 if (!da_tokens)
250 return;
251
252 memcpy(da_tokens+da_num_tokens, table->tokens,
253 sizeof(struct calling_interface_token) * tokens);
254
255 da_num_tokens += tokens;
256}
257
Alan Jenkins4788df42009-08-19 15:06:50 +0100258static void __init find_tokens(const struct dmi_header *dm, void *dummy)
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800259{
260 switch (dm->type) {
261 case 0xd4: /* Indexed IO */
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800262 case 0xd5: /* Protected Area Type 1 */
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800263 case 0xd6: /* Protected Area Type 2 */
264 break;
265 case 0xda: /* Calling interface */
266 parse_da_table(dm);
267 break;
268 }
269}
270
271static int find_token_location(int tokenid)
272{
273 int i;
274 for (i = 0; i < da_num_tokens; i++) {
275 if (da_tokens[i].tokenID == tokenid)
276 return da_tokens[i].location;
277 }
278
279 return -1;
280}
281
282static struct calling_interface_buffer *
283dell_send_request(struct calling_interface_buffer *buffer, int class,
284 int select)
285{
286 struct smi_cmd command;
287
288 command.magic = SMI_CMD_MAGIC;
289 command.command_address = da_command_address;
290 command.command_code = da_command_code;
291 command.ebx = virt_to_phys(buffer);
292 command.ecx = 0x42534931;
293
294 buffer->class = class;
295 buffer->select = select;
296
297 dcdbas_smi_request(&command);
298
299 return buffer;
300}
301
Keng-Yu Lin037accf2010-09-28 11:43:31 +0800302static struct dentry *dell_laptop_dir;
303
304static int dell_debugfs_show(struct seq_file *s, void *data)
305{
306 int status;
307
308 get_buffer();
309 dell_send_request(buffer, 17, 11);
310 status = buffer->output[1];
311 release_buffer();
312
313 seq_printf(s, "status:\t0x%X\n", status);
314 seq_printf(s, "Bit 0 : Hardware switch supported: %lu\n",
315 status & BIT(0));
316 seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n",
317 (status & BIT(1)) >> 1);
318 seq_printf(s, "Bit 2 : Wifi is supported: %lu\n",
319 (status & BIT(2)) >> 2);
320 seq_printf(s, "Bit 3 : Bluetooth is supported: %lu\n",
321 (status & BIT(3)) >> 3);
322 seq_printf(s, "Bit 4 : WWAN is supported: %lu\n",
323 (status & BIT(4)) >> 4);
324 seq_printf(s, "Bit 5 : Wireless keyboard supported: %lu\n",
325 (status & BIT(5)) >> 5);
326 seq_printf(s, "Bit 8 : Wifi is installed: %lu\n",
327 (status & BIT(8)) >> 8);
328 seq_printf(s, "Bit 9 : Bluetooth is installed: %lu\n",
329 (status & BIT(9)) >> 9);
330 seq_printf(s, "Bit 10: WWAN is installed: %lu\n",
331 (status & BIT(10)) >> 10);
332 seq_printf(s, "Bit 16: Hardware switch is on: %lu\n",
333 (status & BIT(16)) >> 16);
334 seq_printf(s, "Bit 17: Wifi is blocked: %lu\n",
335 (status & BIT(17)) >> 17);
336 seq_printf(s, "Bit 18: Bluetooth is blocked: %lu\n",
337 (status & BIT(18)) >> 18);
338 seq_printf(s, "Bit 19: WWAN is blocked: %lu\n",
339 (status & BIT(19)) >> 19);
340
341 seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state);
342 seq_printf(s, "Bit 0 : Wifi controlled by switch: %lu\n",
343 hwswitch_state & BIT(0));
344 seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n",
345 (hwswitch_state & BIT(1)) >> 1);
346 seq_printf(s, "Bit 2 : WWAN controlled by switch: %lu\n",
347 (hwswitch_state & BIT(2)) >> 2);
348 seq_printf(s, "Bit 7 : Wireless switch config locked: %lu\n",
349 (hwswitch_state & BIT(7)) >> 7);
350 seq_printf(s, "Bit 8 : Wifi locator enabled: %lu\n",
351 (hwswitch_state & BIT(8)) >> 8);
352 seq_printf(s, "Bit 15: Wifi locator setting locked: %lu\n",
353 (hwswitch_state & BIT(15)) >> 15);
354
355 return 0;
356}
357
358static int dell_debugfs_open(struct inode *inode, struct file *file)
359{
360 return single_open(file, dell_debugfs_show, inode->i_private);
361}
362
363static const struct file_operations dell_debugfs_fops = {
364 .owner = THIS_MODULE,
365 .open = dell_debugfs_open,
366 .read = seq_read,
367 .llseek = seq_lseek,
368 .release = single_release,
369};
370
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800371static int dell_send_intensity(struct backlight_device *bd)
372{
Stuart Hayes116ee772010-02-10 14:12:13 -0500373 int ret = 0;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800374
Stuart Hayes116ee772010-02-10 14:12:13 -0500375 get_buffer();
376 buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
377 buffer->input[1] = bd->props.brightness;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800378
Stuart Hayes116ee772010-02-10 14:12:13 -0500379 if (buffer->input[0] == -1) {
380 ret = -ENODEV;
381 goto out;
382 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800383
384 if (power_supply_is_system_supplied() > 0)
Stuart Hayes116ee772010-02-10 14:12:13 -0500385 dell_send_request(buffer, 1, 2);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800386 else
Stuart Hayes116ee772010-02-10 14:12:13 -0500387 dell_send_request(buffer, 1, 1);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800388
Stuart Hayes116ee772010-02-10 14:12:13 -0500389out:
390 release_buffer();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800391 return 0;
392}
393
394static int dell_get_intensity(struct backlight_device *bd)
395{
Stuart Hayes116ee772010-02-10 14:12:13 -0500396 int ret = 0;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800397
Stuart Hayes116ee772010-02-10 14:12:13 -0500398 get_buffer();
399 buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800400
Stuart Hayes116ee772010-02-10 14:12:13 -0500401 if (buffer->input[0] == -1) {
402 ret = -ENODEV;
403 goto out;
404 }
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800405
406 if (power_supply_is_system_supplied() > 0)
Stuart Hayes116ee772010-02-10 14:12:13 -0500407 dell_send_request(buffer, 0, 2);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800408 else
Stuart Hayes116ee772010-02-10 14:12:13 -0500409 dell_send_request(buffer, 0, 1);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800410
Jose Alonsob4867422011-07-10 15:46:51 -0300411 ret = buffer->output[1];
412
Stuart Hayes116ee772010-02-10 14:12:13 -0500413out:
414 release_buffer();
Jose Alonsob4867422011-07-10 15:46:51 -0300415 return ret;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800416}
417
Lionel Debrouxacc24722010-11-16 14:14:02 +0100418static const struct backlight_ops dell_ops = {
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800419 .get_brightness = dell_get_intensity,
420 .update_status = dell_send_intensity,
421};
422
Randy Dunlap869f8df2011-11-16 18:20:51 -0800423static void touchpad_led_on(void)
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800424{
425 int command = 0x97;
426 char data = 1;
427 i8042_command(&data, command | 1 << 12);
428}
429
Randy Dunlap869f8df2011-11-16 18:20:51 -0800430static void touchpad_led_off(void)
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800431{
432 int command = 0x97;
433 char data = 2;
434 i8042_command(&data, command | 1 << 12);
435}
436
437static void touchpad_led_set(struct led_classdev *led_cdev,
438 enum led_brightness value)
439{
440 if (value > 0)
441 touchpad_led_on();
442 else
443 touchpad_led_off();
444}
445
446static struct led_classdev touchpad_led = {
447 .name = "dell-laptop::touchpad",
448 .brightness_set = touchpad_led_set,
AceLan Kao2d5de9e2012-01-17 16:18:06 +0800449 .flags = LED_CORE_SUSPENDRESUME,
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800450};
451
452static int __devinit touchpad_led_init(struct device *dev)
453{
454 return led_classdev_register(dev, &touchpad_led);
455}
456
457static void touchpad_led_exit(void)
458{
459 led_classdev_unregister(&touchpad_led);
460}
461
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800462static int __init dell_init(void)
463{
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800464 int max_intensity = 0;
465 int ret;
466
467 if (!dmi_check_system(dell_device_table))
468 return -ENODEV;
469
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800470 quirks = NULL;
471 /* find if this machine support other functions */
472 dmi_check_system(dell_quirks);
473
Jean Delvaree7a19c562009-03-30 21:46:44 +0200474 dmi_walk(find_tokens, NULL);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800475
476 if (!da_tokens) {
Joe Percheseb889522011-03-29 15:21:37 -0700477 pr_info("Unable to find dmi tokens\n");
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800478 return -ENODEV;
479 }
480
Alan Jenkinsada32482009-08-19 15:06:49 +0100481 ret = platform_driver_register(&platform_driver);
482 if (ret)
483 goto fail_platform_driver;
484 platform_device = platform_device_alloc("dell-laptop", -1);
485 if (!platform_device) {
486 ret = -ENOMEM;
487 goto fail_platform_device1;
488 }
489 ret = platform_device_add(platform_device);
490 if (ret)
491 goto fail_platform_device2;
492
Stuart Hayes116ee772010-02-10 14:12:13 -0500493 /*
494 * Allocate buffer below 4GB for SMI data--only 32-bit physical addr
495 * is passed to SMI handler.
496 */
497 bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32);
498
499 if (!bufferpage)
500 goto fail_buffer;
501 buffer = page_address(bufferpage);
Stuart Hayes116ee772010-02-10 14:12:13 -0500502
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800503 if (quirks && quirks->touchpad_led)
504 touchpad_led_init(&platform_device->dev);
505
Keng-Yu Lin037accf2010-09-28 11:43:31 +0800506 dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
Keng-Yu Lin037accf2010-09-28 11:43:31 +0800507
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800508#ifdef CONFIG_ACPI
509 /* In the event of an ACPI backlight being available, don't
510 * register the platform controller.
511 */
512 if (acpi_video_backlight_support())
513 return 0;
514#endif
515
Stuart Hayes116ee772010-02-10 14:12:13 -0500516 get_buffer();
517 buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
518 if (buffer->input[0] != -1) {
519 dell_send_request(buffer, 0, 2);
520 max_intensity = buffer->output[3];
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800521 }
Stuart Hayes116ee772010-02-10 14:12:13 -0500522 release_buffer();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800523
524 if (max_intensity) {
Matthew Garretta19a6ee2010-02-17 16:39:44 -0500525 struct backlight_properties props;
526 memset(&props, 0, sizeof(struct backlight_properties));
Matthew Garrettbb7ca742011-03-22 16:30:21 -0700527 props.type = BACKLIGHT_PLATFORM;
Matthew Garretta19a6ee2010-02-17 16:39:44 -0500528 props.max_brightness = max_intensity;
529 dell_backlight_device = backlight_device_register("dell_backlight",
530 &platform_device->dev,
531 NULL,
532 &dell_ops,
533 &props);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800534
535 if (IS_ERR(dell_backlight_device)) {
536 ret = PTR_ERR(dell_backlight_device);
537 dell_backlight_device = NULL;
Alan Jenkins71e9dc72009-08-19 15:06:47 +0100538 goto fail_backlight;
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800539 }
540
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800541 dell_backlight_device->props.brightness =
542 dell_get_intensity(dell_backlight_device);
543 backlight_update_status(dell_backlight_device);
544 }
545
546 return 0;
Alan Jenkins71e9dc72009-08-19 15:06:47 +0100547
548fail_backlight:
Stuart Hayes116ee772010-02-10 14:12:13 -0500549 free_page((unsigned long)bufferpage);
550fail_buffer:
Alan Jenkinsada32482009-08-19 15:06:49 +0100551 platform_device_del(platform_device);
552fail_platform_device2:
553 platform_device_put(platform_device);
554fail_platform_device1:
555 platform_driver_unregister(&platform_driver);
556fail_platform_driver:
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800557 kfree(da_tokens);
558 return ret;
559}
560
561static void __exit dell_exit(void)
562{
Keng-Yu Lin037accf2010-09-28 11:43:31 +0800563 debugfs_remove_recursive(dell_laptop_dir);
AceLan Kao2d8b90b2011-10-04 16:25:44 +0800564 if (quirks && quirks->touchpad_led)
565 touchpad_led_exit();
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800566 backlight_device_unregister(dell_backlight_device);
Matthew Garrettfacd61d2010-02-09 14:03:04 -0500567 if (platform_device) {
Matthew Garrett92e00e42010-03-01 09:46:43 -0500568 platform_device_unregister(platform_device);
Matthew Garrettfacd61d2010-02-09 14:03:04 -0500569 platform_driver_unregister(&platform_driver);
570 }
Matthew Garrette5512602010-02-09 14:05:01 -0500571 kfree(da_tokens);
Stuart Hayes116ee772010-02-10 14:12:13 -0500572 free_page((unsigned long)buffer);
Matthew Garrettad8f07c2009-01-07 18:08:56 -0800573}
574
575module_init(dell_init);
576module_exit(dell_exit);
577
578MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
579MODULE_DESCRIPTION("Dell laptop driver");
580MODULE_LICENSE("GPL");