From patchwork Tue Mar 10 08:03:27 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 10821 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2A82Z4j026811 for ; Tue, 10 Mar 2009 08:02:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753012AbZCJICj (ORCPT ); Tue, 10 Mar 2009 04:02:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753011AbZCJICi (ORCPT ); Tue, 10 Mar 2009 04:02:38 -0400 Received: from mga02.intel.com ([134.134.136.20]:52911 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752165AbZCJICh (ORCPT ); Tue, 10 Mar 2009 04:02:37 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 10 Mar 2009 00:56:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,335,1233561600"; d="scan'208";a="393125526" Received: from rzhang-dt.sh.intel.com (HELO [10.239.36.218]) ([10.239.36.218]) by orsmga002.jf.intel.com with ESMTP; 10 Mar 2009 01:11:07 -0700 Subject: [RFC PATCH 2/5] ACPI video: check the return value of acpi_video_device_lcd_set_level From: Zhang Rui To: linux-acpi Cc: Len Brown , trenn@suse.de, Matthew Garrett , "Zhang, Rui" Date: Tue, 10 Mar 2009 16:03:27 +0800 Message-Id: <1236672207.2820.120.camel@rzhang-dt> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Subject: check the return value of acpi_video_device_lcd_set_level From: Zhang Rui check the return value of acpi_video_device_lcd_set_level. Signed-off-by: Zhang Rui --- drivers/acpi/video.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/acpi/video.c =================================================================== --- linux-2.6.orig/drivers/acpi/video.c +++ linux-2.6/drivers/acpi/video.c @@ -322,12 +322,12 @@ static int acpi_video_get_brightness(str static int acpi_video_set_brightness(struct backlight_device *bd) { - int request_level = bd->props.brightness+2; + int request_level = bd->props.brightness + 2; struct acpi_video_device *vd = (struct acpi_video_device *)bl_get_data(bd); - acpi_video_device_lcd_set_level(vd, - vd->brightness->levels[request_level]); - return 0; + + return acpi_video_device_lcd_set_level(vd, + vd->brightness->levels[request_level]); } static struct backlight_ops acpi_backlight_ops = { @@ -482,23 +482,29 @@ acpi_video_device_lcd_query_levels(struc static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) { - int status = AE_OK; + int status; union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; int state; - arg0.integer.value = level; - if (device->cap._BCM) - status = acpi_evaluate_object(device->dev->handle, "_BCM", - &args, NULL); + status = acpi_evaluate_object(device->dev->handle, "_BCM", + &args, NULL); + if (ACPI_FAILURE(status)) { + ACPI_ERROR((AE_INFO, "Evaluating _BCM failed")); + return -EIO; + } + device->brightness->curr = level; for (state = 2; state < device->brightness->count; state++) - if (level == device->brightness->levels[state]) + if (level == device->brightness->levels[state]) { device->backlight->props.brightness = state - 2; + return 0; + } - return status; + ACPI_ERROR((AE_INFO, "Current brightness invalid")); + return -EINVAL; } static int @@ -1072,13 +1078,12 @@ acpi_video_device_write_brightness(struc /* validate through the list of available levels */ for (i = 2; i < dev->brightness->count; i++) if (level == dev->brightness->levels[i]) { - if (ACPI_SUCCESS - (acpi_video_device_lcd_set_level(dev, level))) - dev->brightness->curr = level; + if (!acpi_video_device_lcd_set_level(dev, level)) + return count; break; } - return count; + return -EINVAL; } static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) @@ -1776,7 +1781,7 @@ acpi_video_switch_brightness(struct acpi level_next = acpi_video_get_next_level(device, level_current, event); - acpi_video_device_lcd_set_level(device, level_next); + result = acpi_video_device_lcd_set_level(device, level_next); out: if (result)