From patchwork Tue Feb 2 07:38:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 76264 X-Patchwork-Delegate: lenb@kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o127dHP6023199 for ; Tue, 2 Feb 2010 07:40:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755676Ab0BBHki (ORCPT ); Tue, 2 Feb 2010 02:40:38 -0500 Received: from iksaif.net ([88.191.73.63]:57659 "EHLO iksaif.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755640Ab0BBHki (ORCPT ); Tue, 2 Feb 2010 02:40:38 -0500 Received: from localhost.localdomain (lal69-3-82-241-209-44.fbx.proxad.net [82.241.209.44]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id A515EC90042; Tue, 2 Feb 2010 08:40:35 +0100 (CET) From: Corentin Chary To: Len Brown Cc: linux-acpi@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Linux Kernel Mailing List , Corentin Chary Subject: [PATCH 13/28] asus-laptop: stop using read_status and store_status for GPS Date: Tue, 2 Feb 2010 08:38:56 +0100 Message-Id: <1265096351-15239-14-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1265096351-15239-13-git-send-email-corentincj@iksaif.net> References: <1265096351-15239-1-git-send-email-corentincj@iksaif.net> <1265096351-15239-2-git-send-email-corentincj@iksaif.net> <1265096351-15239-3-git-send-email-corentincj@iksaif.net> <1265096351-15239-4-git-send-email-corentincj@iksaif.net> <1265096351-15239-5-git-send-email-corentincj@iksaif.net> <1265096351-15239-6-git-send-email-corentincj@iksaif.net> <1265096351-15239-7-git-send-email-corentincj@iksaif.net> <1265096351-15239-8-git-send-email-corentincj@iksaif.net> <1265096351-15239-9-git-send-email-corentincj@iksaif.net> <1265096351-15239-10-git-send-email-corentincj@iksaif.net> <1265096351-15239-11-git-send-email-corentincj@iksaif.net> <1265096351-15239-12-git-send-email-corentincj@iksaif.net> <1265096351-15239-13-git-send-email-corentincj@iksaif.net> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Feb 2010 07:40:39 +0000 (UTC) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index cee751e..ea51d7e 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) 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; } @@ -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; } /* @@ -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; }