mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-20 11:55:03 +00:00
fdtgrep: Move property checking into a function
The h_include() function includes a piece which checks if a node contains a property being searched for. Move this into its own function to reduce the size of the h_include() function. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
490afe7428
commit
61a695e451
1 changed files with 35 additions and 13 deletions
|
@ -575,6 +575,40 @@ static int check_type_include(void *priv, int type, const char *data, int size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check_props() - Check if a node has properties that we want to include
|
||||||
|
*
|
||||||
|
* Calls check_type_include() for each property in the nodn, returning 1 if
|
||||||
|
* that function returns 1 for any of them
|
||||||
|
*
|
||||||
|
* @disp: Display structure, holding info about our options
|
||||||
|
* @fdt: Devicetree blob to check
|
||||||
|
* @node: Node offset to check
|
||||||
|
* @inc: Current value of the 'include' variable (see h_include())
|
||||||
|
* Return: 0 to exclude, 1 to include, -1 if no information is available
|
||||||
|
*/
|
||||||
|
static int check_props(struct display_info *disp, const void *fdt, int node,
|
||||||
|
int inc)
|
||||||
|
{
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
for (offset = fdt_first_property_offset(fdt, node);
|
||||||
|
offset > 0 && inc != 1;
|
||||||
|
offset = fdt_next_property_offset(fdt, offset)) {
|
||||||
|
const struct fdt_property *prop;
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
prop = fdt_get_property_by_offset(fdt, offset, NULL);
|
||||||
|
if (!prop)
|
||||||
|
continue;
|
||||||
|
str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
|
||||||
|
inc = check_type_include(disp, FDT_NODE_HAS_PROP, str,
|
||||||
|
strlen(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
return inc;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* h_include() - Include handler function for fdt_first_region()
|
* h_include() - Include handler function for fdt_first_region()
|
||||||
*
|
*
|
||||||
|
@ -617,19 +651,7 @@ static int h_include(void *priv, const void *fdt, int offset, int type,
|
||||||
(disp->types_inc & FDT_NODE_HAS_PROP)) {
|
(disp->types_inc & FDT_NODE_HAS_PROP)) {
|
||||||
debug(" - checking node '%s'\n",
|
debug(" - checking node '%s'\n",
|
||||||
fdt_get_name(fdt, offset, NULL));
|
fdt_get_name(fdt, offset, NULL));
|
||||||
for (offset = fdt_first_property_offset(fdt, offset);
|
inc = check_props(disp, fdt, offset, inc);
|
||||||
offset > 0 && inc != 1;
|
|
||||||
offset = fdt_next_property_offset(fdt, offset)) {
|
|
||||||
const struct fdt_property *prop;
|
|
||||||
const char *str;
|
|
||||||
|
|
||||||
prop = fdt_get_property_by_offset(fdt, offset, NULL);
|
|
||||||
if (!prop)
|
|
||||||
continue;
|
|
||||||
str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
|
|
||||||
inc = check_type_include(priv, FDT_NODE_HAS_PROP, str,
|
|
||||||
strlen(str));
|
|
||||||
}
|
|
||||||
if (inc == -1)
|
if (inc == -1)
|
||||||
inc = 0;
|
inc = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue