diff options
author | Corentin Chary <corentincj@iksaif.net> | 2010-01-13 16:21:33 -0500 |
---|---|---|
committer | Corentin Chary <corentincj@iksaif.net> | 2010-02-28 13:35:11 -0500 |
commit | 17e78f6260fbc8f55c279cca081c26c88d96ec00 (patch) | |
tree | 04488fab7707d671d4efdf51162e9ac88b8cd154 /drivers/platform | |
parent | 3e68ae7c2a9076a694e46f49ec26323a7757eaad (diff) |
asus-laptop: removing read_status/store_status/write_status and asus->status
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/asus-laptop.c | 81 |
1 files changed, 24 insertions, 57 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index d726db380e47..2349e88bbc75 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -107,16 +107,8 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot " | |||
107 | * Flags for hotk status | 107 | * Flags for hotk status |
108 | * WL_ON and BT_ON are also used for wireless_status() | 108 | * WL_ON and BT_ON are also used for wireless_status() |
109 | */ | 109 | */ |
110 | #define WL_ON 0x01 /* internal Wifi */ | 110 | #define WL_RSTS 0x01 /* internal Wifi */ |
111 | #define BT_ON 0x02 /* internal Bluetooth */ | 111 | #define BT_RSTS 0x02 /* internal Bluetooth */ |
112 | #define MLED_ON 0x04 /* mail LED */ | ||
113 | #define TLED_ON 0x08 /* touchpad LED */ | ||
114 | #define RLED_ON 0x10 /* Record LED */ | ||
115 | #define PLED_ON 0x20 /* Phone LED */ | ||
116 | #define GLED_ON 0x40 /* Gaming LED */ | ||
117 | #define LCD_ON 0x80 /* LCD backlight */ | ||
118 | #define GPS_ON 0x100 /* GPS */ | ||
119 | #define KEY_ON 0x200 /* Keyboard backlight */ | ||
120 | 112 | ||
121 | #define ASUS_HANDLE(object, paths...) \ | 113 | #define ASUS_HANDLE(object, paths...) \ |
122 | static acpi_handle object##_handle = NULL; \ | 114 | static acpi_handle object##_handle = NULL; \ |
@@ -244,7 +236,6 @@ struct asus_laptop { | |||
244 | int lcd_state; | 236 | int lcd_state; |
245 | 237 | ||
246 | acpi_handle handle; /* the handle of the hotk device */ | 238 | acpi_handle handle; /* the handle of the hotk device */ |
247 | char status; /* status of the hotk, for LEDs, ... */ | ||
248 | u32 ledd_status; /* status of the LED display */ | 239 | u32 ledd_status; /* status of the LED display */ |
249 | u8 light_level; /* light sensor level */ | 240 | u8 light_level; /* light sensor level */ |
250 | u8 light_switch; /* light sensor switch value */ | 241 | u8 light_switch; /* light sensor switch value */ |
@@ -332,35 +323,18 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val) | |||
332 | return write_acpi_int_ret(handle, method, val, NULL); | 323 | return write_acpi_int_ret(handle, method, val, NULL); |
333 | } | 324 | } |
334 | 325 | ||
335 | /* Generic LED functions */ | 326 | /* Generic LED function */ |
336 | static int read_status(struct asus_laptop *asus, int mask) | 327 | static void asus_led_set(struct asus_laptop *asus, acpi_handle handle, |
328 | int value) | ||
337 | { | 329 | { |
338 | return (asus->status & mask) ? 1 : 0; | 330 | if (handle == mled_set_handle) |
339 | } | 331 | value = !value; |
340 | 332 | else if (handle == gled_set_handle) | |
341 | static void write_status(struct asus_laptop *asus, acpi_handle handle, | 333 | value = !value + 1; |
342 | int out, int mask) | 334 | else |
343 | { | 335 | value = !!value; |
344 | asus->status = (out) ? (asus->status | mask) : (asus->status & ~mask); | ||
345 | |||
346 | switch (mask) { | ||
347 | case MLED_ON: | ||
348 | out = !(out & 0x1); | ||
349 | break; | ||
350 | case GLED_ON: | ||
351 | out = (out & 0x1) + 1; | ||
352 | break; | ||
353 | case GPS_ON: | ||
354 | handle = (out) ? gps_on_handle : gps_off_handle; | ||
355 | out = 0x02; | ||
356 | break; | ||
357 | default: | ||
358 | out &= 0x1; | ||
359 | break; | ||
360 | } | ||
361 | 336 | ||
362 | if (write_acpi_int(handle, NULL, out)) | 337 | write_acpi_int(handle, NULL, value); |
363 | pr_warning(" write failed %x\n", mask); | ||
364 | } | 338 | } |
365 | 339 | ||
366 | /* | 340 | /* |
@@ -403,7 +377,7 @@ ASUS_LED(kled, "kbd_backlight", 3); | |||
403 | struct asus_laptop *asus = work_to_asus(work, object); \ | 377 | struct asus_laptop *asus = work_to_asus(work, object); \ |
404 | \ | 378 | \ |
405 | int value = asus->leds.object##_wk; \ | 379 | int value = asus->leds.object##_wk; \ |
406 | write_status(asus, object##_set_handle, value, (mask)); \ | 380 | asus_led_set(asus, object##_set_handle, value); \ |
407 | } \ | 381 | } \ |
408 | static enum led_brightness object##_led_get( \ | 382 | static enum led_brightness object##_led_get( \ |
409 | struct led_classdev *led_cdev) \ | 383 | struct led_classdev *led_cdev) \ |
@@ -740,9 +714,9 @@ static int parse_arg(const char *buf, unsigned long count, int *val) | |||
740 | return count; | 714 | return count; |
741 | } | 715 | } |
742 | 716 | ||
743 | static ssize_t store_status(struct asus_laptop *asus, | 717 | static ssize_t sysfs_acpi_set(struct asus_laptop *asus, |
744 | const char *buf, size_t count, | 718 | const char *buf, size_t count, |
745 | acpi_handle handle, int mask) | 719 | acpi_handle handle) |
746 | { | 720 | { |
747 | int rv, value; | 721 | int rv, value; |
748 | int out = 0; | 722 | int out = 0; |
@@ -751,8 +725,8 @@ static ssize_t store_status(struct asus_laptop *asus, | |||
751 | if (rv > 0) | 725 | if (rv > 0) |
752 | out = value ? 1 : 0; | 726 | out = value ? 1 : 0; |
753 | 727 | ||
754 | write_status(asus, handle, out, mask); | 728 | if (write_acpi_int(handle, NULL, value)) |
755 | 729 | return -ENODEV; | |
756 | return rv; | 730 | return rv; |
757 | } | 731 | } |
758 | 732 | ||
@@ -810,7 +784,7 @@ static ssize_t show_wlan(struct device *dev, | |||
810 | { | 784 | { |
811 | struct asus_laptop *asus = dev_get_drvdata(dev); | 785 | struct asus_laptop *asus = dev_get_drvdata(dev); |
812 | 786 | ||
813 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_ON)); | 787 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_RSTS)); |
814 | } | 788 | } |
815 | 789 | ||
816 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, | 790 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, |
@@ -818,7 +792,7 @@ static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, | |||
818 | { | 792 | { |
819 | struct asus_laptop *asus = dev_get_drvdata(dev); | 793 | struct asus_laptop *asus = dev_get_drvdata(dev); |
820 | 794 | ||
821 | return store_status(asus, buf, count, wl_switch_handle, WL_ON); | 795 | return sysfs_acpi_set(asus, buf, count, wl_switch_handle); |
822 | } | 796 | } |
823 | 797 | ||
824 | /* | 798 | /* |
@@ -829,7 +803,7 @@ static ssize_t show_bluetooth(struct device *dev, | |||
829 | { | 803 | { |
830 | struct asus_laptop *asus = dev_get_drvdata(dev); | 804 | struct asus_laptop *asus = dev_get_drvdata(dev); |
831 | 805 | ||
832 | return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_ON)); | 806 | return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_RSTS)); |
833 | } | 807 | } |
834 | 808 | ||
835 | static ssize_t store_bluetooth(struct device *dev, | 809 | static ssize_t store_bluetooth(struct device *dev, |
@@ -838,7 +812,7 @@ static ssize_t store_bluetooth(struct device *dev, | |||
838 | { | 812 | { |
839 | struct asus_laptop *asus = dev_get_drvdata(dev); | 813 | struct asus_laptop *asus = dev_get_drvdata(dev); |
840 | 814 | ||
841 | return store_status(asus, buf, count, bt_switch_handle, BT_ON); | 815 | return sysfs_acpi_set(asus, buf, count, bt_switch_handle); |
842 | } | 816 | } |
843 | 817 | ||
844 | /* | 818 | /* |
@@ -1439,16 +1413,9 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus) | |||
1439 | 1413 | ||
1440 | /* WLED and BLED are on by default */ | 1414 | /* WLED and BLED are on by default */ |
1441 | if (bluetooth_status >= 0) | 1415 | if (bluetooth_status >= 0) |
1442 | write_status(asus, bt_switch_handle, !!bluetooth_status, BT_ON); | 1416 | write_acpi_int(bt_switch_handle, NULL, !!bluetooth_status); |
1443 | if (wireless_status >= 0) | 1417 | if (wireless_status >= 0) |
1444 | write_status(asus, wl_switch_handle, !!wireless_status, WL_ON); | 1418 | write_acpi_int(wl_switch_handle, NULL, !!wireless_status); |
1445 | |||
1446 | /* If the h/w switch is off, we need to check the real status */ | ||
1447 | write_status(asus, NULL, asus_wireless_status(asus, BT_ON), BT_ON); | ||
1448 | write_status(asus, NULL, asus_wireless_status(asus, WL_ON), WL_ON); | ||
1449 | |||
1450 | /* LCD Backlight is on by default */ | ||
1451 | write_status(asus, NULL, 1, LCD_ON); | ||
1452 | 1419 | ||
1453 | /* Keyboard Backlight is on by default */ | 1420 | /* Keyboard Backlight is on by default */ |
1454 | if (kled_set_handle) | 1421 | if (kled_set_handle) |