Patchwork [U-Boot,1/2] pci: Add find_hose_by_cfg_addr() helper function

login
register
mail settings
Submitter Kumar Gala
Date Dec. 17, 2010, 11:30 p.m.
Message ID <1292628646-9352-1-git-send-email-galak@kernel.crashing.org>
Download mbox | patch
Permalink /patch/76013/
State Superseded
Delegated to: Kumar Gala
Headers show

Comments

Kumar Gala - Dec. 17, 2010, 11:30 p.m.
Being able to get back a pci_controller struct back by searching for it
means we can do things like dynamically allocate them or not have to
expose the static structures to all users.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 drivers/pci/pci.c |   11 +++++++++++
 include/pci.h     |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)
Kumar Gala - Dec. 30, 2010, 4:24 p.m.
On Dec 17, 2010, at 5:30 PM, Kumar Gala wrote:

> Being able to get back a pci_controller struct back by searching for it
> means we can do things like dynamically allocate them or not have to
> expose the static structures to all users.
> 
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> drivers/pci/pci.c |   11 +++++++++++
> include/pci.h     |    1 +
> 2 files changed, 12 insertions(+), 0 deletions(-)

Any comments or concerns on this?  Some of my 8xxx PCI cleanup depends on the two patches.

- k

> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 702ac67..74ef4ec 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -165,6 +165,17 @@ struct pci_controller *pci_bus_to_hose (int bus)
> 	return NULL;
> }
> 
> +struct pci_controller *find_hose_by_cfg_addr(void *cfg_addr)
> +{
> +	struct pci_controller *hose;
> +
> +	for (hose = hose_head; hose; hose = hose->next)
> +		if (hose->cfg_addr == cfg_addr)
> +			return hose;
> +
> +	return NULL;
> +}
> +
> int pci_last_busno(void)
> {
> 	struct pci_controller *hose = hose_head;
> diff --git a/include/pci.h b/include/pci.h
> index c456006..e80b6bd 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -511,6 +511,7 @@ extern int pci_hose_write_config_word_via_dword(struct pci_controller *hose,
> extern void *pci_map_bar(pci_dev_t pdev, int bar, int flags);
> extern void pci_register_hose(struct pci_controller* hose);
> extern struct pci_controller* pci_bus_to_hose(int bus);
> +extern struct pci_controller *find_hose_by_cfg_addr(void *cfg_addr);
> 
> extern int pci_hose_scan(struct pci_controller *hose);
> extern int pci_hose_scan_bus(struct pci_controller *hose, int bus);
> -- 
> 1.7.2.3
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 702ac67..74ef4ec 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -165,6 +165,17 @@  struct pci_controller *pci_bus_to_hose (int bus)
 	return NULL;
 }
 
+struct pci_controller *find_hose_by_cfg_addr(void *cfg_addr)
+{
+	struct pci_controller *hose;
+
+	for (hose = hose_head; hose; hose = hose->next)
+		if (hose->cfg_addr == cfg_addr)
+			return hose;
+
+	return NULL;
+}
+
 int pci_last_busno(void)
 {
 	struct pci_controller *hose = hose_head;
diff --git a/include/pci.h b/include/pci.h
index c456006..e80b6bd 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -511,6 +511,7 @@  extern int pci_hose_write_config_word_via_dword(struct pci_controller *hose,
 extern void *pci_map_bar(pci_dev_t pdev, int bar, int flags);
 extern void pci_register_hose(struct pci_controller* hose);
 extern struct pci_controller* pci_bus_to_hose(int bus);
+extern struct pci_controller *find_hose_by_cfg_addr(void *cfg_addr);
 
 extern int pci_hose_scan(struct pci_controller *hose);
 extern int pci_hose_scan_bus(struct pci_controller *hose, int bus);