File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
741
741
}
742
742
EXPORT_SYMBOL (of_get_next_available_child );
743
743
744
+ /**
745
+ * of_get_next_cpu_node - Iterate on cpu nodes
746
+ * @prev: previous child of the /cpus node, or NULL to get first
747
+ *
748
+ * Returns a cpu node pointer with refcount incremented, use of_node_put()
749
+ * on it when done. Returns NULL when prev is the last child. Decrements
750
+ * the refcount of prev.
751
+ */
752
+ struct device_node * of_get_next_cpu_node (struct device_node * prev )
753
+ {
754
+ struct device_node * next = NULL ;
755
+ unsigned long flags ;
756
+ struct device_node * node ;
757
+
758
+ if (!prev )
759
+ node = of_find_node_by_path ("/cpus" );
760
+
761
+ raw_spin_lock_irqsave (& devtree_lock , flags );
762
+ if (prev )
763
+ next = prev -> sibling ;
764
+ else if (node ) {
765
+ next = node -> child ;
766
+ of_node_put (node );
767
+ }
768
+ for (; next ; next = next -> sibling ) {
769
+ if (!(of_node_name_eq (next , "cpu" ) ||
770
+ (next -> type && !of_node_cmp (next -> type , "cpu" ))))
771
+ continue ;
772
+ if (!__of_device_is_available (next ))
773
+ continue ;
774
+ if (of_node_get (next ))
775
+ break ;
776
+ }
777
+ of_node_put (prev );
778
+ raw_spin_unlock_irqrestore (& devtree_lock , flags );
779
+ return next ;
780
+ }
781
+ EXPORT_SYMBOL (of_get_next_cpu_node );
782
+
744
783
/**
745
784
* of_get_compatible_child - Find compatible child node
746
785
* @parent: parent node
Original file line number Diff line number Diff line change @@ -353,6 +353,8 @@ extern const void *of_get_property(const struct device_node *node,
353
353
const char * name ,
354
354
int * lenp );
355
355
extern struct device_node * of_get_cpu_node (int cpu , unsigned int * thread );
356
+ extern struct device_node * of_get_next_cpu_node (struct device_node * prev );
357
+
356
358
#define for_each_property_of_node (dn , pp ) \
357
359
for (pp = dn->properties; pp != NULL; pp = pp->next)
358
360
@@ -754,6 +756,11 @@ static inline struct device_node *of_get_cpu_node(int cpu,
754
756
return NULL ;
755
757
}
756
758
759
+ static inline struct device_node * of_get_next_cpu_node (struct device_node * prev )
760
+ {
761
+ return NULL ;
762
+ }
763
+
757
764
static inline int of_n_addr_cells (struct device_node * np )
758
765
{
759
766
return 0 ;
@@ -1217,6 +1224,10 @@ static inline int of_property_read_s32(const struct device_node *np,
1217
1224
for (child = of_get_next_available_child(parent, NULL); child != NULL; \
1218
1225
child = of_get_next_available_child(parent, child))
1219
1226
1227
+ #define for_each_of_cpu_node (cpu ) \
1228
+ for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
1229
+ cpu = of_get_next_cpu_node(cpu))
1230
+
1220
1231
#define for_each_node_with_property (dn , prop_name ) \
1221
1232
for (dn = of_find_node_with_property(NULL, prop_name); dn; \
1222
1233
dn = of_find_node_with_property(dn, prop_name))
You can’t perform that action at this time.
0 commit comments