Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/31933 )
Change subject: util/sconfig: Expose usable PCI and PNP device names ......................................................................
util/sconfig: Expose usable PCI and PNP device names
These devices can be accessed directly by symbolname, without a search and walk through the tree, as they have static paths.
Change-Id: I711058f5c809fa9bc7ea4333aaebad6847ebdfd4 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/31933 Reviewed-by: Felix Held felix-coreboot@felixheld.de Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/sconfig/main.c 1 file changed, 16 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Held: Looks good to me, approved
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 5e3a1d4..6b421ec 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -883,6 +883,18 @@ emit_dev_links(fil, ptr); }
+static void expose_device_names(FILE *fil, struct device *ptr, struct device *next) +{ + /* Only devices on root bus here. */ + if (ptr->bustype == PCI && ptr->parent->dev->bustype == DOMAIN) + fprintf(fil, "DEVTREE_CONST struct device *DEVTREE_CONST __pci_0_%02x_%d = &%s;\n", + ptr->path_a, ptr->path_b, ptr->name); + + if (ptr->bustype == PNP) + fprintf(fil, "DEVTREE_CONST struct device *DEVTREE_CONST __pnp_%04x_%02x = &%s;\n", + ptr->path_a, ptr->path_b, ptr->name); +} + static void add_siblings_to_queue(struct queue_entry **bfs_q_head, struct device *d) { @@ -1385,6 +1397,10 @@ fprintf(autogen, "\n/* pass 1 */\n"); walk_device_tree(autogen, &base_root_dev, pass1);
+ /* Expose static devicenames to global namespace. */ + fprintf(autogen, "\n/* expose_device_names */\n"); + walk_device_tree(autogen, &base_root_dev, expose_device_names); + fclose(autogen);
return 0;