Linux 3.4.102
[linux/fpc-iii.git] / drivers / platform / x86 / samsung-laptop.c
blobde9f432cf22d10fabc0b9ca3b5782ebdd602fabb
1 /*
2 * Samsung Laptop driver
4 * Copyright (C) 2009,2011 Greg Kroah-Hartman (gregkh@suse.de)
5 * Copyright (C) 2009,2011 Novell Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/delay.h>
18 #include <linux/pci.h>
19 #include <linux/backlight.h>
20 #include <linux/leds.h>
21 #include <linux/fb.h>
22 #include <linux/dmi.h>
23 #include <linux/platform_device.h>
24 #include <linux/rfkill.h>
25 #include <linux/acpi.h>
26 #include <linux/seq_file.h>
27 #include <linux/debugfs.h>
28 #include <linux/ctype.h>
29 #include <linux/efi.h>
30 #if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE)
31 #include <acpi/video.h>
32 #endif
35 * This driver is needed because a number of Samsung laptops do not hook
36 * their control settings through ACPI. So we have to poke around in the
37 * BIOS to do things like brightness values, and "special" key controls.
41 * We have 0 - 8 as valid brightness levels. The specs say that level 0 should
42 * be reserved by the BIOS (which really doesn't make much sense), we tell
43 * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8
45 #define MAX_BRIGHT 0x07
48 #define SABI_IFACE_MAIN 0x00
49 #define SABI_IFACE_SUB 0x02
50 #define SABI_IFACE_COMPLETE 0x04
51 #define SABI_IFACE_DATA 0x05
53 #define WL_STATUS_WLAN 0x0
54 #define WL_STATUS_BT 0x2
56 /* Structure get/set data using sabi */
57 struct sabi_data {
58 union {
59 struct {
60 u32 d0;
61 u32 d1;
62 u16 d2;
63 u8 d3;
65 u8 data[11];
69 struct sabi_header_offsets {
70 u8 port;
71 u8 re_mem;
72 u8 iface_func;
73 u8 en_mem;
74 u8 data_offset;
75 u8 data_segment;
78 struct sabi_commands {
80 * Brightness is 0 - 8, as described above.
81 * Value 0 is for the BIOS to use
83 u16 get_brightness;
84 u16 set_brightness;
87 * first byte:
88 * 0x00 - wireless is off
89 * 0x01 - wireless is on
90 * second byte:
91 * 0x02 - 3G is off
92 * 0x03 - 3G is on
93 * TODO, verify 3G is correct, that doesn't seem right...
95 u16 get_wireless_button;
96 u16 set_wireless_button;
98 /* 0 is off, 1 is on */
99 u16 get_backlight;
100 u16 set_backlight;
103 * 0x80 or 0x00 - no action
104 * 0x81 - recovery key pressed
106 u16 get_recovery_mode;
107 u16 set_recovery_mode;
110 * on seclinux: 0 is low, 1 is high,
111 * on swsmi: 0 is normal, 1 is silent, 2 is turbo
113 u16 get_performance_level;
114 u16 set_performance_level;
116 /* 0x80 is off, 0x81 is on */
117 u16 get_battery_life_extender;
118 u16 set_battery_life_extender;
120 /* 0x80 is off, 0x81 is on */
121 u16 get_usb_charge;
122 u16 set_usb_charge;
124 /* the first byte is for bluetooth and the third one is for wlan */
125 u16 get_wireless_status;
126 u16 set_wireless_status;
128 /* 0x81 to read, (0x82 | level << 8) to set, 0xaabb to enable */
129 u16 kbd_backlight;
132 * Tell the BIOS that Linux is running on this machine.
133 * 81 is on, 80 is off
135 u16 set_linux;
138 struct sabi_performance_level {
139 const char *name;
140 u16 value;
143 struct sabi_config {
144 int sabi_version;
145 const char *test_string;
146 u16 main_function;
147 const struct sabi_header_offsets header_offsets;
148 const struct sabi_commands commands;
149 const struct sabi_performance_level performance_levels[4];
150 u8 min_brightness;
151 u8 max_brightness;
154 static const struct sabi_config sabi_configs[] = {
156 /* I don't know if it is really 2, but it it is
157 * less than 3 anyway */
158 .sabi_version = 2,
160 .test_string = "SECLINUX",
162 .main_function = 0x4c49,
164 .header_offsets = {
165 .port = 0x00,
166 .re_mem = 0x02,
167 .iface_func = 0x03,
168 .en_mem = 0x04,
169 .data_offset = 0x05,
170 .data_segment = 0x07,
173 .commands = {
174 .get_brightness = 0x00,
175 .set_brightness = 0x01,
177 .get_wireless_button = 0x02,
178 .set_wireless_button = 0x03,
180 .get_backlight = 0x04,
181 .set_backlight = 0x05,
183 .get_recovery_mode = 0x06,
184 .set_recovery_mode = 0x07,
186 .get_performance_level = 0x08,
187 .set_performance_level = 0x09,
189 .get_battery_life_extender = 0xFFFF,
190 .set_battery_life_extender = 0xFFFF,
192 .get_usb_charge = 0xFFFF,
193 .set_usb_charge = 0xFFFF,
195 .get_wireless_status = 0xFFFF,
196 .set_wireless_status = 0xFFFF,
198 .kbd_backlight = 0xFFFF,
200 .set_linux = 0x0a,
203 .performance_levels = {
205 .name = "silent",
206 .value = 0,
209 .name = "normal",
210 .value = 1,
212 { },
214 .min_brightness = 1,
215 .max_brightness = 8,
218 .sabi_version = 3,
220 .test_string = "SwSmi@",
222 .main_function = 0x5843,
224 .header_offsets = {
225 .port = 0x00,
226 .re_mem = 0x04,
227 .iface_func = 0x02,
228 .en_mem = 0x03,
229 .data_offset = 0x05,
230 .data_segment = 0x07,
233 .commands = {
234 .get_brightness = 0x10,
235 .set_brightness = 0x11,
237 .get_wireless_button = 0x12,
238 .set_wireless_button = 0x13,
240 .get_backlight = 0x2d,
241 .set_backlight = 0x2e,
243 .get_recovery_mode = 0xff,
244 .set_recovery_mode = 0xff,
246 .get_performance_level = 0x31,
247 .set_performance_level = 0x32,
249 .get_battery_life_extender = 0x65,
250 .set_battery_life_extender = 0x66,
252 .get_usb_charge = 0x67,
253 .set_usb_charge = 0x68,
255 .get_wireless_status = 0x69,
256 .set_wireless_status = 0x6a,
258 .kbd_backlight = 0x78,
260 .set_linux = 0xff,
263 .performance_levels = {
265 .name = "normal",
266 .value = 0,
269 .name = "silent",
270 .value = 1,
273 .name = "overclock",
274 .value = 2,
276 { },
278 .min_brightness = 0,
279 .max_brightness = 8,
281 { },
285 * samsung-laptop/ - debugfs root directory
286 * f0000_segment - dump f0000 segment
287 * command - current command
288 * data - current data
289 * d0, d1, d2, d3 - data fields
290 * call - call SABI using command and data
292 * This allow to call arbitrary sabi commands wihout
293 * modifying the driver at all.
294 * For example, setting the keyboard backlight brightness to 5
296 * echo 0x78 > command
297 * echo 0x0582 > d0
298 * echo 0 > d1
299 * echo 0 > d2
300 * echo 0 > d3
301 * cat call
304 struct samsung_laptop_debug {
305 struct dentry *root;
306 struct sabi_data data;
307 u16 command;
309 struct debugfs_blob_wrapper f0000_wrapper;
310 struct debugfs_blob_wrapper data_wrapper;
311 struct debugfs_blob_wrapper sdiag_wrapper;
314 struct samsung_laptop;
316 struct samsung_rfkill {
317 struct samsung_laptop *samsung;
318 struct rfkill *rfkill;
319 enum rfkill_type type;
322 struct samsung_laptop {
323 const struct sabi_config *config;
325 void __iomem *sabi;
326 void __iomem *sabi_iface;
327 void __iomem *f0000_segment;
329 struct mutex sabi_mutex;
331 struct platform_device *platform_device;
332 struct backlight_device *backlight_device;
334 struct samsung_rfkill wlan;
335 struct samsung_rfkill bluetooth;
337 struct led_classdev kbd_led;
338 int kbd_led_wk;
339 struct workqueue_struct *led_workqueue;
340 struct work_struct kbd_led_work;
342 struct samsung_laptop_debug debug;
343 struct samsung_quirks *quirks;
345 bool handle_backlight;
346 bool has_stepping_quirk;
348 char sdiag[64];
351 struct samsung_quirks {
352 bool broken_acpi_video;
355 static struct samsung_quirks samsung_unknown = {};
357 static struct samsung_quirks samsung_broken_acpi_video = {
358 .broken_acpi_video = true,
361 static bool force;
362 module_param(force, bool, 0);
363 MODULE_PARM_DESC(force,
364 "Disable the DMI check and forces the driver to be loaded");
366 static bool debug;
367 module_param(debug, bool, S_IRUGO | S_IWUSR);
368 MODULE_PARM_DESC(debug, "Debug enabled or not");
370 static int sabi_command(struct samsung_laptop *samsung, u16 command,
371 struct sabi_data *in,
372 struct sabi_data *out)
374 const struct sabi_config *config = samsung->config;
375 int ret = 0;
376 u16 port = readw(samsung->sabi + config->header_offsets.port);
377 u8 complete, iface_data;
379 mutex_lock(&samsung->sabi_mutex);
381 if (debug) {
382 if (in)
383 pr_info("SABI command:0x%04x "
384 "data:{0x%08x, 0x%08x, 0x%04x, 0x%02x}",
385 command, in->d0, in->d1, in->d2, in->d3);
386 else
387 pr_info("SABI command:0x%04x", command);
390 /* enable memory to be able to write to it */
391 outb(readb(samsung->sabi + config->header_offsets.en_mem), port);
393 /* write out the command */
394 writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN);
395 writew(command, samsung->sabi_iface + SABI_IFACE_SUB);
396 writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE);
397 if (in) {
398 writel(in->d0, samsung->sabi_iface + SABI_IFACE_DATA);
399 writel(in->d1, samsung->sabi_iface + SABI_IFACE_DATA + 4);
400 writew(in->d2, samsung->sabi_iface + SABI_IFACE_DATA + 8);
401 writeb(in->d3, samsung->sabi_iface + SABI_IFACE_DATA + 10);
403 outb(readb(samsung->sabi + config->header_offsets.iface_func), port);
405 /* write protect memory to make it safe */
406 outb(readb(samsung->sabi + config->header_offsets.re_mem), port);
408 /* see if the command actually succeeded */
409 complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE);
410 iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA);
412 /* iface_data = 0xFF happens when a command is not known
413 * so we only add a warning in debug mode since we will
414 * probably issue some unknown command at startup to find
415 * out which features are supported */
416 if (complete != 0xaa || (iface_data == 0xff && debug))
417 pr_warn("SABI command 0x%04x failed with"
418 " completion flag 0x%02x and interface data 0x%02x",
419 command, complete, iface_data);
421 if (complete != 0xaa || iface_data == 0xff) {
422 ret = -EINVAL;
423 goto exit;
426 if (out) {
427 out->d0 = readl(samsung->sabi_iface + SABI_IFACE_DATA);
428 out->d1 = readl(samsung->sabi_iface + SABI_IFACE_DATA + 4);
429 out->d2 = readw(samsung->sabi_iface + SABI_IFACE_DATA + 2);
430 out->d3 = readb(samsung->sabi_iface + SABI_IFACE_DATA + 1);
433 if (debug && out) {
434 pr_info("SABI return data:{0x%08x, 0x%08x, 0x%04x, 0x%02x}",
435 out->d0, out->d1, out->d2, out->d3);
438 exit:
439 mutex_unlock(&samsung->sabi_mutex);
440 return ret;
443 /* simple wrappers usable with most commands */
444 static int sabi_set_commandb(struct samsung_laptop *samsung,
445 u16 command, u8 data)
447 struct sabi_data in = { { { .d0 = 0, .d1 = 0, .d2 = 0, .d3 = 0 } } };
449 in.data[0] = data;
450 return sabi_command(samsung, command, &in, NULL);
453 static int read_brightness(struct samsung_laptop *samsung)
455 const struct sabi_config *config = samsung->config;
456 const struct sabi_commands *commands = &samsung->config->commands;
457 struct sabi_data sretval;
458 int user_brightness = 0;
459 int retval;
461 retval = sabi_command(samsung, commands->get_brightness,
462 NULL, &sretval);
463 if (retval)
464 return retval;
466 user_brightness = sretval.data[0];
467 if (user_brightness > config->min_brightness)
468 user_brightness -= config->min_brightness;
469 else
470 user_brightness = 0;
472 return user_brightness;
475 static void set_brightness(struct samsung_laptop *samsung, u8 user_brightness)
477 const struct sabi_config *config = samsung->config;
478 const struct sabi_commands *commands = &samsung->config->commands;
479 u8 user_level = user_brightness + config->min_brightness;
481 if (samsung->has_stepping_quirk && user_level != 0) {
483 * short circuit if the specified level is what's already set
484 * to prevent the screen from flickering needlessly
486 if (user_brightness == read_brightness(samsung))
487 return;
489 sabi_set_commandb(samsung, commands->set_brightness, 0);
492 sabi_set_commandb(samsung, commands->set_brightness, user_level);
495 static int get_brightness(struct backlight_device *bd)
497 struct samsung_laptop *samsung = bl_get_data(bd);
499 return read_brightness(samsung);
502 static void check_for_stepping_quirk(struct samsung_laptop *samsung)
504 int initial_level;
505 int check_level;
506 int orig_level = read_brightness(samsung);
509 * Some laptops exhibit the strange behaviour of stepping toward
510 * (rather than setting) the brightness except when changing to/from
511 * brightness level 0. This behaviour is checked for here and worked
512 * around in set_brightness.
515 if (orig_level == 0)
516 set_brightness(samsung, 1);
518 initial_level = read_brightness(samsung);
520 if (initial_level <= 2)
521 check_level = initial_level + 2;
522 else
523 check_level = initial_level - 2;
525 samsung->has_stepping_quirk = false;
526 set_brightness(samsung, check_level);
528 if (read_brightness(samsung) != check_level) {
529 samsung->has_stepping_quirk = true;
530 pr_info("enabled workaround for brightness stepping quirk\n");
533 set_brightness(samsung, orig_level);
536 static int update_status(struct backlight_device *bd)
538 struct samsung_laptop *samsung = bl_get_data(bd);
539 const struct sabi_commands *commands = &samsung->config->commands;
541 set_brightness(samsung, bd->props.brightness);
543 if (bd->props.power == FB_BLANK_UNBLANK)
544 sabi_set_commandb(samsung, commands->set_backlight, 1);
545 else
546 sabi_set_commandb(samsung, commands->set_backlight, 0);
548 return 0;
551 static const struct backlight_ops backlight_ops = {
552 .get_brightness = get_brightness,
553 .update_status = update_status,
556 static int seclinux_rfkill_set(void *data, bool blocked)
558 struct samsung_rfkill *srfkill = data;
559 struct samsung_laptop *samsung = srfkill->samsung;
560 const struct sabi_commands *commands = &samsung->config->commands;
562 return sabi_set_commandb(samsung, commands->set_wireless_button,
563 !blocked);
566 static struct rfkill_ops seclinux_rfkill_ops = {
567 .set_block = seclinux_rfkill_set,
570 static int swsmi_wireless_status(struct samsung_laptop *samsung,
571 struct sabi_data *data)
573 const struct sabi_commands *commands = &samsung->config->commands;
575 return sabi_command(samsung, commands->get_wireless_status,
576 NULL, data);
579 static int swsmi_rfkill_set(void *priv, bool blocked)
581 struct samsung_rfkill *srfkill = priv;
582 struct samsung_laptop *samsung = srfkill->samsung;
583 const struct sabi_commands *commands = &samsung->config->commands;
584 struct sabi_data data;
585 int ret, i;
587 ret = swsmi_wireless_status(samsung, &data);
588 if (ret)
589 return ret;
591 /* Don't set the state for non-present devices */
592 for (i = 0; i < 4; i++)
593 if (data.data[i] == 0x02)
594 data.data[1] = 0;
596 if (srfkill->type == RFKILL_TYPE_WLAN)
597 data.data[WL_STATUS_WLAN] = !blocked;
598 else if (srfkill->type == RFKILL_TYPE_BLUETOOTH)
599 data.data[WL_STATUS_BT] = !blocked;
601 return sabi_command(samsung, commands->set_wireless_status,
602 &data, &data);
605 static void swsmi_rfkill_query(struct rfkill *rfkill, void *priv)
607 struct samsung_rfkill *srfkill = priv;
608 struct samsung_laptop *samsung = srfkill->samsung;
609 struct sabi_data data;
610 int ret;
612 ret = swsmi_wireless_status(samsung, &data);
613 if (ret)
614 return ;
616 if (srfkill->type == RFKILL_TYPE_WLAN)
617 ret = data.data[WL_STATUS_WLAN];
618 else if (srfkill->type == RFKILL_TYPE_BLUETOOTH)
619 ret = data.data[WL_STATUS_BT];
620 else
621 return ;
623 rfkill_set_sw_state(rfkill, !ret);
626 static struct rfkill_ops swsmi_rfkill_ops = {
627 .set_block = swsmi_rfkill_set,
628 .query = swsmi_rfkill_query,
631 static ssize_t get_performance_level(struct device *dev,
632 struct device_attribute *attr, char *buf)
634 struct samsung_laptop *samsung = dev_get_drvdata(dev);
635 const struct sabi_config *config = samsung->config;
636 const struct sabi_commands *commands = &config->commands;
637 struct sabi_data sretval;
638 int retval;
639 int i;
641 /* Read the state */
642 retval = sabi_command(samsung, commands->get_performance_level,
643 NULL, &sretval);
644 if (retval)
645 return retval;
647 /* The logic is backwards, yeah, lots of fun... */
648 for (i = 0; config->performance_levels[i].name; ++i) {
649 if (sretval.data[0] == config->performance_levels[i].value)
650 return sprintf(buf, "%s\n", config->performance_levels[i].name);
652 return sprintf(buf, "%s\n", "unknown");
655 static ssize_t set_performance_level(struct device *dev,
656 struct device_attribute *attr, const char *buf,
657 size_t count)
659 struct samsung_laptop *samsung = dev_get_drvdata(dev);
660 const struct sabi_config *config = samsung->config;
661 const struct sabi_commands *commands = &config->commands;
662 int i;
664 if (count < 1)
665 return count;
667 for (i = 0; config->performance_levels[i].name; ++i) {
668 const struct sabi_performance_level *level =
669 &config->performance_levels[i];
670 if (!strncasecmp(level->name, buf, strlen(level->name))) {
671 sabi_set_commandb(samsung,
672 commands->set_performance_level,
673 level->value);
674 break;
678 if (!config->performance_levels[i].name)
679 return -EINVAL;
681 return count;
684 static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO,
685 get_performance_level, set_performance_level);
687 static int read_battery_life_extender(struct samsung_laptop *samsung)
689 const struct sabi_commands *commands = &samsung->config->commands;
690 struct sabi_data data;
691 int retval;
693 if (commands->get_battery_life_extender == 0xFFFF)
694 return -ENODEV;
696 memset(&data, 0, sizeof(data));
697 data.data[0] = 0x80;
698 retval = sabi_command(samsung, commands->get_battery_life_extender,
699 &data, &data);
701 if (retval)
702 return retval;
704 if (data.data[0] != 0 && data.data[0] != 1)
705 return -ENODEV;
707 return data.data[0];
710 static int write_battery_life_extender(struct samsung_laptop *samsung,
711 int enabled)
713 const struct sabi_commands *commands = &samsung->config->commands;
714 struct sabi_data data;
716 memset(&data, 0, sizeof(data));
717 data.data[0] = 0x80 | enabled;
718 return sabi_command(samsung, commands->set_battery_life_extender,
719 &data, NULL);
722 static ssize_t get_battery_life_extender(struct device *dev,
723 struct device_attribute *attr,
724 char *buf)
726 struct samsung_laptop *samsung = dev_get_drvdata(dev);
727 int ret;
729 ret = read_battery_life_extender(samsung);
730 if (ret < 0)
731 return ret;
733 return sprintf(buf, "%d\n", ret);
736 static ssize_t set_battery_life_extender(struct device *dev,
737 struct device_attribute *attr,
738 const char *buf, size_t count)
740 struct samsung_laptop *samsung = dev_get_drvdata(dev);
741 int ret, value;
743 if (!count || sscanf(buf, "%i", &value) != 1)
744 return -EINVAL;
746 ret = write_battery_life_extender(samsung, !!value);
747 if (ret < 0)
748 return ret;
750 return count;
753 static DEVICE_ATTR(battery_life_extender, S_IWUSR | S_IRUGO,
754 get_battery_life_extender, set_battery_life_extender);
756 static int read_usb_charge(struct samsung_laptop *samsung)
758 const struct sabi_commands *commands = &samsung->config->commands;
759 struct sabi_data data;
760 int retval;
762 if (commands->get_usb_charge == 0xFFFF)
763 return -ENODEV;
765 memset(&data, 0, sizeof(data));
766 data.data[0] = 0x80;
767 retval = sabi_command(samsung, commands->get_usb_charge,
768 &data, &data);
770 if (retval)
771 return retval;
773 if (data.data[0] != 0 && data.data[0] != 1)
774 return -ENODEV;
776 return data.data[0];
779 static int write_usb_charge(struct samsung_laptop *samsung,
780 int enabled)
782 const struct sabi_commands *commands = &samsung->config->commands;
783 struct sabi_data data;
785 memset(&data, 0, sizeof(data));
786 data.data[0] = 0x80 | enabled;
787 return sabi_command(samsung, commands->set_usb_charge,
788 &data, NULL);
791 static ssize_t get_usb_charge(struct device *dev,
792 struct device_attribute *attr,
793 char *buf)
795 struct samsung_laptop *samsung = dev_get_drvdata(dev);
796 int ret;
798 ret = read_usb_charge(samsung);
799 if (ret < 0)
800 return ret;
802 return sprintf(buf, "%d\n", ret);
805 static ssize_t set_usb_charge(struct device *dev,
806 struct device_attribute *attr,
807 const char *buf, size_t count)
809 struct samsung_laptop *samsung = dev_get_drvdata(dev);
810 int ret, value;
812 if (!count || sscanf(buf, "%i", &value) != 1)
813 return -EINVAL;
815 ret = write_usb_charge(samsung, !!value);
816 if (ret < 0)
817 return ret;
819 return count;
822 static DEVICE_ATTR(usb_charge, S_IWUSR | S_IRUGO,
823 get_usb_charge, set_usb_charge);
825 static struct attribute *platform_attributes[] = {
826 &dev_attr_performance_level.attr,
827 &dev_attr_battery_life_extender.attr,
828 &dev_attr_usb_charge.attr,
829 NULL
832 static int find_signature(void __iomem *memcheck, const char *testStr)
834 int i = 0;
835 int loca;
837 for (loca = 0; loca < 0xffff; loca++) {
838 char temp = readb(memcheck + loca);
840 if (temp == testStr[i]) {
841 if (i == strlen(testStr)-1)
842 break;
843 ++i;
844 } else {
845 i = 0;
848 return loca;
851 static void samsung_rfkill_exit(struct samsung_laptop *samsung)
853 if (samsung->wlan.rfkill) {
854 rfkill_unregister(samsung->wlan.rfkill);
855 rfkill_destroy(samsung->wlan.rfkill);
856 samsung->wlan.rfkill = NULL;
858 if (samsung->bluetooth.rfkill) {
859 rfkill_unregister(samsung->bluetooth.rfkill);
860 rfkill_destroy(samsung->bluetooth.rfkill);
861 samsung->bluetooth.rfkill = NULL;
865 static int samsung_new_rfkill(struct samsung_laptop *samsung,
866 struct samsung_rfkill *arfkill,
867 const char *name, enum rfkill_type type,
868 const struct rfkill_ops *ops,
869 int blocked)
871 struct rfkill **rfkill = &arfkill->rfkill;
872 int ret;
874 arfkill->type = type;
875 arfkill->samsung = samsung;
877 *rfkill = rfkill_alloc(name, &samsung->platform_device->dev,
878 type, ops, arfkill);
880 if (!*rfkill)
881 return -EINVAL;
883 if (blocked != -1)
884 rfkill_init_sw_state(*rfkill, blocked);
886 ret = rfkill_register(*rfkill);
887 if (ret) {
888 rfkill_destroy(*rfkill);
889 *rfkill = NULL;
890 return ret;
892 return 0;
895 static int __init samsung_rfkill_init_seclinux(struct samsung_laptop *samsung)
897 return samsung_new_rfkill(samsung, &samsung->wlan, "samsung-wlan",
898 RFKILL_TYPE_WLAN, &seclinux_rfkill_ops, -1);
901 static int __init samsung_rfkill_init_swsmi(struct samsung_laptop *samsung)
903 struct sabi_data data;
904 int ret;
906 ret = swsmi_wireless_status(samsung, &data);
907 if (ret) {
908 /* Some swsmi laptops use the old seclinux way to control
909 * wireless devices */
910 if (ret == -EINVAL)
911 ret = samsung_rfkill_init_seclinux(samsung);
912 return ret;
915 /* 0x02 seems to mean that the device is no present/available */
917 if (data.data[WL_STATUS_WLAN] != 0x02)
918 ret = samsung_new_rfkill(samsung, &samsung->wlan,
919 "samsung-wlan",
920 RFKILL_TYPE_WLAN,
921 &swsmi_rfkill_ops,
922 !data.data[WL_STATUS_WLAN]);
923 if (ret)
924 goto exit;
926 if (data.data[WL_STATUS_BT] != 0x02)
927 ret = samsung_new_rfkill(samsung, &samsung->bluetooth,
928 "samsung-bluetooth",
929 RFKILL_TYPE_BLUETOOTH,
930 &swsmi_rfkill_ops,
931 !data.data[WL_STATUS_BT]);
932 if (ret)
933 goto exit;
935 exit:
936 if (ret)
937 samsung_rfkill_exit(samsung);
939 return ret;
942 static int __init samsung_rfkill_init(struct samsung_laptop *samsung)
944 if (samsung->config->sabi_version == 2)
945 return samsung_rfkill_init_seclinux(samsung);
946 if (samsung->config->sabi_version == 3)
947 return samsung_rfkill_init_swsmi(samsung);
948 return 0;
951 static int kbd_backlight_enable(struct samsung_laptop *samsung)
953 const struct sabi_commands *commands = &samsung->config->commands;
954 struct sabi_data data;
955 int retval;
957 if (commands->kbd_backlight == 0xFFFF)
958 return -ENODEV;
960 memset(&data, 0, sizeof(data));
961 data.d0 = 0xaabb;
962 retval = sabi_command(samsung, commands->kbd_backlight,
963 &data, &data);
965 if (retval)
966 return retval;
968 if (data.d0 != 0xccdd)
969 return -ENODEV;
970 return 0;
973 static int kbd_backlight_read(struct samsung_laptop *samsung)
975 const struct sabi_commands *commands = &samsung->config->commands;
976 struct sabi_data data;
977 int retval;
979 memset(&data, 0, sizeof(data));
980 data.data[0] = 0x81;
981 retval = sabi_command(samsung, commands->kbd_backlight,
982 &data, &data);
984 if (retval)
985 return retval;
987 return data.data[0];
990 static int kbd_backlight_write(struct samsung_laptop *samsung, int brightness)
992 const struct sabi_commands *commands = &samsung->config->commands;
993 struct sabi_data data;
995 memset(&data, 0, sizeof(data));
996 data.d0 = 0x82 | ((brightness & 0xFF) << 8);
997 return sabi_command(samsung, commands->kbd_backlight,
998 &data, NULL);
1001 static void kbd_led_update(struct work_struct *work)
1003 struct samsung_laptop *samsung;
1005 samsung = container_of(work, struct samsung_laptop, kbd_led_work);
1006 kbd_backlight_write(samsung, samsung->kbd_led_wk);
1009 static void kbd_led_set(struct led_classdev *led_cdev,
1010 enum led_brightness value)
1012 struct samsung_laptop *samsung;
1014 samsung = container_of(led_cdev, struct samsung_laptop, kbd_led);
1016 if (value > samsung->kbd_led.max_brightness)
1017 value = samsung->kbd_led.max_brightness;
1018 else if (value < 0)
1019 value = 0;
1021 samsung->kbd_led_wk = value;
1022 queue_work(samsung->led_workqueue, &samsung->kbd_led_work);
1025 static enum led_brightness kbd_led_get(struct led_classdev *led_cdev)
1027 struct samsung_laptop *samsung;
1029 samsung = container_of(led_cdev, struct samsung_laptop, kbd_led);
1030 return kbd_backlight_read(samsung);
1033 static void samsung_leds_exit(struct samsung_laptop *samsung)
1035 if (!IS_ERR_OR_NULL(samsung->kbd_led.dev))
1036 led_classdev_unregister(&samsung->kbd_led);
1037 if (samsung->led_workqueue)
1038 destroy_workqueue(samsung->led_workqueue);
1041 static int __init samsung_leds_init(struct samsung_laptop *samsung)
1043 int ret = 0;
1045 samsung->led_workqueue = create_singlethread_workqueue("led_workqueue");
1046 if (!samsung->led_workqueue)
1047 return -ENOMEM;
1049 if (kbd_backlight_enable(samsung) >= 0) {
1050 INIT_WORK(&samsung->kbd_led_work, kbd_led_update);
1052 samsung->kbd_led.name = "samsung::kbd_backlight";
1053 samsung->kbd_led.brightness_set = kbd_led_set;
1054 samsung->kbd_led.brightness_get = kbd_led_get;
1055 samsung->kbd_led.max_brightness = 8;
1057 ret = led_classdev_register(&samsung->platform_device->dev,
1058 &samsung->kbd_led);
1061 if (ret)
1062 samsung_leds_exit(samsung);
1064 return ret;
1067 static void samsung_backlight_exit(struct samsung_laptop *samsung)
1069 if (samsung->backlight_device) {
1070 backlight_device_unregister(samsung->backlight_device);
1071 samsung->backlight_device = NULL;
1075 static int __init samsung_backlight_init(struct samsung_laptop *samsung)
1077 struct backlight_device *bd;
1078 struct backlight_properties props;
1080 if (!samsung->handle_backlight)
1081 return 0;
1083 memset(&props, 0, sizeof(struct backlight_properties));
1084 props.type = BACKLIGHT_PLATFORM;
1085 props.max_brightness = samsung->config->max_brightness -
1086 samsung->config->min_brightness;
1088 bd = backlight_device_register("samsung",
1089 &samsung->platform_device->dev,
1090 samsung, &backlight_ops,
1091 &props);
1092 if (IS_ERR(bd))
1093 return PTR_ERR(bd);
1095 samsung->backlight_device = bd;
1096 samsung->backlight_device->props.brightness = read_brightness(samsung);
1097 samsung->backlight_device->props.power = FB_BLANK_UNBLANK;
1098 backlight_update_status(samsung->backlight_device);
1100 return 0;
1103 static umode_t samsung_sysfs_is_visible(struct kobject *kobj,
1104 struct attribute *attr, int idx)
1106 struct device *dev = container_of(kobj, struct device, kobj);
1107 struct platform_device *pdev = to_platform_device(dev);
1108 struct samsung_laptop *samsung = platform_get_drvdata(pdev);
1109 bool ok = true;
1111 if (attr == &dev_attr_performance_level.attr)
1112 ok = !!samsung->config->performance_levels[0].name;
1113 if (attr == &dev_attr_battery_life_extender.attr)
1114 ok = !!(read_battery_life_extender(samsung) >= 0);
1115 if (attr == &dev_attr_usb_charge.attr)
1116 ok = !!(read_usb_charge(samsung) >= 0);
1118 return ok ? attr->mode : 0;
1121 static struct attribute_group platform_attribute_group = {
1122 .is_visible = samsung_sysfs_is_visible,
1123 .attrs = platform_attributes
1126 static void samsung_sysfs_exit(struct samsung_laptop *samsung)
1128 struct platform_device *device = samsung->platform_device;
1130 sysfs_remove_group(&device->dev.kobj, &platform_attribute_group);
1133 static int __init samsung_sysfs_init(struct samsung_laptop *samsung)
1135 struct platform_device *device = samsung->platform_device;
1137 return sysfs_create_group(&device->dev.kobj, &platform_attribute_group);
1141 static int show_call(struct seq_file *m, void *data)
1143 struct samsung_laptop *samsung = m->private;
1144 struct sabi_data *sdata = &samsung->debug.data;
1145 int ret;
1147 seq_printf(m, "SABI 0x%04x {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n",
1148 samsung->debug.command,
1149 sdata->d0, sdata->d1, sdata->d2, sdata->d3);
1151 ret = sabi_command(samsung, samsung->debug.command, sdata, sdata);
1153 if (ret) {
1154 seq_printf(m, "SABI command 0x%04x failed\n",
1155 samsung->debug.command);
1156 return ret;
1159 seq_printf(m, "SABI {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n",
1160 sdata->d0, sdata->d1, sdata->d2, sdata->d3);
1161 return 0;
1164 static int samsung_debugfs_open(struct inode *inode, struct file *file)
1166 return single_open(file, show_call, inode->i_private);
1169 static const struct file_operations samsung_laptop_call_io_ops = {
1170 .owner = THIS_MODULE,
1171 .open = samsung_debugfs_open,
1172 .read = seq_read,
1173 .llseek = seq_lseek,
1174 .release = single_release,
1177 static void samsung_debugfs_exit(struct samsung_laptop *samsung)
1179 debugfs_remove_recursive(samsung->debug.root);
1182 static int samsung_debugfs_init(struct samsung_laptop *samsung)
1184 struct dentry *dent;
1186 samsung->debug.root = debugfs_create_dir("samsung-laptop", NULL);
1187 if (!samsung->debug.root) {
1188 pr_err("failed to create debugfs directory");
1189 goto error_debugfs;
1192 samsung->debug.f0000_wrapper.data = samsung->f0000_segment;
1193 samsung->debug.f0000_wrapper.size = 0xffff;
1195 samsung->debug.data_wrapper.data = &samsung->debug.data;
1196 samsung->debug.data_wrapper.size = sizeof(samsung->debug.data);
1198 samsung->debug.sdiag_wrapper.data = samsung->sdiag;
1199 samsung->debug.sdiag_wrapper.size = strlen(samsung->sdiag);
1201 dent = debugfs_create_u16("command", S_IRUGO | S_IWUSR,
1202 samsung->debug.root, &samsung->debug.command);
1203 if (!dent)
1204 goto error_debugfs;
1206 dent = debugfs_create_u32("d0", S_IRUGO | S_IWUSR, samsung->debug.root,
1207 &samsung->debug.data.d0);
1208 if (!dent)
1209 goto error_debugfs;
1211 dent = debugfs_create_u32("d1", S_IRUGO | S_IWUSR, samsung->debug.root,
1212 &samsung->debug.data.d1);
1213 if (!dent)
1214 goto error_debugfs;
1216 dent = debugfs_create_u16("d2", S_IRUGO | S_IWUSR, samsung->debug.root,
1217 &samsung->debug.data.d2);
1218 if (!dent)
1219 goto error_debugfs;
1221 dent = debugfs_create_u8("d3", S_IRUGO | S_IWUSR, samsung->debug.root,
1222 &samsung->debug.data.d3);
1223 if (!dent)
1224 goto error_debugfs;
1226 dent = debugfs_create_blob("data", S_IRUGO | S_IWUSR,
1227 samsung->debug.root,
1228 &samsung->debug.data_wrapper);
1229 if (!dent)
1230 goto error_debugfs;
1232 dent = debugfs_create_blob("f0000_segment", S_IRUSR | S_IWUSR,
1233 samsung->debug.root,
1234 &samsung->debug.f0000_wrapper);
1235 if (!dent)
1236 goto error_debugfs;
1238 dent = debugfs_create_file("call", S_IFREG | S_IRUGO,
1239 samsung->debug.root, samsung,
1240 &samsung_laptop_call_io_ops);
1241 if (!dent)
1242 goto error_debugfs;
1244 dent = debugfs_create_blob("sdiag", S_IRUGO | S_IWUSR,
1245 samsung->debug.root,
1246 &samsung->debug.sdiag_wrapper);
1247 if (!dent)
1248 goto error_debugfs;
1250 return 0;
1252 error_debugfs:
1253 samsung_debugfs_exit(samsung);
1254 return -ENOMEM;
1257 static void samsung_sabi_exit(struct samsung_laptop *samsung)
1259 const struct sabi_config *config = samsung->config;
1261 /* Turn off "Linux" mode in the BIOS */
1262 if (config && config->commands.set_linux != 0xff)
1263 sabi_set_commandb(samsung, config->commands.set_linux, 0x80);
1265 if (samsung->sabi_iface) {
1266 iounmap(samsung->sabi_iface);
1267 samsung->sabi_iface = NULL;
1269 if (samsung->f0000_segment) {
1270 iounmap(samsung->f0000_segment);
1271 samsung->f0000_segment = NULL;
1274 samsung->config = NULL;
1277 static __init void samsung_sabi_infos(struct samsung_laptop *samsung, int loca,
1278 unsigned int ifaceP)
1280 const struct sabi_config *config = samsung->config;
1282 printk(KERN_DEBUG "This computer supports SABI==%x\n",
1283 loca + 0xf0000 - 6);
1285 printk(KERN_DEBUG "SABI header:\n");
1286 printk(KERN_DEBUG " SMI Port Number = 0x%04x\n",
1287 readw(samsung->sabi + config->header_offsets.port));
1288 printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n",
1289 readb(samsung->sabi + config->header_offsets.iface_func));
1290 printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n",
1291 readb(samsung->sabi + config->header_offsets.en_mem));
1292 printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n",
1293 readb(samsung->sabi + config->header_offsets.re_mem));
1294 printk(KERN_DEBUG " SABI data offset = 0x%04x\n",
1295 readw(samsung->sabi + config->header_offsets.data_offset));
1296 printk(KERN_DEBUG " SABI data segment = 0x%04x\n",
1297 readw(samsung->sabi + config->header_offsets.data_segment));
1299 printk(KERN_DEBUG " SABI pointer = 0x%08x\n", ifaceP);
1302 static void __init samsung_sabi_diag(struct samsung_laptop *samsung)
1304 int loca = find_signature(samsung->f0000_segment, "SDiaG@");
1305 int i;
1307 if (loca == 0xffff)
1308 return ;
1310 /* Example:
1311 * Ident: @SDiaG@686XX-N90X3A/966-SEC-07HL-S90X3A
1313 * Product name: 90X3A
1314 * BIOS Version: 07HL
1316 loca += 1;
1317 for (i = 0; loca < 0xffff && i < sizeof(samsung->sdiag) - 1; loca++) {
1318 char temp = readb(samsung->f0000_segment + loca);
1320 if (isalnum(temp) || temp == '/' || temp == '-')
1321 samsung->sdiag[i++] = temp;
1322 else
1323 break ;
1326 if (debug && samsung->sdiag[0])
1327 pr_info("sdiag: %s", samsung->sdiag);
1330 static int __init samsung_sabi_init(struct samsung_laptop *samsung)
1332 const struct sabi_config *config = NULL;
1333 const struct sabi_commands *commands;
1334 unsigned int ifaceP;
1335 int ret = 0;
1336 int i;
1337 int loca;
1339 samsung->f0000_segment = ioremap_nocache(0xf0000, 0xffff);
1340 if (!samsung->f0000_segment) {
1341 if (debug || force)
1342 pr_err("Can't map the segment at 0xf0000\n");
1343 ret = -EINVAL;
1344 goto exit;
1347 samsung_sabi_diag(samsung);
1349 /* Try to find one of the signatures in memory to find the header */
1350 for (i = 0; sabi_configs[i].test_string != 0; ++i) {
1351 samsung->config = &sabi_configs[i];
1352 loca = find_signature(samsung->f0000_segment,
1353 samsung->config->test_string);
1354 if (loca != 0xffff)
1355 break;
1358 if (loca == 0xffff) {
1359 if (debug || force)
1360 pr_err("This computer does not support SABI\n");
1361 ret = -ENODEV;
1362 goto exit;
1365 config = samsung->config;
1366 commands = &config->commands;
1368 /* point to the SMI port Number */
1369 loca += 1;
1370 samsung->sabi = (samsung->f0000_segment + loca);
1372 /* Get a pointer to the SABI Interface */
1373 ifaceP = (readw(samsung->sabi + config->header_offsets.data_segment) & 0x0ffff) << 4;
1374 ifaceP += readw(samsung->sabi + config->header_offsets.data_offset) & 0x0ffff;
1376 if (debug)
1377 samsung_sabi_infos(samsung, loca, ifaceP);
1379 samsung->sabi_iface = ioremap_nocache(ifaceP, 16);
1380 if (!samsung->sabi_iface) {
1381 pr_err("Can't remap %x\n", ifaceP);
1382 ret = -EINVAL;
1383 goto exit;
1386 /* Turn on "Linux" mode in the BIOS */
1387 if (commands->set_linux != 0xff) {
1388 int retval = sabi_set_commandb(samsung,
1389 commands->set_linux, 0x81);
1390 if (retval) {
1391 pr_warn("Linux mode was not set!\n");
1392 ret = -ENODEV;
1393 goto exit;
1397 /* Check for stepping quirk */
1398 if (samsung->handle_backlight)
1399 check_for_stepping_quirk(samsung);
1401 pr_info("detected SABI interface: %s\n",
1402 samsung->config->test_string);
1404 exit:
1405 if (ret)
1406 samsung_sabi_exit(samsung);
1408 return ret;
1411 static void samsung_platform_exit(struct samsung_laptop *samsung)
1413 if (samsung->platform_device) {
1414 platform_device_unregister(samsung->platform_device);
1415 samsung->platform_device = NULL;
1419 static int __init samsung_platform_init(struct samsung_laptop *samsung)
1421 struct platform_device *pdev;
1423 pdev = platform_device_register_simple("samsung", -1, NULL, 0);
1424 if (IS_ERR(pdev))
1425 return PTR_ERR(pdev);
1427 samsung->platform_device = pdev;
1428 platform_set_drvdata(samsung->platform_device, samsung);
1429 return 0;
1432 static struct samsung_quirks *quirks;
1434 static int __init samsung_dmi_matched(const struct dmi_system_id *d)
1436 quirks = d->driver_data;
1437 return 0;
1440 static struct dmi_system_id __initdata samsung_dmi_table[] = {
1442 .matches = {
1443 DMI_MATCH(DMI_SYS_VENDOR,
1444 "SAMSUNG ELECTRONICS CO., LTD."),
1445 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
1449 .matches = {
1450 DMI_MATCH(DMI_SYS_VENDOR,
1451 "SAMSUNG ELECTRONICS CO., LTD."),
1452 DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
1456 .matches = {
1457 DMI_MATCH(DMI_SYS_VENDOR,
1458 "SAMSUNG ELECTRONICS CO., LTD."),
1459 DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
1463 .matches = {
1464 DMI_MATCH(DMI_SYS_VENDOR,
1465 "SAMSUNG ELECTRONICS CO., LTD."),
1466 DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
1469 /* Specific DMI ids for laptop with quirks */
1471 .callback = samsung_dmi_matched,
1472 .ident = "N150P",
1473 .matches = {
1474 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1475 DMI_MATCH(DMI_PRODUCT_NAME, "N150P"),
1476 DMI_MATCH(DMI_BOARD_NAME, "N150P"),
1478 .driver_data = &samsung_broken_acpi_video,
1481 .callback = samsung_dmi_matched,
1482 .ident = "N145P/N250P/N260P",
1483 .matches = {
1484 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1485 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
1486 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
1488 .driver_data = &samsung_broken_acpi_video,
1491 .callback = samsung_dmi_matched,
1492 .ident = "N150/N210/N220",
1493 .matches = {
1494 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1495 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"),
1496 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"),
1498 .driver_data = &samsung_broken_acpi_video,
1501 .callback = samsung_dmi_matched,
1502 .ident = "NF110/NF210/NF310",
1503 .matches = {
1504 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1505 DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"),
1506 DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"),
1508 .driver_data = &samsung_broken_acpi_video,
1511 .callback = samsung_dmi_matched,
1512 .ident = "N250P",
1513 .matches = {
1514 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1515 DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
1516 DMI_MATCH(DMI_BOARD_NAME, "N250P"),
1518 .driver_data = &samsung_broken_acpi_video,
1520 { },
1522 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
1524 static struct platform_device *samsung_platform_device;
1526 static int __init samsung_init(void)
1528 struct samsung_laptop *samsung;
1529 int ret;
1531 if (efi_enabled(EFI_BOOT))
1532 return -ENODEV;
1534 quirks = &samsung_unknown;
1535 if (!force && !dmi_check_system(samsung_dmi_table))
1536 return -ENODEV;
1538 samsung = kzalloc(sizeof(*samsung), GFP_KERNEL);
1539 if (!samsung)
1540 return -ENOMEM;
1542 mutex_init(&samsung->sabi_mutex);
1543 samsung->handle_backlight = true;
1544 samsung->quirks = quirks;
1547 #if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE)
1548 /* Don't handle backlight here if the acpi video already handle it */
1549 if (acpi_video_backlight_support()) {
1550 if (samsung->quirks->broken_acpi_video) {
1551 pr_info("Disabling ACPI video driver\n");
1552 acpi_video_unregister();
1553 } else {
1554 samsung->handle_backlight = false;
1557 #endif
1559 ret = samsung_platform_init(samsung);
1560 if (ret)
1561 goto error_platform;
1563 ret = samsung_sabi_init(samsung);
1564 if (ret)
1565 goto error_sabi;
1567 #ifdef CONFIG_ACPI
1568 /* Only log that if we are really on a sabi platform */
1569 if (acpi_video_backlight_support() &&
1570 !samsung->quirks->broken_acpi_video)
1571 pr_info("Backlight controlled by ACPI video driver\n");
1572 #endif
1574 ret = samsung_sysfs_init(samsung);
1575 if (ret)
1576 goto error_sysfs;
1578 ret = samsung_backlight_init(samsung);
1579 if (ret)
1580 goto error_backlight;
1582 ret = samsung_rfkill_init(samsung);
1583 if (ret)
1584 goto error_rfkill;
1586 ret = samsung_leds_init(samsung);
1587 if (ret)
1588 goto error_leds;
1590 ret = samsung_debugfs_init(samsung);
1591 if (ret)
1592 goto error_debugfs;
1594 samsung_platform_device = samsung->platform_device;
1595 return ret;
1597 error_debugfs:
1598 samsung_leds_exit(samsung);
1599 error_leds:
1600 samsung_rfkill_exit(samsung);
1601 error_rfkill:
1602 samsung_backlight_exit(samsung);
1603 error_backlight:
1604 samsung_sysfs_exit(samsung);
1605 error_sysfs:
1606 samsung_sabi_exit(samsung);
1607 error_sabi:
1608 samsung_platform_exit(samsung);
1609 error_platform:
1610 kfree(samsung);
1611 return ret;
1614 static void __exit samsung_exit(void)
1616 struct samsung_laptop *samsung;
1618 samsung = platform_get_drvdata(samsung_platform_device);
1620 samsung_debugfs_exit(samsung);
1621 samsung_leds_exit(samsung);
1622 samsung_rfkill_exit(samsung);
1623 samsung_backlight_exit(samsung);
1624 samsung_sysfs_exit(samsung);
1625 samsung_sabi_exit(samsung);
1626 samsung_platform_exit(samsung);
1628 kfree(samsung);
1629 samsung_platform_device = NULL;
1632 module_init(samsung_init);
1633 module_exit(samsung_exit);
1635 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");
1636 MODULE_DESCRIPTION("Samsung Backlight driver");
1637 MODULE_LICENSE("GPL");