Re: [PATCH] PCI fixes for 2.6.10-rc2

From: Greg KH
Date: Fri Nov 19 2004 - 17:21:39 EST


ChangeSet 1.2165, 2004/11/19 10:02:07-08:00, eike-hotplug@xxxxxxxxx

[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: Rolf Eike Beer <eike-hotplug@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <greg@xxxxxxxxx>


drivers/pci/hotplug/rpaphp_pci.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)


diff -Nru a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
--- a/drivers/pci/hotplug/rpaphp_pci.c 2004-11-19 13:20:10 -08:00
+++ b/drivers/pci/hotplug/rpaphp_pci.c 2004-11-19 13:20:10 -08:00
@@ -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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/