summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-06-22 02:54:52 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-06-22 02:54:52 +0200
commit2b8153421de8c29864cb147f241804858440bfa1 (patch)
treef8ea3de2f8037aa21f454316482b59e594cc1c26 /include/linux
parent41f1830f5a7af77cf5c86359aba3cbd706687e52 (diff)
parentd20dc1493db438fbbfb7733adc82f472dd8a0789 (diff)
downloadcachepc-linux-2b8153421de8c29864cb147f241804858440bfa1.tar.gz
cachepc-linux-2b8153421de8c29864cb147f241804858440bfa1.zip
Merge branch 'dt/property-move' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull DT-related device properties changes from Rob Herring. * 'dt/property-move' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: of: Support const and non-const use for to_of_node() of: Make of_fwnode_handle() safer of: Move OF property and graph API from base.c to property.c
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/of.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index 50fcdb54087f..29b7b738b509 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -148,18 +148,28 @@ 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 of_fwnode_handle(node) (&(node)->fwnode)
+#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) \
+ ({ \
+ typeof(node) __of_fwnode_handle_node = (node); \
+ \
+ __of_fwnode_handle_node ? \
+ &__of_fwnode_handle_node->fwnode : NULL; \
+ })
static inline bool of_have_populated_dt(void)
{
@@ -533,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;
}