Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185052
b: refs/heads/master
c: 6358bf2
h: refs/heads/master
v: v3
  • Loading branch information
Corentin Chary committed Feb 28, 2010
1 parent 9834419 commit 45d0314
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 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: aa9df930d6eabbd8f2439eca6b2f77f81ce425f2
refs/heads/master: 6358bf2c4c309efc7c3cbc36466c32108c12c456
56 changes: 35 additions & 21 deletions trunk/drivers/platform/x86/asus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,26 +331,9 @@ 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_gps_status(struct asus_laptop *asus)
{
unsigned long long status;
acpi_status rv = AE_OK;

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

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

/* Generic LED functions */
static int read_status(struct asus_laptop *asus, int mask)
{
if (mask == GPS_ON)
return read_gps_status(asus);

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

Expand Down Expand Up @@ -979,21 +962,52 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr,

/*
* GPS
* TODO: use rfkill
*/
static int asus_gps_status(struct asus_laptop *asus)
{
unsigned long long status;
acpi_status rv = AE_OK;

rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status);
if (ACPI_FAILURE(rv)) {
pr_warning("Error reading GPS status\n");
return -ENODEV;
}
return !!status;
}

static int asus_gps_switch(struct asus_laptop *asus, int status)
{
acpi_handle handle = status ? gps_on_handle : gps_off_handle;

if (write_acpi_int(handle, NULL, 0x02))
return -ENODEV;
return 0;
}

static ssize_t show_gps(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct asus_laptop *asus = dev_get_drvdata(dev);

return sprintf(buf, "%d\n", read_status(asus, GPS_ON));
return sprintf(buf, "%d\n", asus_gps_status(asus));
}

static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct asus_laptop *asus = dev_get_drvdata(dev);
struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value;
int ret;

return store_status(asus, buf, count, NULL, GPS_ON);
rv = parse_arg(buf, count, &value);
if (rv <= 0)
return -EINVAL;
ret = asus_gps_switch(asus, !!value);
if (ret)
return ret;
return rv;
}

/*
Expand Down Expand Up @@ -1451,7 +1465,7 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
set_light_sens_level(asus, asus->light_level);

/* GPS is on by default */
write_status(asus, NULL, 1, GPS_ON);
asus_gps_switch(asus, 1);
return result;
}

Expand Down

0 comments on commit 45d0314

Please sign in to comment.