Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of: Add for_each_reserved_child_of_node()

We would like to use for_each loop for status = "reserved" nodes.
Add for_each_reserved_child_of_node() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/87a5pegfau.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

authored by

Kuninori Morimoto and committed by
Geert Uytterhoeven
28c5d4e4 8918283a

+40
+29
drivers/of/base.c
··· 466 466 } 467 467 468 468 /** 469 + * __of_device_is_reserved - check if a device is reserved 470 + * 471 + * @device: Node to check for availability, with locks already held 472 + * 473 + * Return: True if the status property is set to "reserved", false otherwise 474 + */ 475 + static bool __of_device_is_reserved(const struct device_node *device) 476 + { 477 + static const char * const reserved[] = {"reserved", NULL}; 478 + 479 + return __of_device_is_status(device, reserved); 480 + } 481 + 482 + /** 469 483 * of_device_is_available - check if a device is available for use 470 484 * 471 485 * @device: Node to check for availability ··· 663 649 return of_get_next_status_child(node, prev, __of_device_is_available); 664 650 } 665 651 EXPORT_SYMBOL(of_get_next_available_child); 652 + 653 + /** 654 + * of_get_next_reserved_child - Find the next reserved child node 655 + * @node: parent node 656 + * @prev: previous child of the parent node, or NULL to get first 657 + * 658 + * This function is like of_get_next_child(), except that it 659 + * automatically skips any disabled nodes (i.e. status = "disabled"). 660 + */ 661 + struct device_node *of_get_next_reserved_child(const struct device_node *node, 662 + struct device_node *prev) 663 + { 664 + return of_get_next_status_child(node, prev, __of_device_is_reserved); 665 + } 666 + EXPORT_SYMBOL(of_get_next_reserved_child); 666 667 667 668 /** 668 669 * of_get_next_cpu_node - Iterate on cpu nodes
+11
include/linux/of.h
··· 294 294 struct device_node *prev); 295 295 extern struct device_node *of_get_next_available_child( 296 296 const struct device_node *node, struct device_node *prev); 297 + extern struct device_node *of_get_next_reserved_child( 298 + const struct device_node *node, struct device_node *prev); 297 299 298 300 extern struct device_node *of_get_compatible_child(const struct device_node *parent, 299 301 const char *compatible); ··· 538 536 } 539 537 540 538 static inline struct device_node *of_get_next_available_child( 539 + const struct device_node *node, struct device_node *prev) 540 + { 541 + return NULL; 542 + } 543 + 544 + static inline struct device_node *of_get_next_reserved_child( 541 545 const struct device_node *node, struct device_node *prev) 542 546 { 543 547 return NULL; ··· 1439 1431 #define for_each_available_child_of_node(parent, child) \ 1440 1432 for (child = of_get_next_available_child(parent, NULL); child != NULL; \ 1441 1433 child = of_get_next_available_child(parent, child)) 1434 + #define for_each_reserved_child_of_node(parent, child) \ 1435 + for (child = of_get_next_reserved_child(parent, NULL); child != NULL; \ 1436 + child = of_get_next_reserved_child(parent, child)) 1442 1437 1443 1438 #define for_each_of_cpu_node(cpu) \ 1444 1439 for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \