mirror of
https://xff.cz/git/u-boot/
synced 2025-10-03 00:11:30 +02:00
dm: core: Add ofnode_for_each_subnode()
Add a convenience macro to iterate over subnodes of a node. Make use of this where appropriate in the code. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -224,9 +224,7 @@ tegra_xusb_padctl_config_parse_dt(struct tegra_xusb_padctl *padctl,
|
|||||||
|
|
||||||
config->name = ofnode_get_name(node);
|
config->name = ofnode_get_name(node);
|
||||||
|
|
||||||
for (subnode = ofnode_first_subnode(node);
|
ofnode_for_each_subnode(subnode, node) {
|
||||||
ofnode_valid(subnode);
|
|
||||||
subnode = ofnode_next_subnode(subnode)) {
|
|
||||||
struct tegra_xusb_padctl_group *group;
|
struct tegra_xusb_padctl_group *group;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -256,9 +254,7 @@ static int tegra_xusb_padctl_parse_dt(struct tegra_xusb_padctl *padctl,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (subnode = ofnode_first_subnode(node);
|
ofnode_for_each_subnode(subnode, node) {
|
||||||
ofnode_valid(subnode);
|
|
||||||
subnode = ofnode_next_subnode(subnode)) {
|
|
||||||
struct tegra_xusb_padctl_config *config = &padctl->config;
|
struct tegra_xusb_padctl_config *config = &padctl->config;
|
||||||
|
|
||||||
debug("%s: subnode=%s\n", __func__, ofnode_get_name(subnode));
|
debug("%s: subnode=%s\n", __func__, ofnode_get_name(subnode));
|
||||||
|
@@ -390,10 +390,11 @@ int ofnode_decode_display_timing(ofnode parent, int index,
|
|||||||
if (!ofnode_valid(timings))
|
if (!ofnode_valid(timings))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
for (i = 0, node = ofnode_first_subnode(timings);
|
i = 0;
|
||||||
ofnode_valid(node) && i != index;
|
ofnode_for_each_subnode(node, timings) {
|
||||||
node = ofnode_first_subnode(node))
|
if (i++ == index)
|
||||||
i++;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ofnode_valid(node))
|
if (!ofnode_valid(node))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@@ -1038,8 +1038,7 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config)
|
|||||||
|
|
||||||
config->flash_erase_value = ofnode_read_s32_default(flash_node,
|
config->flash_erase_value = ofnode_read_s32_default(flash_node,
|
||||||
"erase-value", -1);
|
"erase-value", -1);
|
||||||
for (node = ofnode_first_subnode(flash_node); ofnode_valid(node);
|
ofnode_for_each_subnode(node, flash_node) {
|
||||||
node = ofnode_next_subnode(node)) {
|
|
||||||
const char *name = ofnode_get_name(node);
|
const char *name = ofnode_get_name(node);
|
||||||
enum ec_flash_region region;
|
enum ec_flash_region region;
|
||||||
|
|
||||||
|
@@ -34,9 +34,7 @@ int pmic_bind_children(struct udevice *pmic, ofnode parent,
|
|||||||
debug("%s for '%s' at node offset: %d\n", __func__, pmic->name,
|
debug("%s for '%s' at node offset: %d\n", __func__, pmic->name,
|
||||||
dev_of_offset(pmic));
|
dev_of_offset(pmic));
|
||||||
|
|
||||||
for (node = ofnode_first_subnode(parent);
|
ofnode_for_each_subnode(node, parent) {
|
||||||
ofnode_valid(node);
|
|
||||||
node = ofnode_next_subnode(node)) {
|
|
||||||
node_name = ofnode_get_name(node);
|
node_name = ofnode_get_name(node);
|
||||||
|
|
||||||
debug("* Found child node: '%s'\n", node_name);
|
debug("* Found child node: '%s'\n", node_name);
|
||||||
|
@@ -628,4 +628,28 @@ int ofnode_read_resource(ofnode node, uint index, struct resource *res);
|
|||||||
int ofnode_read_resource_byname(ofnode node, const char *name,
|
int ofnode_read_resource_byname(ofnode node, const char *name,
|
||||||
struct resource *res);
|
struct resource *res);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ofnode_for_each_subnode() - iterate over all subnodes of a parent
|
||||||
|
*
|
||||||
|
* @node: child node (ofnode, lvalue)
|
||||||
|
* @parent: parent node (ofnode)
|
||||||
|
*
|
||||||
|
* This is a wrapper around a for loop and is used like so:
|
||||||
|
*
|
||||||
|
* ofnode node;
|
||||||
|
*
|
||||||
|
* ofnode_for_each_subnode(node, parent) {
|
||||||
|
* Use node
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Note that this is implemented as a macro and @node is used as
|
||||||
|
* iterator in the loop. The parent variable can be a constant or even a
|
||||||
|
* literal.
|
||||||
|
*/
|
||||||
|
#define ofnode_for_each_subnode(node, parent) \
|
||||||
|
for (node = ofnode_first_subnode(parent); \
|
||||||
|
ofnode_valid(node); \
|
||||||
|
node = ofnode_next_subnode(node))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user