[coreboot] r860 - coreboot-v3/util/dtc

svn at coreboot.org svn at coreboot.org
Sat Sep 6 22:39:25 CEST 2008


Author: hailfinger
Date: 2008-09-06 22:39:25 +0200 (Sat, 06 Sep 2008)
New Revision: 860

Modified:
   coreboot-v3/util/dtc/flattree.c
Log:
I managed to break dtc while working on PCI bridges:
dtc only uses dev_fn as identifier for a PCI device. That gets us a name
collision if we have the same dev_fn combination on multiple buses.
Either we add a random unique ID to the struct name or we integrate the
path to the parent device as well.
I decided to go for integration of parent device path.

With the following device tree

/{
        cpus {};
        domain at 0 {
                bus at 0 {
                        pci at 0,0 {
                        };
                        pci at 1,1 {
                        };
                        pci at f,0 {
                                bus at 1 {
                                        pci at 0,0 {
                                        };
                                };
                        };
                };
        };
};


we get the old names:
dev_root
dev_cpus
dev_domain_0
dev_bus_0
dev_pci_0_0
dev_pci_1_1
dev_pci_f_0
dev_bus_1
dev_pci_0_0 COLLISION!!!

and the new names:
dev_root
dev_cpus
dev_domain_0
dev_domain_0_bus_0
dev_domain_0_bus_0_pci_0_0
dev_domain_0_bus_0_pci_1_1
dev_domain_0_bus_0_pci_f_0
dev_domain_0_bus_0_pci_f_0_bus_1
dev_domain_0_bus_0_pci_f_0_bus_1_pci_0_0

Ron would like shorter names because they only have to be
machine-readable. That's left for another patch.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: Ronald G. Minnich <rminnich at gmail.com>


Modified: coreboot-v3/util/dtc/flattree.c
===================================================================
--- coreboot-v3/util/dtc/flattree.c	2008-09-06 20:30:26 UTC (rev 859)
+++ coreboot-v3/util/dtc/flattree.c	2008-09-06 20:39:25 UTC (rev 860)
@@ -1311,8 +1311,22 @@
 labeltree(struct node *tree)
 {
 	struct node *child;
+	char *tmp1;
+	char *tmp2;
 
 	tree->label = clean(tree->name, 1);
+	if (tree->parent && tree->label) {
+		tmp1 = strdup(tree->parent->label);
+		if (strlen(tmp1)) {
+			tmp2 = tree->label;
+			tree->label = malloc(strlen(tmp1) + strlen(tmp2) + 2);
+			strcpy(tree->label, tmp1);
+			strcat(tree->label, "_");
+			strcat(tree->label, tmp2);
+			free(tmp2);
+		}
+		free(tmp1);
+	}
 	
 	if (tree->next_sibling)
 		labeltree(tree->next_sibling);





More information about the coreboot mailing list