pci_dn.c (2e483528cebad089d0bb3f9aebb0ada22d968ffa) | pci_dn.c (98d9f30c820d509145757e6ecbc36013aa02f7bc) |
---|---|
1/* 2 * pci_dn.c 3 * 4 * Copyright (C) 2001 Todd Inglett, IBM Corporation 5 * 6 * PCI manipulation via device_nodes. 7 * 8 * This program is free software; you can redistribute it and/or modify --- 128 unchanged lines hidden (view full) --- 137 pdn->devfn = pdn->busno = -1; 138 pdn->phb = phb; 139 } 140 141 /* Update dn->phb ptrs for new phb and children devices */ 142 traverse_pci_devices(dn, update_dn_pci_info, phb); 143} 144 | 1/* 2 * pci_dn.c 3 * 4 * Copyright (C) 2001 Todd Inglett, IBM Corporation 5 * 6 * PCI manipulation via device_nodes. 7 * 8 * This program is free software; you can redistribute it and/or modify --- 128 unchanged lines hidden (view full) --- 137 pdn->devfn = pdn->busno = -1; 138 pdn->phb = phb; 139 } 140 141 /* Update dn->phb ptrs for new phb and children devices */ 142 traverse_pci_devices(dn, update_dn_pci_info, phb); 143} 144 |
145/* 146 * Traversal func that looks for a <busno,devfcn> value. 147 * If found, the pci_dn is returned (thus terminating the traversal). 148 */ 149static void *is_devfn_node(struct device_node *dn, void *data) 150{ 151 int busno = ((unsigned long)data >> 8) & 0xff; 152 int devfn = ((unsigned long)data) & 0xff; 153 struct pci_dn *pci = dn->data; 154 155 if (pci && (devfn == pci->devfn) && (busno == pci->busno)) 156 return dn; 157 return NULL; 158} 159 160/* 161 * This is the "slow" path for looking up a device_node from a 162 * pci_dev. It will hunt for the device under its parent's 163 * phb and then update of_node pointer. 164 * 165 * It may also do fixups on the actual device since this happens 166 * on the first read/write. 167 * 168 * Note that it also must deal with devices that don't exist. 169 * In this case it may probe for real hardware ("just in case") 170 * and add a device_node to the device tree if necessary. 171 * 172 * Is this function necessary anymore now that dev->dev.of_node is 173 * used to store the node pointer? 174 * 175 */ 176struct device_node *fetch_dev_dn(struct pci_dev *dev) 177{ 178 struct pci_controller *phb = dev->sysdata; 179 struct device_node *dn; 180 unsigned long searchval = (dev->bus->number << 8) | dev->devfn; 181 182 if (WARN_ON(!phb)) 183 return NULL; 184 185 dn = traverse_pci_devices(phb->dn, is_devfn_node, (void *)searchval); 186 if (dn) 187 dev->dev.of_node = dn; 188 return dn; 189} 190EXPORT_SYMBOL(fetch_dev_dn); 191 | |
192/** 193 * pci_devs_phb_init - Initialize phbs and pci devs under them. 194 * 195 * This routine walks over all phb's (pci-host bridges) on the 196 * system, and sets up assorted pci-related structures 197 * (including pci info in the device node structs) for each 198 * pci device found underneath. This routine runs once, 199 * early in the boot sequence. 200 */ 201void __init pci_devs_phb_init(void) 202{ 203 struct pci_controller *phb, *tmp; 204 205 /* This must be done first so the device nodes have valid pci info! */ 206 list_for_each_entry_safe(phb, tmp, &hose_list, list_node) 207 pci_devs_phb_init_dynamic(phb); 208} | 145/** 146 * pci_devs_phb_init - Initialize phbs and pci devs under them. 147 * 148 * This routine walks over all phb's (pci-host bridges) on the 149 * system, and sets up assorted pci-related structures 150 * (including pci info in the device node structs) for each 151 * pci device found underneath. This routine runs once, 152 * early in the boot sequence. 153 */ 154void __init pci_devs_phb_init(void) 155{ 156 struct pci_controller *phb, *tmp; 157 158 /* This must be done first so the device nodes have valid pci info! */ 159 list_for_each_entry_safe(phb, tmp, &hose_list, list_node) 160 pci_devs_phb_init_dynamic(phb); 161} |