mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 01/12] PCI: add helpers for building PCI bus resource lists
Date: Mon, 10 Oct 2011 21:18:30 -0600	[thread overview]
Message-ID: <20111011031829.5149.43868.stgit@bhelgaas.mtv.corp.google.com> (raw)
In-Reply-To: <20111011030726.5149.23793.stgit@bhelgaas.mtv.corp.google.com>

We'd like to supply a list of resources when we create a new PCI bus,
e.g., the root bus under a PCI host bridge.  These are helpers for
constructing that list.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/bus.c   |   30 +++++++++++++++++++++++++-----
 include/linux/pci.h |    2 ++
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 1e2ad92..79fc31a 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -18,6 +18,30 @@
 
 #include "pci.h"
 
+void pci_add_resource(struct list_head *resources, struct resource *res)
+{
+	struct pci_bus_resource *bus_res;
+
+	bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
+	if (!bus_res) {
+		printk(KERN_ERR "PCI: can't add bus resource %pR\n", res);
+		return;
+	}
+
+	bus_res->res = res;
+	list_add_tail(&bus_res->list, resources);
+}
+
+void pci_free_resource_list(struct list_head *resources)
+{
+	struct pci_bus_resource *bus_res, *tmp;
+
+	list_for_each_entry_safe(bus_res, tmp, resources, list) {
+		list_del(&bus_res->list);
+		kfree(bus_res);
+	}
+}
+
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
 			  unsigned int flags)
 {
@@ -52,16 +76,12 @@ EXPORT_SYMBOL_GPL(pci_bus_resource_n);
 
 void pci_bus_remove_resources(struct pci_bus *bus)
 {
-	struct pci_bus_resource *bus_res, *tmp;
 	int i;
 
 	for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
 		bus->resource[i] = NULL;
 
-	list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
-		list_del(&bus_res->list);
-		kfree(bus_res);
-	}
+	pci_free_resource_list(&bus->resources);
 }
 
 /**
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9fc0122..6841e7f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -907,6 +907,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
 void pci_release_selected_regions(struct pci_dev *, int);
 
 /* drivers/pci/bus.c */
+void pci_add_resource(struct list_head *resources, struct resource *res);
+void pci_free_resource_list(struct list_head *resources);
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
 struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
 void pci_bus_remove_resources(struct pci_bus *bus);


  reply	other threads:[~2011-10-11  3:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11  3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
2011-10-11  3:18 ` Bjorn Helgaas [this message]
2011-10-11  3:18 ` [PATCH 02/12] PCI: pass available resources into pci_create_bus() Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 03/12] MIPS: PCI: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 04/12] x86/PCI: " Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 05/12] powerpc/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 06/12] powerpc/pci: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 07/12] powerpc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 08/12] microblaze/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 09/12] microblaze/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 10/12] sparc/pci: " Bjorn Helgaas
2011-10-11  3:33   ` David Miller
2011-10-11  3:19 ` [PATCH 11/12] sparc/pci: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 12/12] sparc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:33   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111011031829.5149.43868.stgit@bhelgaas.mtv.corp.google.com \
    --to=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®