#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
-#include_next <linux/of.h>
-#else
+#define KERNEL_HAS_OF_SUPPORT 1
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */
#ifdef CONFIG_OF
+#define KERNEL_HAS_OF_SUPPORT 1
+#endif /* CONFIG_OF */
+
+#ifdef KERNEL_HAS_OF_SUPPORT
#include_next <linux/of.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
+#ifdef CONFIG_OF
+extern struct device_node *of_get_child_by_name(const struct device_node *node,
+ const char *name);
+#else
+static inline struct device_node *of_get_child_by_name(
+ const struct device_node *node,
+ const char *name)
+{
+ return NULL;
+}
#endif /* CONFIG_OF */
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */
+#endif /* KERNEL_HAS_OF_SUPPORT */
#endif /* _COMPAT_LINUX_OF_H */
return ret;
}
EXPORT_SYMBOL_GPL(pcie_capability_clear_and_set_dword);
+
+#ifdef KERNEL_HAS_OF_SUPPORT
+#ifdef CONFIG_OF
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
+/**
+ * of_get_child_by_name - Find the child node by name for a given parent
+ * @node: parent node
+ * @name: child name to look for.
+ *
+ * This function looks for child node for given matching name
+ *
+ * Returns a node pointer if found, with refcount incremented, use
+ * of_node_put() on it when done.
+ * Returns NULL if node is not found.
+ */
+struct device_node *of_get_child_by_name(const struct device_node *node,
+ const char *name)
+{
+ struct device_node *child;
+
+ for_each_child_of_node(node, child)
+ if (child->name && (of_node_cmp(child->name, name) == 0))
+ break;
+ return child;
+}
+EXPORT_SYMBOL_GPL(of_get_child_by_name);
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */
+#endif /* CONFIG_OF */
+#endif /* KERNEL_HAS_OF_SUPPORT */