#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)                                         \
        ({                                                              \
 {
 }
 
-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;
 }