|
@@ -315,6 +315,32 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
|
|
|
}
|
|
|
EXPORT_SYMBOL(of_get_cpu_node);
|
|
|
|
|
|
+/**
|
|
|
+ * of_cpu_node_to_id: Get the logical CPU number for a given device_node
|
|
|
+ *
|
|
|
+ * @cpu_node: Pointer to the device_node for CPU.
|
|
|
+ *
|
|
|
+ * Returns the logical CPU number of the given CPU device_node.
|
|
|
+ * Returns -ENODEV if the CPU is not found.
|
|
|
+ */
|
|
|
+int of_cpu_node_to_id(struct device_node *cpu_node)
|
|
|
+{
|
|
|
+ int cpu;
|
|
|
+ bool found = false;
|
|
|
+ struct device_node *np;
|
|
|
+
|
|
|
+ for_each_possible_cpu(cpu) {
|
|
|
+ np = of_cpu_device_node_get(cpu);
|
|
|
+ found = (cpu_node == np);
|
|
|
+ of_node_put(np);
|
|
|
+ if (found)
|
|
|
+ return cpu;
|
|
|
+ }
|
|
|
+
|
|
|
+ return -ENODEV;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(of_cpu_node_to_id);
|
|
|
+
|
|
|
/**
|
|
|
* __of_device_is_compatible() - Check if the node matches given constraints
|
|
|
* @device: pointer to node
|