From: Anton Vorontsov Date: Thu, 19 Feb 2009 18:20:41 +0300 Subject: [U-Boot] [PATCH 2/7] PCI: Add pci_last_busno() helper In-Reply-To: <20090219151943.GA3310@oksana.dev.rtsoft.ru> References: <20090219151943.GA3310@oksana.dev.rtsoft.ru> Message-ID: <20090219152041.GB19823@oksana.dev.rtsoft.ru> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This is just a handy routine that reports last PCI busno: we walk down all the hoses and return last hose's last_busno. Will be used by PCI/PCIe initialization code. Signed-off-by: Anton Vorontsov --- drivers/pci/pci.c | 13 +++++++++++++ include/pci.h | 2 ++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index fffca49..d6d2d6e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -165,6 +165,19 @@ struct pci_controller *pci_bus_to_hose (int bus) return NULL; } +int pci_last_busno(void) +{ + struct pci_controller *hose = hose_head; + + if (!hose) + return -1; + + while (hose->next) + hose = hose->next; + + return hose->last_busno; +} + #ifndef CONFIG_IXP425 pci_dev_t pci_find_devices(struct pci_device_id *ids, int index) { diff --git a/include/pci.h b/include/pci.h index d0594e3..aaa4554 100644 --- a/include/pci.h +++ b/include/pci.h @@ -535,6 +535,8 @@ extern int pci_hose_config_device(struct pci_controller *hose, pci_addr_t mem, unsigned long command); +int pci_last_busno(void); + #ifdef CONFIG_MPC824X extern void pci_mpc824x_init (struct pci_controller *hose); #endif -- 1.5.6.5