From: Jiang Liu <liuj97@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>, Yinghai Lu <yinghai@kernel.org>
Cc: Jiang Liu <jiang.liu@huawei.com>,
"Rafael J . Wysocki" <rjw@sisk.pl>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Gu Zheng <guz.fnst@cn.fujitsu.com>,
Toshi Kani <toshi.kani@hp.com>,
Myron Stowe <myron.stowe@redhat.com>,
Yijing Wang <wangyijing@huawei.com>, Jiang Liu <liuj97@gmail.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiri Kosina <jkosina@suse.cz>,
Masanari Iida <standby24x7@gmail.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Subject: [RFC PATCH v2, part 2 03/18] PCI, hotplug: use hotplug-safe iterators to walk PCI buses
Date: Wed, 15 May 2013 00:51:47 +0800 [thread overview]
Message-ID: <1368550322-1045-3-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1368550322-1045-1-git-send-email-jiang.liu@huawei.com>
Enhance PCI hotplug drivers to use hotplug-safe iterators to walk
PCI buses.
In other words, replace pci_find_bus(), pci_find_next_bus() and
pci_root_buses with pci_bus_exists(), pci_get_bus(), pci_get_next_bus()
and pci_get_next_root_bus() etc.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Masanari Iida <standby24x7@gmail.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/pci/hotplug-pci.c | 2 +-
drivers/pci/hotplug/ibmphp_core.c | 8 +++++---
drivers/pci/hotplug/ibmphp_ebda.c | 8 ++++++--
drivers/pci/hotplug/sgi_hotplug.c | 3 ++-
drivers/pci/hotplug/shpchp_sysfs.c | 2 +-
5 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/hotplug-pci.c b/drivers/pci/hotplug-pci.c
index 6258dc2..18533ed 100644
--- a/drivers/pci/hotplug-pci.c
+++ b/drivers/pci/hotplug-pci.c
@@ -11,7 +11,7 @@ int __ref pci_hp_add_bridge(struct pci_dev *dev)
int end = parent->busn_res.end;
for (busnr = start; busnr <= end; busnr++) {
- if (!pci_find_bus(pci_domain_nr(parent), busnr))
+ if (!pci_bus_exists(pci_domain_nr(parent), busnr))
break;
}
if (busnr-- > end) {
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index cbd72d8..fb47695 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -739,7 +739,7 @@ static u8 bus_structure_fixup(u8 busno)
struct pci_dev *dev;
u16 l;
- if (pci_find_bus(0, busno) || !(ibmphp_find_same_bus_num(busno)))
+ if (pci_bus_exists(0, busno) || !(ibmphp_find_same_bus_num(busno)))
return 1;
bus = kmalloc(sizeof(*bus), GFP_KERNEL);
@@ -787,7 +787,7 @@ static int ibm_configure_device(struct pci_func *func)
PCI_DEVFN(func->device, func->function));
if (func->dev == NULL) {
- struct pci_bus *bus = pci_find_bus(0, func->busno);
+ struct pci_bus *bus = pci_get_bus(0, func->busno);
if (!bus)
return 0;
@@ -795,6 +795,7 @@ static int ibm_configure_device(struct pci_func *func)
PCI_DEVFN(func->device, func->function));
if (num)
pci_bus_add_devices(bus);
+ pci_bus_put(bus);
func->dev = pci_get_bus_and_slot(func->busno,
PCI_DEVFN(func->device, func->function));
@@ -1315,13 +1316,14 @@ static int __init ibmphp_init(void)
goto exit;
}
- bus = pci_find_bus(0, 0);
+ bus = pci_get_bus(0, 0);
if (!bus) {
err("Can't find the root pci bus, can not continue\n");
rc = -ENODEV;
goto error;
}
memcpy(ibmphp_pci_bus, bus, sizeof(*ibmphp_pci_bus));
+ pci_bus_put(bus);
ibmphp_debug = debug;
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 9df78bc..e17f271 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -978,9 +978,13 @@ static int __init ebda_rsrc_controller (void)
} /* each hpc */
list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
+ struct pci_bus *bus = pci_get_bus(0, tmp_slot->bus);
+
+ BUG_ON(!bus);
snprintf(name, SLOT_NAME_SIZE, "%s", create_file_name(tmp_slot));
- pci_hp_register(tmp_slot->hotplug_slot,
- pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name);
+ pci_hp_register(tmp_slot->hotplug_slot, bus, tmp_slot->device,
+ name);
+ pci_bus_put(bus);
}
print_ebda_hpc ();
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index b2781df..5c69bda 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -684,7 +684,7 @@ static int __init sn_pci_hotplug_init(void)
INIT_LIST_HEAD(&sn_hp_list);
- while ((pci_bus = pci_find_next_bus(pci_bus))) {
+ for_each_pci_root_bus(pci_bus) {
if (!pci_bus->sysdata)
continue;
@@ -703,6 +703,7 @@ static int __init sn_pci_hotplug_init(void)
break;
}
}
+ pci_bus_put(pci_bus);
return registered == 1 ? 0 : -ENODEV;
}
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index e8c31fe..e7a5dd2 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -74,7 +74,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
}
out += sprintf(out, "Free resources: bus numbers\n");
for (busnr = bus->busn_res.start; busnr <= bus->busn_res.end; busnr++) {
- if (!pci_find_bus(pci_domain_nr(bus), busnr))
+ if (!pci_bus_exists(pci_domain_nr(bus), busnr))
break;
}
if (busnr < bus->busn_res.end)
--
1.8.1.2
next prev parent reply other threads:[~2013-05-14 16:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 16:51 [RFC PATCH v2, part 2 01/18] PCI: introduce hotplug-safe PCI bus iterators Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 02/18] PCI, core: use hotplug-safe iterators to walk PCI buses Jiang Liu
2013-05-14 18:55 ` Yinghai Lu
2013-05-14 16:51 ` Jiang Liu [this message]
2013-05-14 18:57 ` [RFC PATCH v2, part 2 03/18] PCI, hotplug: " Yinghai Lu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 04/18] PCI, Alpha: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 05/18] PCI, FRV: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 06/18] PCI, IA64: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 07/18] PCI, Microblaze: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 08/18] PCI, mn10300: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 09/18] PCI, PPC: " Jiang Liu
2013-05-14 23:30 ` Benjamin Herrenschmidt
2013-05-15 15:07 ` Liu Jiang
2013-05-15 15:17 ` Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 10/18] PCI, SPARC: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 11/18] PCI, x86: " Jiang Liu
2013-05-14 18:59 ` Yinghai Lu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 12/18] PCI, ACPI: " Jiang Liu
2013-05-14 20:28 ` Rafael J. Wysocki
2013-05-14 16:51 ` [RFC PATCH v2, part 2 13/18] PCI, DRM: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 14/18] PCI, EDAC: use hotplug-safe PCI bus " Jiang Liu
2013-05-22 4:12 ` Gu Zheng
2013-05-25 15:18 ` Liu Jiang
2013-05-14 16:51 ` [RFC PATCH v2, part 2 15/18] PCI, via-camera: use hotplug-safe " Jiang Liu
2013-05-14 16:52 ` [RFC PATCH v2, part 2 16/18] PCI, iommu: " Jiang Liu
2013-05-14 22:13 ` Don Dutile
2013-05-15 15:36 ` Liu Jiang
2013-05-14 16:52 ` [RFC PATCH v2, part 2 17/18] PCI, eeepc-laptop: " Jiang Liu
2013-05-14 16:52 ` [RFC PATCH v2, part 2 18/18] PCI, asus-wmi: " Jiang Liu
2013-05-14 17:05 ` [RFC PATCH v2, part 2 01/18] PCI: introduce hotplug-safe PCI bus iterators Greg Kroah-Hartman
2013-05-15 14:42 ` Liu Jiang
2013-05-15 14:51 ` Liu Jiang
2013-05-14 18:56 ` Yinghai Lu
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=1368550322-1045-3-git-send-email-jiang.liu@huawei.com \
--to=liuj97@gmail.com \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=guz.fnst@cn.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=myron.stowe@redhat.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rjw@sisk.pl \
--cc=standby24x7@gmail.com \
--cc=toshi.kani@hp.com \
--cc=wangyijing@huawei.com \
--cc=yinghai@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;
as well as URLs for NNTP newsgroup(s).