All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: rafael@kernel.org, mika.westerberg@intel.com, hyungwoo.yang@intel.com
Subject: [PATCH 1/1] device properties: Fix return codes for __acpi_node_get_property_reference
Date: Thu,  5 Oct 2017 09:04:24 +0300	[thread overview]
Message-ID: <20171005060424.16780-1-sakari.ailus@linux.intel.com> (raw)

Fix more return codes for device property: Align return codes of
__acpi_node_get_property_reference. In particular what was missed
previously:

-EPROTO could be returned in certain cases, now -EINVAL;
-EINVAL was returned if the property was not found, now -ENOENT;
-EINVAL was returned also if the index was higher than the number of
entries in a package, now -ENOENT.

Fixes: ("device property: Align return codes of __acpi_node_get_property_reference")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Hyungwoo Yang <hyungwoo.yang@intel.com>
---
Hi Rafael,

Unfortunately the patch I posted the previous time to remedy the issue
("device property: Align return codes of
_acpi_node_get_property_reference") did not fully fix the issue.

 drivers/acpi/property.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 5a8ac5e1081b..8c28c516e7ec 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -592,8 +592,16 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 		return -ENOENT;
 
 	ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj);
-	if (ret)
-		return ret;
+	switch (ret) {
+	case -EINVAL:
+		return -ENOENT;
+	case -EPROTO:
+		return -EINVAL;
+	default:
+		if (ret)
+			return ret;
+		break;
+	}
 
 	/*
 	 * The simplest case is when the value is a single reference.  Just
@@ -605,7 +613,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 
 		ret = acpi_bus_get_device(obj->reference.handle, &device);
 		if (ret)
-			return ret;
+			return ret == -ENODEV ? -EINVAL : ret;
 
 		args->adev = device;
 		args->nargs = 0;
@@ -621,8 +629,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 	 * The index argument is then used to determine which reference
 	 * the caller wants (along with the arguments).
 	 */
-	if (obj->type != ACPI_TYPE_PACKAGE || index >= obj->package.count)
-		return -EPROTO;
+	if (obj->type != ACPI_TYPE_PACKAGE)
+		return -EINVAL;
+	if (index >= obj->package.count)
+		return -ENOENT;
 
 	element = obj->package.elements;
 	end = element + obj->package.count;
-- 
2.11.0


             reply	other threads:[~2017-10-05  6:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-05  6:04 Sakari Ailus [this message]
2017-10-05 12:59 ` [PATCH 1/1] device properties: Fix return codes for __acpi_node_get_property_reference Rafael J. Wysocki
2017-10-05 14:01   ` Sakari Ailus
2017-10-05 15:30     ` Rafael J. Wysocki
2017-10-05 22:04       ` Sakari Ailus
2017-10-05 22:22         ` Rafael J. Wysocki
2017-10-10 12:43           ` Sakari Ailus
2017-10-05 20:40     ` Rafael J. Wysocki
2017-10-10 14:22       ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171005060424.16780-1-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=hyungwoo.yang@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mika.westerberg@intel.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.