@@ -169,35 +169,15 @@ static inline const char *of_node_full_name(const struct device_node *np)
169
169
170
170
extern struct device_node * of_find_node_by_name (struct device_node * from ,
171
171
const char * name );
172
- #define for_each_node_by_name (dn , name ) \
173
- for (dn = of_find_node_by_name(NULL, name); dn; \
174
- dn = of_find_node_by_name(dn, name))
175
172
extern struct device_node * of_find_node_by_type (struct device_node * from ,
176
173
const char * type );
177
- #define for_each_node_by_type (dn , type ) \
178
- for (dn = of_find_node_by_type(NULL, type); dn; \
179
- dn = of_find_node_by_type(dn, type))
180
174
extern struct device_node * of_find_compatible_node (struct device_node * from ,
181
175
const char * type , const char * compat );
182
- #define for_each_compatible_node (dn , type , compatible ) \
183
- for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
184
- dn = of_find_compatible_node(dn, type, compatible))
185
176
extern struct device_node * of_find_matching_node_and_match (
186
177
struct device_node * from ,
187
178
const struct of_device_id * matches ,
188
179
const struct of_device_id * * match );
189
- static inline struct device_node * of_find_matching_node (
190
- struct device_node * from ,
191
- const struct of_device_id * matches )
192
- {
193
- return of_find_matching_node_and_match (from , matches , NULL );
194
- }
195
- #define for_each_matching_node (dn , matches ) \
196
- for (dn = of_find_matching_node(NULL, matches); dn; \
197
- dn = of_find_matching_node(dn, matches))
198
- #define for_each_matching_node_and_match (dn , matches , match ) \
199
- for (dn = of_find_matching_node_and_match(NULL, matches, match); \
200
- dn; dn = of_find_matching_node_and_match(dn, matches, match))
180
+
201
181
extern struct device_node * of_find_node_by_path (const char * path );
202
182
extern struct device_node * of_find_node_by_phandle (phandle handle );
203
183
extern struct device_node * of_get_parent (const struct device_node * node );
@@ -209,43 +189,11 @@ extern struct device_node *of_get_next_available_child(
209
189
210
190
extern struct device_node * of_get_child_by_name (const struct device_node * node ,
211
191
const char * name );
212
- #define for_each_child_of_node (parent , child ) \
213
- for (child = of_get_next_child(parent, NULL); child != NULL; \
214
- child = of_get_next_child(parent, child))
215
-
216
- #define for_each_available_child_of_node (parent , child ) \
217
- for (child = of_get_next_available_child(parent, NULL); child != NULL; \
218
- child = of_get_next_available_child(parent, child))
219
-
220
- static inline int of_get_child_count (const struct device_node * np )
221
- {
222
- struct device_node * child ;
223
- int num = 0 ;
224
-
225
- for_each_child_of_node (np , child )
226
- num ++ ;
227
-
228
- return num ;
229
- }
230
-
231
- static inline int of_get_available_child_count (const struct device_node * np )
232
- {
233
- struct device_node * child ;
234
- int num = 0 ;
235
-
236
- for_each_available_child_of_node (np , child )
237
- num ++ ;
238
-
239
- return num ;
240
- }
241
192
242
193
/* cache lookup */
243
194
extern struct device_node * of_find_next_cache_node (const struct device_node * );
244
195
extern struct device_node * of_find_node_with_property (
245
196
struct device_node * from , const char * prop_name );
246
- #define for_each_node_with_property (dn , prop_name ) \
247
- for (dn = of_find_node_with_property(NULL, prop_name); dn; \
248
- dn = of_find_node_with_property(dn, prop_name))
249
197
250
198
extern struct property * of_find_property (const struct device_node * np ,
251
199
const char * name ,
@@ -367,42 +315,53 @@ static inline struct device_node *of_find_node_by_name(struct device_node *from,
367
315
return NULL ;
368
316
}
369
317
370
- static inline struct device_node * of_get_parent (const struct device_node * node )
318
+ static inline struct device_node * of_find_node_by_type (struct device_node * from ,
319
+ const char * type )
371
320
{
372
321
return NULL ;
373
322
}
374
323
375
- static inline bool of_have_populated_dt (void )
324
+ static inline struct device_node * of_find_matching_node_and_match (
325
+ struct device_node * from ,
326
+ const struct of_device_id * matches ,
327
+ const struct of_device_id * * match )
376
328
{
377
- return false ;
329
+ return NULL ;
378
330
}
379
331
380
- /* Kill an unused variable warning on a device_node pointer */
381
- static inline void __of_use_dn (const struct device_node * np )
332
+ static inline struct device_node * of_get_parent (const struct device_node * node )
382
333
{
334
+ return NULL ;
383
335
}
384
336
385
- #define for_each_child_of_node (parent , child ) \
386
- while (__of_use_dn(parent), __of_use_dn(child), 0)
337
+ static inline struct device_node * of_get_next_child (
338
+ const struct device_node * node , struct device_node * prev )
339
+ {
340
+ return NULL ;
341
+ }
387
342
388
- #define for_each_available_child_of_node (parent , child ) \
389
- while (0)
343
+ static inline struct device_node * of_get_next_available_child (
344
+ const struct device_node * node , struct device_node * prev )
345
+ {
346
+ return NULL ;
347
+ }
390
348
391
- static inline struct device_node * of_get_child_by_name (
392
- const struct device_node * node ,
393
- const char * name )
349
+ static inline struct device_node * of_find_node_with_property (
350
+ struct device_node * from , const char * prop_name )
394
351
{
395
352
return NULL ;
396
353
}
397
354
398
- static inline int of_get_child_count ( const struct device_node * np )
355
+ static inline bool of_have_populated_dt ( void )
399
356
{
400
- return 0 ;
357
+ return false ;
401
358
}
402
359
403
- static inline int of_get_available_child_count (const struct device_node * np )
360
+ static inline struct device_node * of_get_child_by_name (
361
+ const struct device_node * node ,
362
+ const char * name )
404
363
{
405
- return 0 ;
364
+ return NULL ;
406
365
}
407
366
408
367
static inline int of_device_is_compatible (const struct device_node * device ,
@@ -569,6 +528,13 @@ extern int of_node_to_nid(struct device_node *np);
569
528
static inline int of_node_to_nid (struct device_node * device ) { return 0 ; }
570
529
#endif
571
530
531
+ static inline struct device_node * of_find_matching_node (
532
+ struct device_node * from ,
533
+ const struct of_device_id * matches )
534
+ {
535
+ return of_find_matching_node_and_match (from , matches , NULL );
536
+ }
537
+
572
538
/**
573
539
* of_property_read_bool - Findfrom a property
574
540
* @np: device node from which the property value is to be read.
@@ -618,6 +584,55 @@ static inline int of_property_read_u32(const struct device_node *np,
618
584
s; \
619
585
s = of_prop_next_string(prop, s))
620
586
587
+ #define for_each_node_by_name (dn , name ) \
588
+ for (dn = of_find_node_by_name(NULL, name); dn; \
589
+ dn = of_find_node_by_name(dn, name))
590
+ #define for_each_node_by_type (dn , type ) \
591
+ for (dn = of_find_node_by_type(NULL, type); dn; \
592
+ dn = of_find_node_by_type(dn, type))
593
+ #define for_each_compatible_node (dn , type , compatible ) \
594
+ for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
595
+ dn = of_find_compatible_node(dn, type, compatible))
596
+ #define for_each_matching_node (dn , matches ) \
597
+ for (dn = of_find_matching_node(NULL, matches); dn; \
598
+ dn = of_find_matching_node(dn, matches))
599
+ #define for_each_matching_node_and_match (dn , matches , match ) \
600
+ for (dn = of_find_matching_node_and_match(NULL, matches, match); \
601
+ dn; dn = of_find_matching_node_and_match(dn, matches, match))
602
+
603
+ #define for_each_child_of_node (parent , child ) \
604
+ for (child = of_get_next_child(parent, NULL); child != NULL; \
605
+ child = of_get_next_child(parent, child))
606
+ #define for_each_available_child_of_node (parent , child ) \
607
+ for (child = of_get_next_available_child(parent, NULL); child != NULL; \
608
+ child = of_get_next_available_child(parent, child))
609
+
610
+ #define for_each_node_with_property (dn , prop_name ) \
611
+ for (dn = of_find_node_with_property(NULL, prop_name); dn; \
612
+ dn = of_find_node_with_property(dn, prop_name))
613
+
614
+ static inline int of_get_child_count (const struct device_node * np )
615
+ {
616
+ struct device_node * child ;
617
+ int num = 0 ;
618
+
619
+ for_each_child_of_node (np , child )
620
+ num ++ ;
621
+
622
+ return num ;
623
+ }
624
+
625
+ static inline int of_get_available_child_count (const struct device_node * np )
626
+ {
627
+ struct device_node * child ;
628
+ int num = 0 ;
629
+
630
+ for_each_available_child_of_node (np , child )
631
+ num ++ ;
632
+
633
+ return num ;
634
+ }
635
+
621
636
#if defined(CONFIG_PROC_FS ) && defined(CONFIG_PROC_DEVICETREE )
622
637
extern void proc_device_tree_add_node (struct device_node * , struct proc_dir_entry * );
623
638
extern void proc_device_tree_add_prop (struct proc_dir_entry * pde , struct property * prop );
0 commit comments