From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: devicetree@vger.kernel.org, robh@kernel.org, frowand.list@gmail.com
Cc: linux-acpi@vger.kernel.org, sudeep.holla@arm.com,
lorenzo.pieralisi@arm.com, mika.westerberg@linux.intel.com,
rafael@kernel.org, mark.rutland@arm.com, broonie@kernel.org,
ahs3@redhat.com
Subject: [RESEND PATCH v4 3/3] of: Support const and non-const use for to_of_node()
Date: Thu, 18 May 2017 14:12:39 +0300 [thread overview]
Message-ID: <1495105959-20146-1-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1495104163-17165-1-git-send-email-sakari.ailus@linux.intel.com>
Turn to_of_node() into a macro in order to support both const and
non-const use. Additionally make the fwnode argument to is_of_node() const
as well.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
This was actually in another set, but fits better here.
(Now with correct In-Reply-To header.)
include/linux/of.h | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index a7ccf34..03dbc94 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -148,16 +148,20 @@ extern raw_spinlock_t devtree_lock;
#ifdef CONFIG_OF
void of_core_init(void);
-static inline bool is_of_node(struct fwnode_handle *fwnode)
+static inline bool is_of_node(const struct fwnode_handle *fwnode)
{
return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF;
}
-static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
-{
- return is_of_node(fwnode) ?
- container_of(fwnode, struct device_node, fwnode) : NULL;
-}
+#define to_of_node(__fwnode) \
+ ({ \
+ typeof(__fwnode) __to_of_node_fwnode = __fwnode; \
+ \
+ is_of_node(__to_of_node_fwnode) ? \
+ container_of(__to_of_node_fwnode, \
+ struct device_node, fwnode) : \
+ NULL; \
+ })
#define of_fwnode_handle(node) \
({ \
--
2.7.4
prev parent reply other threads:[~2017-05-18 11:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 10:42 [PATCH v4 0/2] Preparation for further fwnode property cleanup Sakari Ailus
2017-05-18 10:42 ` [PATCH v4 1/2] of: Move OF property and graph API from base.c to property.c Sakari Ailus
2017-05-18 10:42 ` [PATCH v4 2/2] of: Make of_fwnode_handle() safer Sakari Ailus
2017-05-18 11:12 ` Sakari Ailus [this message]
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=1495105959-20146-1-git-send-email-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=ahs3@redhat.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sudeep.holla@arm.com \
/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).