These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / of / base.c
index 5ed9724..017dd94 100644 (file)
@@ -375,10 +375,7 @@ bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun,
                                           cpu, thread))
                return true;
 
-       if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
-               return true;
-
-       return false;
+       return __of_find_n_match_cpu_property(cpun, "reg", cpu, thread);
 }
 
 /**
@@ -2230,6 +2227,40 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 }
 EXPORT_SYMBOL(of_graph_get_next_endpoint);
 
+/**
+ * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers
+ * @parent: pointer to the parent device node
+ * @port_reg: identifier (value of reg property) of the parent port node
+ * @reg: identifier (value of reg property) of the endpoint node
+ *
+ * Return: An 'endpoint' node pointer which is identified by reg and at the same
+ * is the child of a port node identified by port_reg. reg and port_reg are
+ * ignored when they are -1.
+ */
+struct device_node *of_graph_get_endpoint_by_regs(
+       const struct device_node *parent, int port_reg, int reg)
+{
+       struct of_endpoint endpoint;
+       struct device_node *node, *prev_node = NULL;
+
+       while (1) {
+               node = of_graph_get_next_endpoint(parent, prev_node);
+               of_node_put(prev_node);
+               if (!node)
+                       break;
+
+               of_graph_parse_endpoint(node, &endpoint);
+               if (((port_reg == -1) || (endpoint.port == port_reg)) &&
+                       ((reg == -1) || (endpoint.id == reg)))
+                       return node;
+
+               prev_node = node;
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL(of_graph_get_endpoint_by_regs);
+
 /**
  * of_graph_get_remote_port_parent() - get remote port's parent node
  * @node: pointer to a local endpoint device_node