summaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2017-05-24 10:53:55 -0400
committerRob Herring <robh@kernel.org>2017-06-01 09:50:49 -0400
commitd20dc1493db438fbbfb7733adc82f472dd8a0789 (patch)
treea81ff52fe7e4ed471df24a2e1c48a7d25deb1fcd /include/linux/of.h
parentdebd3a3b27c76c65a7d032b6f01710e6a6d555ab (diff)
of: Support const and non-const use for to_of_node()
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> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index f05c87f0c495..29b7b738b509 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -148,16 +148,20 @@ extern raw_spinlock_t devtree_lock;
148#ifdef CONFIG_OF 148#ifdef CONFIG_OF
149void of_core_init(void); 149void of_core_init(void);
150 150
151static inline bool is_of_node(struct fwnode_handle *fwnode) 151static inline bool is_of_node(const struct fwnode_handle *fwnode)
152{ 152{
153 return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF; 153 return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF;
154} 154}
155 155
156static inline struct device_node *to_of_node(struct fwnode_handle *fwnode) 156#define to_of_node(__fwnode) \
157{ 157 ({ \
158 return is_of_node(fwnode) ? 158 typeof(__fwnode) __to_of_node_fwnode = (__fwnode); \
159 container_of(fwnode, struct device_node, fwnode) : NULL; 159 \
160} 160 is_of_node(__to_of_node_fwnode) ? \
161 container_of(__to_of_node_fwnode, \
162 struct device_node, fwnode) : \
163 NULL; \
164 })
161 165
162#define of_fwnode_handle(node) \ 166#define of_fwnode_handle(node) \
163 ({ \ 167 ({ \
@@ -539,12 +543,12 @@ static inline void of_core_init(void)
539{ 543{
540} 544}
541 545
542static inline bool is_of_node(struct fwnode_handle *fwnode) 546static inline bool is_of_node(const struct fwnode_handle *fwnode)
543{ 547{
544 return false; 548 return false;
545} 549}
546 550
547static inline struct device_node *to_of_node(struct fwnode_handle *fwnode) 551static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode)
548{ 552{
549 return NULL; 553 return NULL;
550} 554}