Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185051
b: refs/heads/master
c: aa9df93
h: refs/heads/master
i:
  185049: 2de4f18
  185047: 4b8db67
v: v3
  • Loading branch information
Corentin Chary committed Feb 28, 2010
1 parent 43f8f6d commit 9834419
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: be4ee82d3e44c5940a7f77cae5ed3e942e80a723
refs/heads/master: aa9df930d6eabbd8f2439eca6b2f77f81ce425f2
55 changes: 29 additions & 26 deletions trunk/drivers/platform/x86/asus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ struct asus_laptop {

struct asus_laptop_leds leds;

int wireless_status;
bool have_rsts;

acpi_handle handle; /* the handle of the hotk device */
char status; /* status of the hotk, for LEDs, ... */
u32 ledd_status; /* status of the LED display */
Expand Down Expand Up @@ -328,23 +331,6 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val)
return write_acpi_int_ret(handle, method, val, NULL);
}

static int read_wireless_status(struct asus_laptop *asus, int mask)
{
unsigned long long status;
acpi_status rv = AE_OK;

if (!wireless_status_handle)
return (asus->status & mask) ? 1 : 0;

rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
if (ACPI_FAILURE(rv))
pr_warning("Error reading Wireless status\n");
else
return (status & mask) ? 1 : 0;

return (asus->status & mask) ? 1 : 0;
}

static int read_gps_status(struct asus_laptop *asus)
{
unsigned long long status;
Expand All @@ -362,10 +348,7 @@ static int read_gps_status(struct asus_laptop *asus)
/* Generic LED functions */
static int read_status(struct asus_laptop *asus, int mask)
{
/* There is a special method for both wireless devices */
if (mask == BT_ON || mask == WL_ON)
return read_wireless_status(asus, mask);
else if (mask == GPS_ON)
if (mask == GPS_ON)
return read_gps_status(asus);

return (asus->status & mask) ? 1 : 0;
Expand Down Expand Up @@ -811,6 +794,25 @@ static ssize_t store_ledd(struct device *dev, struct device_attribute *attr,
return rv;
}

/*
* Wireless
*/
static int asus_wireless_status(struct asus_laptop *asus, int mask)
{
unsigned long long status;
acpi_status rv = AE_OK;

if (!asus->have_rsts)
return (asus->wireless_status & mask) ? 1 : 0;

rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
if (ACPI_FAILURE(rv)) {
pr_warning("Error reading Wireless status\n");
return -EINVAL;
}
return !!(status & mask);
}

/*
* WLAN
*/
Expand All @@ -819,7 +821,7 @@ static ssize_t show_wlan(struct device *dev,
{
struct asus_laptop *asus = dev_get_drvdata(dev);

return sprintf(buf, "%d\n", read_status(asus, WL_ON));
return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_ON));
}

static ssize_t store_wlan(struct device *dev, struct device_attribute *attr,
Expand All @@ -838,7 +840,7 @@ static ssize_t show_bluetooth(struct device *dev,
{
struct asus_laptop *asus = dev_get_drvdata(dev);

return sprintf(buf, "%d\n", read_status(asus, BT_ON));
return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_ON));
}

static ssize_t store_bluetooth(struct device *dev,
Expand Down Expand Up @@ -1371,7 +1373,8 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
if (hwrs_result & BT_HWRS)
ASUS_HANDLE_INIT(bt_switch);

ASUS_HANDLE_INIT(wireless_status);
if (!ASUS_HANDLE_INIT(wireless_status))
asus->have_rsts = true;

ASUS_HANDLE_INIT(brightness_set);
ASUS_HANDLE_INIT(brightness_get);
Expand Down Expand Up @@ -1424,8 +1427,8 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
write_status(asus, wl_switch_handle, !!wireless_status, WL_ON);

/* If the h/w switch is off, we need to check the real status */
write_status(asus, NULL, read_status(asus, BT_ON), BT_ON);
write_status(asus, NULL, read_status(asus, WL_ON), WL_ON);
write_status(asus, NULL, asus_wireless_status(asus, BT_ON), BT_ON);
write_status(asus, NULL, asus_wireless_status(asus, WL_ON), WL_ON);

/* LCD Backlight is on by default */
write_status(asus, NULL, 1, LCD_ON);
Expand Down

0 comments on commit 9834419

Please sign in to comment.