summaryrefslogtreecommitdiff
path: root/util/sconfig/sconfig.y
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2021-02-28 16:18:18 +0100
committerFelix Held <felix-coreboot@felixheld.de>2021-09-08 19:03:20 +0000
commit859ecdf51771185d4b7d983e4152acf7099c1728 (patch)
treea3d336fbe732e1a8e9f1a4b2b9db63ae1a08d603 /util/sconfig/sconfig.y
parente708468df93e065fba772ce567e3f14af023a2a6 (diff)
sconfig: Ensure at least one `device` node below each `chip`
Even though `device` entries are children of `chip` entries in the devicetree source format, the chips in the translated C structures are only hooked up to device nodes. Hence, any chip with all its settings will be silently dropped by sconfig if there is no device node below it. Let's adapt the parser to ensure that there is at least one `device` entry. The intermediate `chipchildren_dev` rule applies until the first `device` entry is found, then everything continues as before with the `chipchildren` rule. Change-Id: I54830bc1fc7d00a0605f3fe4d36a83ef57ef3312 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/51119 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/sconfig/sconfig.y')
-rwxr-xr-xutil/sconfig/sconfig.y8
1 files changed, 6 insertions, 2 deletions
diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y
index 40c1295595..da6d97b1a6 100755
--- a/util/sconfig/sconfig.y
+++ b/util/sconfig/sconfig.y
@@ -25,7 +25,11 @@ static struct fw_config_field_bits *cur_bits;
%%
devtree: { cur_parent = root_parent; } | devtree chip | devtree fw_config_table;
-chipchildren: chipchildren device | chipchildren chip | chipchildren registers | chipchildren reference | /* empty */ ;
+/* Ensure at least one `device` below each `chip`. */
+chipchild_nondev: chip | registers | reference;
+chipchild: device | chipchild_nondev;
+chipchildren: chipchildren chipchild | /* empty */ ;
+chipchildren_dev: device chipchildren | chipchild_nondev chipchildren_dev;
devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | devicechildren smbios_slot_desc | devicechildren registers | devicechildren fw_config_probe | /* empty */ ;
@@ -34,7 +38,7 @@ chip: CHIP STRING /* == path */ {
chip_enqueue_tail(cur_chip_instance);
cur_chip_instance = $<chip_instance>$;
}
- chipchildren END {
+ chipchildren_dev END {
cur_chip_instance = chip_dequeue_tail();
};