archive mirror
 help / color / mirror / Atom feed
From: Alban Bedel <>
To: Philipp Zabel <>
Cc:, Alban Bedel <>
Subject: [PATCH] reset: Fix of_reset_control_get() for consistent return values
Date: Tue,  1 Sep 2015 17:28:31 +0200	[thread overview]
Message-ID: <> (raw)

When of_reset_control_get() is called without connection ID it returns
-ENOENT when the 'resets' property doesn't exists or is an empty entry.
However when a connection ID is given it returns -EINVAL when the 'resets'
property doesn't exists or the requested name can't be found. This is
because the error code returned by of_property_match_string() is just
passed down as an index to of_parse_phandle_with_args(), which then
returns -EINVAL.

To get a consistent return value with both code paths we must return
-ENOENT when of_property_match_string() fails.

Signed-off-by: Alban Bedel <>
 drivers/reset/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 3cbc764..fd6ac9b 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -265,9 +265,12 @@ struct reset_control *of_reset_control_get(struct device_node *node,
 	int rstc_id;
 	int ret;
-	if (id)
+	if (id) {
 		index = of_property_match_string(node,
 						 "reset-names", id);
+		if (index < 0)
+			return ERR_PTR(-ENOENT);
+	}
 	ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
 					 index, &args);
 	if (ret)

             reply	other threads:[~2015-09-01 15:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 15:28 Alban Bedel [this message]
2015-09-02 15:09 ` [PATCH] reset: Fix of_reset_control_get() for consistent return values Philipp Zabel
2015-09-02 16:35   ` Alban
2015-09-03  9:49     ` Philipp Zabel

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:

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

  git send-email \ \ \ \ \

* 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 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).