diff options
author | Corentin Chary <corentincj@iksaif.net> | 2010-01-13 15:49:10 -0500 |
---|---|---|
committer | Corentin Chary <corentincj@iksaif.net> | 2010-02-28 13:35:11 -0500 |
commit | aa9df930d6eabbd8f2439eca6b2f77f81ce425f2 (patch) | |
tree | f206ce0cc25c8a93d72ff9f6e444a6e4af4f2c7b /drivers/platform/x86/asus-laptop.c | |
parent | be4ee82d3e44c5940a7f77cae5ed3e942e80a723 (diff) |
asus-laptop: stop using read_status for bluetooth and wlan
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Diffstat (limited to 'drivers/platform/x86/asus-laptop.c')
-rw-r--r-- | drivers/platform/x86/asus-laptop.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 940ce3d63229..cee751e301a6 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -239,6 +239,9 @@ struct asus_laptop { | |||
239 | 239 | ||
240 | struct asus_laptop_leds leds; | 240 | struct asus_laptop_leds leds; |
241 | 241 | ||
242 | int wireless_status; | ||
243 | bool have_rsts; | ||
244 | |||
242 | acpi_handle handle; /* the handle of the hotk device */ | 245 | acpi_handle handle; /* the handle of the hotk device */ |
243 | char status; /* status of the hotk, for LEDs, ... */ | 246 | char status; /* status of the hotk, for LEDs, ... */ |
244 | u32 ledd_status; /* status of the LED display */ | 247 | u32 ledd_status; /* status of the LED display */ |
@@ -328,23 +331,6 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val) | |||
328 | return write_acpi_int_ret(handle, method, val, NULL); | 331 | return write_acpi_int_ret(handle, method, val, NULL); |
329 | } | 332 | } |
330 | 333 | ||
331 | static int read_wireless_status(struct asus_laptop *asus, int mask) | ||
332 | { | ||
333 | unsigned long long status; | ||
334 | acpi_status rv = AE_OK; | ||
335 | |||
336 | if (!wireless_status_handle) | ||
337 | return (asus->status & mask) ? 1 : 0; | ||
338 | |||
339 | rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status); | ||
340 | if (ACPI_FAILURE(rv)) | ||
341 | pr_warning("Error reading Wireless status\n"); | ||
342 | else | ||
343 | return (status & mask) ? 1 : 0; | ||
344 | |||
345 | return (asus->status & mask) ? 1 : 0; | ||
346 | } | ||
347 | |||
348 | static int read_gps_status(struct asus_laptop *asus) | 334 | static int read_gps_status(struct asus_laptop *asus) |
349 | { | 335 | { |
350 | unsigned long long status; | 336 | unsigned long long status; |
@@ -362,10 +348,7 @@ static int read_gps_status(struct asus_laptop *asus) | |||
362 | /* Generic LED functions */ | 348 | /* Generic LED functions */ |
363 | static int read_status(struct asus_laptop *asus, int mask) | 349 | static int read_status(struct asus_laptop *asus, int mask) |
364 | { | 350 | { |
365 | /* There is a special method for both wireless devices */ | 351 | if (mask == GPS_ON) |
366 | if (mask == BT_ON || mask == WL_ON) | ||
367 | return read_wireless_status(asus, mask); | ||
368 | else if (mask == GPS_ON) | ||
369 | return read_gps_status(asus); | 352 | return read_gps_status(asus); |
370 | 353 | ||
371 | return (asus->status & mask) ? 1 : 0; | 354 | return (asus->status & mask) ? 1 : 0; |
@@ -812,6 +795,25 @@ static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, | |||
812 | } | 795 | } |
813 | 796 | ||
814 | /* | 797 | /* |
798 | * Wireless | ||
799 | */ | ||
800 | static int asus_wireless_status(struct asus_laptop *asus, int mask) | ||
801 | { | ||
802 | unsigned long long status; | ||
803 | acpi_status rv = AE_OK; | ||
804 | |||
805 | if (!asus->have_rsts) | ||
806 | return (asus->wireless_status & mask) ? 1 : 0; | ||
807 | |||
808 | rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status); | ||
809 | if (ACPI_FAILURE(rv)) { | ||
810 | pr_warning("Error reading Wireless status\n"); | ||
811 | return -EINVAL; | ||
812 | } | ||
813 | return !!(status & mask); | ||
814 | } | ||
815 | |||
816 | /* | ||
815 | * WLAN | 817 | * WLAN |
816 | */ | 818 | */ |
817 | static ssize_t show_wlan(struct device *dev, | 819 | static ssize_t show_wlan(struct device *dev, |
@@ -819,7 +821,7 @@ static ssize_t show_wlan(struct device *dev, | |||
819 | { | 821 | { |
820 | struct asus_laptop *asus = dev_get_drvdata(dev); | 822 | struct asus_laptop *asus = dev_get_drvdata(dev); |
821 | 823 | ||
822 | return sprintf(buf, "%d\n", read_status(asus, WL_ON)); | 824 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_ON)); |
823 | } | 825 | } |
824 | 826 | ||
825 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, | 827 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, |
@@ -838,7 +840,7 @@ static ssize_t show_bluetooth(struct device *dev, | |||
838 | { | 840 | { |
839 | struct asus_laptop *asus = dev_get_drvdata(dev); | 841 | struct asus_laptop *asus = dev_get_drvdata(dev); |
840 | 842 | ||
841 | return sprintf(buf, "%d\n", read_status(asus, BT_ON)); | 843 | return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_ON)); |
842 | } | 844 | } |
843 | 845 | ||
844 | static ssize_t store_bluetooth(struct device *dev, | 846 | static ssize_t store_bluetooth(struct device *dev, |
@@ -1371,7 +1373,8 @@ static int asus_laptop_get_info(struct asus_laptop *asus) | |||
1371 | if (hwrs_result & BT_HWRS) | 1373 | if (hwrs_result & BT_HWRS) |
1372 | ASUS_HANDLE_INIT(bt_switch); | 1374 | ASUS_HANDLE_INIT(bt_switch); |
1373 | 1375 | ||
1374 | ASUS_HANDLE_INIT(wireless_status); | 1376 | if (!ASUS_HANDLE_INIT(wireless_status)) |
1377 | asus->have_rsts = true; | ||
1375 | 1378 | ||
1376 | ASUS_HANDLE_INIT(brightness_set); | 1379 | ASUS_HANDLE_INIT(brightness_set); |
1377 | ASUS_HANDLE_INIT(brightness_get); | 1380 | ASUS_HANDLE_INIT(brightness_get); |
@@ -1424,8 +1427,8 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus) | |||
1424 | write_status(asus, wl_switch_handle, !!wireless_status, WL_ON); | 1427 | write_status(asus, wl_switch_handle, !!wireless_status, WL_ON); |
1425 | 1428 | ||
1426 | /* If the h/w switch is off, we need to check the real status */ | 1429 | /* If the h/w switch is off, we need to check the real status */ |
1427 | write_status(asus, NULL, read_status(asus, BT_ON), BT_ON); | 1430 | write_status(asus, NULL, asus_wireless_status(asus, BT_ON), BT_ON); |
1428 | write_status(asus, NULL, read_status(asus, WL_ON), WL_ON); | 1431 | write_status(asus, NULL, asus_wireless_status(asus, WL_ON), WL_ON); |
1429 | 1432 | ||
1430 | /* LCD Backlight is on by default */ | 1433 | /* LCD Backlight is on by default */ |
1431 | write_status(asus, NULL, 1, LCD_ON); | 1434 | write_status(asus, NULL, 1, LCD_ON); |