Commit 0da773c5 authored by Sakari Ailus's avatar Sakari Ailus Committed by Greg Kroah-Hartman

of: Support const and non-const use for to_of_node()

commit d20dc149 upstream.

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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 883f7c32
......@@ -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; \
})
static inline bool of_have_populated_dt(void)
{
......@@ -529,12 +533,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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment