devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bryan Wu <cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	josh.wu-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org,
	cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: [PATCH] of: introduce of_get_available_child_count
Date: Tue, 24 Sep 2013 10:50:09 -0700	[thread overview]
Message-ID: <1380045009-21149-1-git-send-email-cooloney@gmail.com> (raw)

Some drivers keep counting available child by themselves. So
introduce a new simple API like of_get_child_count() but for
available childs.

Cc: Josh Wu <josh.wu-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Bryan Wu <cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 include/linux/of.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/of.h b/include/linux/of.h
index f95aee3..54c2560 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -226,6 +226,17 @@ static inline int of_get_child_count(const struct device_node *np)
 	return num;
 }
 
+static inline int of_get_available_child_count(const struct device_node *np)
+{
+	struct device_node *child;
+	int num = 0;
+
+	for_each_available_child_of_node(np, child)
+		num++;
+
+	return num;
+}
+
 extern struct device_node *of_find_node_with_property(
 	struct device_node *from, const char *prop_name);
 #define for_each_node_with_property(dn, prop_name) \
@@ -376,6 +387,11 @@ static inline int of_get_child_count(const struct device_node *np)
 	return 0;
 }
 
+static inline int of_get_available_child_count(const struct device_node *np)
+{
+	return 0;
+}
+
 static inline int of_device_is_compatible(const struct device_node *device,
 					  const char *name)
 {
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2013-09-24 17:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-24 17:50 Bryan Wu [this message]
     [not found] ` <1380045009-21149-1-git-send-email-cooloney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-24 21:16   ` [PATCH] of: introduce of_get_available_child_count Rob Herring
     [not found]     ` <52420118.9050501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-24 21:22       ` Bryan Wu
     [not found]         ` <CAK5ve-LbgMrD1SFqpaW-L2cmEahaA9Ff+wjrrxwJiG=cVkQrrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-24 18:09           ` Bryan Wu
     [not found]             ` <CAK5ve-+8ySa3gi8smSo88Sq2RCNFRMuB-hSYLs0CYBtkiaG-bw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-25  0:02               ` Grant Likely
     [not found]                 ` <20131025000225.6E449C403B6-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-10-25  0:04                   ` Bryan Wu

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=1380045009-21149-1-git-send-email-cooloney@gmail.com \
    --to=cooloney-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=josh.wu-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.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).