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@0 {
                bus@0 {
                        pci@0,0 {
                        };
                        pci@1,1 {
                        };
                        pci@f,0 {
                                bus@1 {
                                        pci@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@gmx.net>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>


git-svn-id: svn://coreboot.org/repository/coreboot-v3@860 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Carl-Daniel Hailfinger 2008-09-06 20:39:25 +00:00
commit c2084e9de3

View file

@ -1311,8 +1311,22 @@ void
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);