diff options
author | Rob Herring <robh@kernel.org> | 2017-07-05 08:31:52 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2017-07-05 08:31:52 -0500 |
commit | a4485b545e2fad4d65732cb7c60089bf4246de5c (patch) | |
tree | 452caf921257d924d9d7b2b1efbf6f80a03d6a52 /include/linux/of.h | |
parent | 5e1743c0af9d5179cf575c0bc2777af02a79b911 (diff) | |
parent | b8ba92b101e82b82a5359dc2dfbd772eb46780d4 (diff) |
Merge branch 'dt/property-move' into dt/next
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index c72ba9437a43..fa089a2789a0 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; } |