Commit bff604f2 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Greg Kroah-Hartman

[PATCH] PCI Hotplug: clean up rpaphp_pci.c::rpaphp_find_pci_dev

this patch improves rpaphp_find_pci_dev. First it uses the for_each_pci_dev
macro instead of the while loop, making this hotplug safe (which is a good
idea in a hotplug driver, isn't it?). Then it removes retval_dev. retval_dev
is set to the found device when something is found, NULL otherwise. If
nothing is found dev will be NULL at the end of the loop anyway and the
found device if we found something, no need for retval_dev then. And a very
small coding style fix.
Signed-off-by: default avatarRolf Eike Beer <eike-hotplug@sf-tec.de>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent f03063c1
......@@ -31,18 +31,17 @@
struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn)
{
struct pci_dev *retval_dev = NULL, *dev = NULL;
struct pci_dev *dev = NULL;
char bus_id[BUS_ID_SIZE];
sprintf(bus_id, "%04x:%02x:%02x.%d",dn->phb->global_number,
sprintf(bus_id, "%04x:%02x:%02x.%d", dn->phb->global_number,
dn->busno, PCI_SLOT(dn->devfn), PCI_FUNC(dn->devfn));
while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
for_each_pci_dev(dev) {
if (!strcmp(pci_name(dev), bus_id)) {
retval_dev = dev;
break;
}
}
return retval_dev;
return dev;
}
EXPORT_SYMBOL_GPL(rpaphp_find_pci_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment