From patchwork Tue Jan 21 02:46:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 3515151 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CBABEC02DC for ; Tue, 21 Jan 2014 02:46:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4B8E20148 for ; Tue, 21 Jan 2014 02:46:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 785B620125 for ; Tue, 21 Jan 2014 02:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752179AbaAUCqx (ORCPT ); Mon, 20 Jan 2014 21:46:53 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:30596 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbaAUCqw (ORCPT ); Mon, 20 Jan 2014 21:46:52 -0500 Received: from 172.24.2.119 (EHLO szxeml210-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BOW49219; Tue, 21 Jan 2014 10:46:36 +0800 (CST) Received: from SZXEML456-HUB.china.huawei.com (10.82.67.199) by szxeml210-edg.china.huawei.com (172.24.2.183) with Microsoft SMTP Server (TLS) id 14.3.158.1; Tue, 21 Jan 2014 10:46:31 +0800 Received: from localhost (10.177.27.212) by szxeml456-hub.china.huawei.com (10.82.67.199) with Microsoft SMTP Server id 14.3.158.1; Tue, 21 Jan 2014 10:46:23 +0800 From: Yijing Wang To: "Rafael J. Wysocki" CC: , Daniel Vetter , Jani Nikula , David Airlie , Bjorn Helgaas , , , , , Greg Kroah-Hartman , Dave Airlie , Yijing Wang , Hanjun Guo Subject: [PATCH v4] ACPI: Fix acpi_evaluate_object() return value check Date: Tue, 21 Jan 2014 10:46:15 +0800 Message-ID: <1390272375-28728-1-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.27.212] X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since acpi_evaluate_object() returns acpi_status and not plain int, ACPI_FAILURE() should be used for checking its return value. Reviewed-by: Jani Nikula Signed-off-by: Yijing Wang Acked-by: Bjorn Helgaas --- v3->v4: Fix spell error, add Jani Nikula reviewed-by. v2->v3: Fix compile error pointed out by Hanjun. v1->v2: Add CC to related subsystem MAINTAINERS --- drivers/gpu/drm/i915/intel_acpi.c | 24 ++++++++++++++---------- drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | 9 +++++---- drivers/gpu/drm/nouveau/nouveau_acpi.c | 23 +++++++++++++---------- drivers/pci/pci-label.c | 9 ++++++--- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c index dfff090..87e8f74 100644 --- a/drivers/gpu/drm/i915/intel_acpi.c +++ b/drivers/gpu/drm/i915/intel_acpi.c @@ -35,7 +35,8 @@ static int intel_dsm(acpi_handle handle, int func) union acpi_object params[4]; union acpi_object *obj; u32 result; - int ret = 0; + acpi_status status; + int ret; input.count = 4; input.pointer = params; @@ -50,10 +51,11 @@ static int intel_dsm(acpi_handle handle, int func) params[3].package.count = 0; params[3].package.elements = NULL; - ret = acpi_evaluate_object(handle, "_DSM", &input, &output); - if (ret) { - DRM_DEBUG_DRIVER("failed to evaluate _DSM: %d\n", ret); - return ret; + status = acpi_evaluate_object(handle, "_DSM", &input, &output); + if (ACPI_FAILURE(status)) { + DRM_DEBUG_DRIVER("failed to evaluate _DSM: %s\n", + acpi_format_exception(status)); + return -EINVAL; } obj = (union acpi_object *)output.pointer; @@ -141,7 +143,8 @@ static void intel_dsm_platform_mux_info(void) struct acpi_object_list input; union acpi_object params[4]; union acpi_object *pkg; - int i, ret; + acpi_status status; + int i; input.count = 4; input.pointer = params; @@ -156,10 +159,11 @@ static void intel_dsm_platform_mux_info(void) params[3].package.count = 0; params[3].package.elements = NULL; - ret = acpi_evaluate_object(intel_dsm_priv.dhandle, "_DSM", &input, - &output); - if (ret) { - DRM_DEBUG_DRIVER("failed to evaluate _DSM: %d\n", ret); + acpi_status = acpi_evaluate_object(intel_dsm_priv.dhandle, + "_DSM", &input, &output); + if (ACPI_FAILURE(status)) { + DRM_DEBUG_DRIVER("failed to evaluate _DSM: %s\n", + acpi_format_exception(status)); goto out; } diff --git a/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c b/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c index 1291204..c5e7a2b 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c @@ -114,15 +114,16 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version) struct acpi_buffer retn = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *obj; acpi_handle handle; - int ret; + acpi_status status; handle = ACPI_HANDLE(&device->pdev->dev); if (!handle) return false; - ret = acpi_evaluate_object(handle, "_DSM", &list, &retn); - if (ret) { - nv_debug(mxm, "DSM MXMS failed: %d\n", ret); + status = acpi_evaluate_object(handle, "_DSM", &list, &retn); + if (ACPI_FAILURE(status)) { + nv_debug(mxm, "DSM MXMS failed: %s\n", + acpi_format_exception(status)); return false; } diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index ba0183f..de3068b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -82,7 +82,8 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t * struct acpi_object_list input; union acpi_object params[4]; union acpi_object *obj; - int i, err; + acpi_status status; + int i; char args_buff[4]; input.count = 4; @@ -101,10 +102,11 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t * args_buff[i] = (arg >> i * 8) & 0xFF; params[3].buffer.pointer = args_buff; - err = acpi_evaluate_object(handle, "_DSM", &input, &output); - if (err) { - printk(KERN_INFO "failed to evaluate _DSM: %d\n", err); - return err; + status = acpi_evaluate_object(handle, "_DSM", &input, &output); + if (ACPI_FAILURE(status)) { + pr_info("failed to evaluate _DSM: %s\n", + acpi_format_exception(status)); + return -EINVAL; } obj = (union acpi_object *)output.pointer; @@ -134,7 +136,7 @@ static int nouveau_dsm(acpi_handle handle, int func, int arg, uint32_t *result) struct acpi_object_list input; union acpi_object params[4]; union acpi_object *obj; - int err; + acpi_status status; input.count = 4; input.pointer = params; @@ -148,10 +150,11 @@ static int nouveau_dsm(acpi_handle handle, int func, int arg, uint32_t *result) params[3].type = ACPI_TYPE_INTEGER; params[3].integer.value = arg; - err = acpi_evaluate_object(handle, "_DSM", &input, &output); - if (err) { - printk(KERN_INFO "failed to evaluate _DSM: %d\n", err); - return err; + status = acpi_evaluate_object(handle, "_DSM", &input, &output); + if (ACPI_FAILURE(status)) { + pr_info("failed to evaluate _DSM: %s\n", + acpi_format_exception(status)); + return -EINVAL; } obj = (union acpi_object *)output.pointer; diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index d51f45a..7ba4de6 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c @@ -213,7 +213,7 @@ dsm_get_label(acpi_handle handle, int func, union acpi_object *obj; int len = 0; - int err; + acpi_status status; input.count = 4; input.pointer = params; @@ -228,9 +228,12 @@ dsm_get_label(acpi_handle handle, int func, params[3].package.count = 0; params[3].package.elements = NULL; - err = acpi_evaluate_object(handle, "_DSM", &input, output); - if (err) + status = acpi_evaluate_object(handle, "_DSM", &input, output); + if (ACPI_FAILURE(status)) { + pr_info("failed to evaluate _DSM: %s\n", + acpi_format_exception(status)); return -1; + } obj = (union acpi_object *)output->pointer;