summaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2017-05-24 17:53:55 +0300
committerRob Herring <robh@kernel.org>2017-06-01 08:50:49 -0500
commitd20dc1493db438fbbfb7733adc82f472dd8a0789 (patch)
treea81ff52fe7e4ed471df24a2e1c48a7d25deb1fcd /include/linux/of.h
parentdebd3a3b27c76c65a7d032b6f01710e6a6d555ab (diff)
downloadop-kernel-dev-d20dc1493db438fbbfb7733adc82f472dd8a0789.zip
op-kernel-dev-d20dc1493db438fbbfb7733adc82f472dd8a0789.tar.gz
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 f05c87f..29b7b738b 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) \
({ \
@@ -539,12 +543,12 @@ static inline 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 false;
}
-static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
+static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode)
{
return NULL;
}
OpenPOWER on IntegriCloud