linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] ACPI: Fix acpi_evaluate_object() return value check
@ 2014-01-21  2:46 Yijing Wang
  2014-01-22 21:37 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Yijing Wang @ 2014-01-21  2:46 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, Daniel Vetter, Jani Nikula, David Airlie,
	Bjorn Helgaas, intel-gfx, dri-devel, linux-kernel, linux-pci,
	Greg Kroah-Hartman, Dave Airlie, Yijing Wang, Hanjun Guo

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 <jani.nikula@intel.com>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
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;
 
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] ACPI: Fix acpi_evaluate_object() return value check
  2014-01-21  2:46 [PATCH v4] ACPI: Fix acpi_evaluate_object() return value check Yijing Wang
@ 2014-01-22 21:37 ` Bjorn Helgaas
  2014-01-23  2:19   ` Yijing Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2014-01-22 21:37 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Rafael J. Wysocki, linux-acpi@vger.kernel.org, Daniel Vetter,
	Jani Nikula, David Airlie, intel-gfx, DRI mailing list,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	Greg Kroah-Hartman, Dave Airlie, Hanjun Guo

On Mon, Jan 20, 2014 at 7:46 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> 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 <jani.nikula@intel.com>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
> 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 ++++++---

For the drivers/pci/pci-label.c part,

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> +       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));

It's too bad there isn't an easy way to produce more informative error
messages, e.g., by including a namespace path or something.  A message
like:

    failed to evaluate _DSM: A requested entity is not found

is only useful if there's enough context to figure out what's going on.

Bjorn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] ACPI: Fix acpi_evaluate_object() return value check
  2014-01-22 21:37 ` Bjorn Helgaas
@ 2014-01-23  2:19   ` Yijing Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Yijing Wang @ 2014-01-23  2:19 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Greg Kroah-Hartman, David Airlie, Daniel Vetter, intel-gfx,
	Rafael J. Wysocki, Hanjun Guo, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, DRI mailing list,
	linux-pci@vger.kernel.org, Dave Airlie

On 2014/1/23 5:37, Bjorn Helgaas wrote:
> On Mon, Jan 20, 2014 at 7:46 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> 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 <jani.nikula@intel.com>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> ---
>> 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 ++++++---
> 
> For the drivers/pci/pci-label.c part,
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Thanks.

> 
>> +       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));
> 
> It's too bad there isn't an easy way to produce more informative error
> messages, e.g., by including a namespace path or something.  A message
> like:
> 
>     failed to evaluate _DSM: A requested entity is not found
> 
> is only useful if there's enough context to figure out what's going on.

Yes, I will add the namespace path into the debug info, thanks!

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-23  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-21  2:46 [PATCH v4] ACPI: Fix acpi_evaluate_object() return value check Yijing Wang
2014-01-22 21:37 ` Bjorn Helgaas
2014-01-23  2:19   ` Yijing Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).