LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: [PATCH 2/2] of: add of_node_read()
Date: Tue, 10 Apr 2018 06:54:13 +0000	[thread overview]
Message-ID: <878t9vv9jv.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87bmerv9ll.wl%kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

We are counting of node by using of_node_get/put(), but
not have of_node_read() which can be used to check count.
Let's add it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/dynamic.c | 14 ++++++++++++++
 include/linux/of.h   |  5 +++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index f4f8ed9..db5fdf3 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -49,6 +49,20 @@ void of_node_put(struct device_node *node)
 }
 EXPORT_SYMBOL(of_node_put);
 
+/**
+ * of_node_read() - read refcount of a node
+ * @node:	Node to dec refcount, NULL is supported to simplify writing of
+ *		callers
+ */
+unsigned int of_node_read(struct device_node *node)
+{
+	if (node)
+		return kobject_read(&node->kobj);
+
+	return 0;
+}
+EXPORT_SYMBOL(of_node_read);
+
 static BLOCKING_NOTIFIER_HEAD(of_reconfig_chain);
 
 int of_reconfig_notifier_register(struct notifier_block *nb)
diff --git a/include/linux/of.h b/include/linux/of.h
index 4d25e4f..8be0ca8 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -122,6 +122,7 @@ static inline void of_node_init(struct device_node *node)
 #ifdef CONFIG_OF_DYNAMIC
 extern struct device_node *of_node_get(struct device_node *node);
 extern void of_node_put(struct device_node *node);
+unsigned int of_node_read(struct device_node *node);
 #else /* CONFIG_OF_DYNAMIC */
 /* Dummy ref counting routines - to be implemented later */
 static inline struct device_node *of_node_get(struct device_node *node)
@@ -129,6 +130,10 @@ static inline struct device_node *of_node_get(struct device_node *node)
 	return node;
 }
 static inline void of_node_put(struct device_node *node) { }
+static inline unsigned int of_node_read(struct device_node *node)
+{
+	return 0;
+}
 #endif /* !CONFIG_OF_DYNAMIC */
 
 /* Pointer for first entry in chain of all nodes. */
-- 
1.9.1

  parent reply	other threads:[~2018-04-10  6:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10  6:53 [PATCH 0/2] add kobject/of_node read() function Kuninori Morimoto
2018-04-10  6:53 ` [PATCH 1/2] kobject: add kobject_read() Kuninori Morimoto
2018-04-10  7:10   ` Greg Kroah-Hartman
2018-04-10  6:54 ` Kuninori Morimoto [this message]
2018-04-10  7:11   ` [PATCH 2/2] of: add of_node_read() Greg Kroah-Hartman

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=878t9vv9jv.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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).