diff options
author | Duncan Laurie <dlaurie@google.com> | 2020-06-09 11:24:10 -0700 |
---|---|---|
committer | Tim Wawrzynczak <twawrzynczak@chromium.org> | 2020-09-18 22:41:56 +0000 |
commit | cbd0bd8155107d109b6c4dd04b9233a04dadc892 (patch) | |
tree | 8bfbe605429a2b92a513c8eb13a3ceac11c50776 /util | |
parent | 7a066ecb4160c6691ae1268aab381faa143ca6e6 (diff) | |
download | coreboot-cbd0bd8155107d109b6c4dd04b9233a04dadc892.tar.xz |
sconfig: Add function for parse+override of tree
Extract the steps to parse and override a devicetree into a function
so it can be used multiple times without copying the same logic.
Change-Id: I4e496a223757beb22e3bd678eb6115968bd32529
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44036
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/sconfig/main.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index f561806a11..dbb266b346 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -1666,6 +1666,18 @@ static void override_devicetree(struct bus *base_parent, } } +static void parse_override_devicetree(const char *file, struct device *dev) +{ + parse_devicetree(file, dev->bus); + + if (!dev_has_children(dev)) { + fprintf(stderr, "ERROR: Override tree needs at least one device!\n"); + exit(1); + } + + override_devicetree(&base_root_bus, dev->bus); +} + int main(int argc, char **argv) { static const struct option long_options[] = { @@ -1708,16 +1720,8 @@ int main(int argc, char **argv) parse_devicetree(base_devtree, &base_root_bus); - if (override_devtree) { - parse_devicetree(override_devtree, &override_root_bus); - - if (!dev_has_children(&override_root_dev)) { - fprintf(stderr, "ERROR: Override tree needs at least one device!\n"); - exit(1); - } - - override_devicetree(&base_root_bus, &override_root_bus); - } + if (override_devtree) + parse_override_devicetree(override_devtree, &override_root_dev); FILE *autogen = fopen(outputc, "w"); if (!autogen) { |