in macio_asic.c [450:514]
static void macio_pci_add_devices(struct macio_chip *chip)
{
struct device_node *np, *pnode;
struct macio_dev *rdev, *mdev, *mbdev = NULL, *sdev = NULL;
struct device *parent = NULL;
struct resource *root_res = &iomem_resource;
/* Add a node for the macio bus itself */
#ifdef CONFIG_PCI
if (chip->lbus.pdev) {
parent = &chip->lbus.pdev->dev;
root_res = &chip->lbus.pdev->resource[0];
}
#endif
pnode = of_node_get(chip->of_node);
if (pnode == NULL)
return;
/* Add macio itself to hierarchy */
rdev = macio_add_one_device(chip, parent, pnode, NULL, root_res);
if (rdev == NULL)
return;
root_res = &rdev->resource[0];
/* First scan 1st level */
for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
if (macio_skip_device(np))
continue;
of_node_get(np);
mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL,
root_res);
if (mdev == NULL)
of_node_put(np);
else if (of_node_name_prefix(np, "media-bay"))
mbdev = mdev;
else if (of_node_name_prefix(np, "escc"))
sdev = mdev;
}
/* Add media bay devices if any */
if (mbdev) {
pnode = mbdev->ofdev.dev.of_node;
for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
if (macio_skip_device(np))
continue;
of_node_get(np);
if (macio_add_one_device(chip, &mbdev->ofdev.dev, np,
mbdev, root_res) == NULL)
of_node_put(np);
}
}
/* Add serial ports if any */
if (sdev) {
pnode = sdev->ofdev.dev.of_node;
for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
if (macio_skip_device(np))
continue;
of_node_get(np);
if (macio_add_one_device(chip, &sdev->ofdev.dev, np,
NULL, root_res) == NULL)
of_node_put(np);
}
}
}