aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2010-01-13 15:55:44 -0500
committerCorentin Chary <corentincj@iksaif.net>2010-02-28 13:35:11 -0500
commit6358bf2c4c309efc7c3cbc36466c32108c12c456 (patch)
tree88c2cefbb1a12402e4a0292ffb3c32d9477831ad /drivers/platform
parentaa9df930d6eabbd8f2439eca6b2f77f81ce425f2 (diff)
asus-laptop: stop using read_status and store_status for GPS
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/asus-laptop.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index cee751e301a6..ea51d7e4df21 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -331,26 +331,9 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val)
331 return write_acpi_int_ret(handle, method, val, NULL); 331 return write_acpi_int_ret(handle, method, val, NULL);
332} 332}
333 333
334static int read_gps_status(struct asus_laptop *asus)
335{
336 unsigned long long status;
337 acpi_status rv = AE_OK;
338
339 rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status);
340 if (ACPI_FAILURE(rv))
341 pr_warning("Error reading GPS status\n");
342 else
343 return status ? 1 : 0;
344
345 return (asus->status & GPS_ON) ? 1 : 0;
346}
347
348/* Generic LED functions */ 334/* Generic LED functions */
349static int read_status(struct asus_laptop *asus, int mask) 335static int read_status(struct asus_laptop *asus, int mask)
350{ 336{
351 if (mask == GPS_ON)
352 return read_gps_status(asus);
353
354 return (asus->status & mask) ? 1 : 0; 337 return (asus->status & mask) ? 1 : 0;
355} 338}
356 339
@@ -979,21 +962,52 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr,
979 962
980/* 963/*
981 * GPS 964 * GPS
965 * TODO: use rfkill
982 */ 966 */
967static int asus_gps_status(struct asus_laptop *asus)
968{
969 unsigned long long status;
970 acpi_status rv = AE_OK;
971
972 rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status);
973 if (ACPI_FAILURE(rv)) {
974 pr_warning("Error reading GPS status\n");
975 return -ENODEV;
976 }
977 return !!status;
978}
979
980static int asus_gps_switch(struct asus_laptop *asus, int status)
981{
982 acpi_handle handle = status ? gps_on_handle : gps_off_handle;
983
984 if (write_acpi_int(handle, NULL, 0x02))
985 return -ENODEV;
986 return 0;
987}
988
983static ssize_t show_gps(struct device *dev, 989static ssize_t show_gps(struct device *dev,
984 struct device_attribute *attr, char *buf) 990 struct device_attribute *attr, char *buf)
985{ 991{
986 struct asus_laptop *asus = dev_get_drvdata(dev); 992 struct asus_laptop *asus = dev_get_drvdata(dev);
987 993
988 return sprintf(buf, "%d\n", read_status(asus, GPS_ON)); 994 return sprintf(buf, "%d\n", asus_gps_status(asus));
989} 995}
990 996
991static ssize_t store_gps(struct device *dev, struct device_attribute *attr, 997static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
992 const char *buf, size_t count) 998 const char *buf, size_t count)
993{ 999{
994 struct asus_laptop *asus = dev_get_drvdata(dev); 1000 struct asus_laptop *asus = dev_get_drvdata(dev);
1001 int rv, value;
1002 int ret;
995 1003
996 return store_status(asus, buf, count, NULL, GPS_ON); 1004 rv = parse_arg(buf, count, &value);
1005 if (rv <= 0)
1006 return -EINVAL;
1007 ret = asus_gps_switch(asus, !!value);
1008 if (ret)
1009 return ret;
1010 return rv;
997} 1011}
998 1012
999/* 1013/*
@@ -1451,7 +1465,7 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
1451 set_light_sens_level(asus, asus->light_level); 1465 set_light_sens_level(asus, asus->light_level);
1452 1466
1453 /* GPS is on by default */ 1467 /* GPS is on by default */
1454 write_status(asus, NULL, 1, GPS_ON); 1468 asus_gps_switch(asus, 1);
1455 return result; 1469 return result;
1456} 1470}
1457 1471