devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: devicetree@vger.kernel.org, linux-acpi@vger.kernel.org
Cc: rafael@kernel.org, robh@kernel.org,
	mika.westerberg@linux.intel.com, frowand.list@gmail.com
Subject: [RFC 3/5] of: Return total number of entries in of_count_phandle_with_args
Date: Thu, 14 Sep 2017 15:29:12 +0300	[thread overview]
Message-ID: <20170914122914.14122-4-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20170914122914.14122-1-sakari.ailus@linux.intel.com>

of_count_phandle_with_args used to count the phandles until the end of the
list or when the first empty phandle was encountered. There may be valid
entries after the empty phandle as well, include all entries to the count.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/of/base.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index fb2fd90f525c..4c8b93cfd06c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1418,14 +1418,14 @@ EXPORT_SYMBOL(of_parse_phandle_with_fixed_args);
  * @list_name:	property name that contains a list
  * @cells_name:	property name that specifies phandles' arguments count
  *
- * Returns the number of phandle + argument tuples within a property. It
- * is a typical pattern to encode a list of phandle and variable
- * arguments into a single property. The number of arguments is encoded
- * by a property in the phandle-target node. For example, a gpios
- * property would contain a list of GPIO specifies consisting of a
- * phandle and 1 or more arguments. The number of arguments are
- * determined by the #gpio-cells property in the node pointed to by the
- * phandle.
+ * Returns the number of phandle + argument tuples within a property
+ * including empty phandles. It is a typical pattern to encode a list
+ * of phandle and variable arguments into a single property. The
+ * number of arguments is encoded by a property in the phandle-target
+ * node. For example, a gpios property would contain a list of GPIO
+ * specifies consisting of a phandle and 1 or more arguments. The
+ * number of arguments are determined by the #gpio-cells property in
+ * the node pointed to by the phandle.
  *
  * Returns the number of phandles + arguments tuples within a property
  * on success, %-ENODATA if the property isn't found and %-EINVAL on
@@ -1441,12 +1441,12 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na
 	if (rc)
 		return rc;
 
-	for (rc = of_phandle_iterator_next(&it); !rc;
+	for (rc = of_phandle_iterator_next(&it); !rc || rc == -ENOENT;
 	     rc = of_phandle_iterator_next(&it))
 		cur_index += 1;
 
-	if (rc != -ENODATA && rc != -ENOENT)
-		return rc == -ENOENT ? -ENODATA : rc;
+	if (rc != -ENODATA)
+		return rc;
 
 	return cur_index;
 }
-- 
2.11.0


  parent reply	other threads:[~2017-09-14 12:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 12:29 [RFC 0/5] Align and document return values of phandle and reference parsing for OF and ACPI Sakari Ailus
2017-09-14 12:29 ` [RFC 2/5] of: Return -ENODATA on accessing out of bounds indices in phandle parsing Sakari Ailus
2017-09-14 12:29 ` Sakari Ailus [this message]
     [not found] ` <20170914122914.14122-1-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-14 12:29   ` [RFC 1/5] clk: Increment assigned-clocks index for empty phandles Sakari Ailus
2017-09-14 12:29   ` [RFC 4/5] ACPI: align acpi_fwnode_get_reference_args with OF counterpart Sakari Ailus
2017-09-14 12:29   ` [RFC 5/5] device property: Document fwnode_property_get_reference_args better Sakari Ailus
2017-09-15 19:57 ` [RFC 0/5] Align and document return values of phandle and reference parsing for OF and ACPI Rob Herring
2017-09-19 23:01   ` Sakari Ailus
2017-09-26  9:02     ` 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=20170914122914.14122-4-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=robh@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 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).