From patchwork Tue Feb 2 07:38:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 76265 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 o127dHP7023199 for ; Tue, 2 Feb 2010 07:40:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755640Ab0BBHkj (ORCPT ); Tue, 2 Feb 2010 02:40:39 -0500 Received: from iksaif.net ([88.191.73.63]:57658 "EHLO iksaif.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755643Ab0BBHki (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 04F58C90036; 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 14/28] asus-laptop: stop using read_status for lcd Date: Tue, 2 Feb 2010 08:38:57 +0100 Message-Id: <1265096351-15239-15-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1265096351-15239-14-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> <1265096351-15239-14-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:41 +0000 (UTC) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index ea51d7e..d726db3 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -241,6 +241,7 @@ struct asus_laptop { int wireless_status; bool have_rsts; + int lcd_state; acpi_handle handle; /* the handle of the hotk device */ char status; /* status of the hotk, for LEDs, ... */ @@ -538,30 +539,33 @@ error: /* * Backlight device */ -static int get_lcd_state(struct asus_laptop *asus) +static int asus_lcd_status(struct asus_laptop *asus) { - return read_status(asus, LCD_ON); + return asus->lcd_state; } -static int set_lcd_state(struct asus_laptop *asus, int value) +static int asus_lcd_set(struct asus_laptop *asus, int value) { int lcd = 0; acpi_status status = 0; - lcd = value ? 1 : 0; + lcd = !!value; - if (lcd == get_lcd_state(asus)) + if (lcd == asus_lcd_status(asus)) return 0; - if (lcd_switch_handle) { - status = acpi_evaluate_object(lcd_switch_handle, - NULL, NULL, NULL); + if (!lcd_switch_handle) + return -ENODEV; + + status = acpi_evaluate_object(lcd_switch_handle, + NULL, NULL, NULL); - if (ACPI_FAILURE(status)) - pr_warning("Error switching LCD\n"); + if (ACPI_FAILURE(status)) { + pr_warning("Error switching LCD\n"); + return -ENODEV; } - write_status(asus, NULL, lcd, LCD_ON); + asus->lcd_state = lcd; return 0; } @@ -569,6 +573,8 @@ static void lcd_blank(struct asus_laptop *asus, int blank) { struct backlight_device *bd = asus->backlight_device; + asus->lcd_state = (blank == FB_BLANK_UNBLANK); + if (bd) { bd->props.power = blank; backlight_update_status(bd); @@ -607,7 +613,7 @@ static int update_bl_status(struct backlight_device *bd) return rv; value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0; - return set_lcd_state(asus, value); + return asus_lcd_set(asus, value); } static struct backlight_ops asusbl_ops = { @@ -1144,13 +1150,10 @@ static void asus_acpi_notify(struct acpi_device *device, u32 event) * We need to tell the backlight device when the backlight power is * switched */ - if (event == ATKD_LCD_ON) { - write_status(asus, NULL, 1, LCD_ON); + if (event == ATKD_LCD_ON) lcd_blank(asus, FB_BLANK_UNBLANK); - } else if (event == ATKD_LCD_OFF) { - write_status(asus, NULL, 0, LCD_ON); + else if (event == ATKD_LCD_OFF) lcd_blank(asus, FB_BLANK_POWERDOWN); - } /* TODO Find a better way to handle events count. */ count = asus->event_count[event % 128]++;