Commit 0945cd5f authored by John Rose's avatar John Rose Committed by Greg Kroah-Hartman

[PATCH] PCI Hotplug: rpaphp: Remove rpaphp_find_pci

The rpaphp module currently uses a fragile method to find a pci device
by its device node.  This function is unnecessary, so this patch scraps
it.
Signed-off-by: default avatarJohn Rose <johnrose@austin.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9c209c91
...@@ -165,6 +165,20 @@ static int pci_add_secondary_bus(struct device_node *dn, ...@@ -165,6 +165,20 @@ static int pci_add_secondary_bus(struct device_node *dn,
return 0; return 0;
} }
static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
struct device_node *dev_dn)
{
struct pci_dev *tmp = NULL;
struct device_node *child_dn;
list_for_each_entry(tmp, &parent->devices, bus_list) {
child_dn = pci_device_to_OF_node(tmp);
if (child_dn == dev_dn)
return tmp;
}
return NULL;
}
static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
{ {
struct pci_controller *hose = dn->phb; struct pci_controller *hose = dn->phb;
...@@ -180,21 +194,18 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) ...@@ -180,21 +194,18 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
pci_bus_add_devices(hose->bus); pci_bus_add_devices(hose->bus);
/* Confirm new bridge dev was created */ /* Confirm new bridge dev was created */
dev = rpaphp_find_pci_dev(dn); dev = dlpar_find_new_dev(hose->bus, dn);
if (!dev) { if (dev) {
printk(KERN_ERR "%s: failed to add pci device\n", __FUNCTION__); if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
return NULL; printk(KERN_ERR "%s: unexpected header type %d\n",
} __FUNCTION__, dev->hdr_type);
return NULL;
}
if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { if (pci_add_secondary_bus(dn, dev))
printk(KERN_ERR "%s: unexpected header type %d\n", return NULL;
__FUNCTION__, dev->hdr_type);
return NULL;
} }
if (pci_add_secondary_bus(dn, dev))
return NULL;
return dev; return dev;
} }
......
...@@ -93,7 +93,6 @@ extern int num_slots; ...@@ -93,7 +93,6 @@ extern int num_slots;
/* function prototypes */ /* function prototypes */
/* rpaphp_pci.c */ /* rpaphp_pci.c */
extern struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn);
extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); extern int rpaphp_claim_resource(struct pci_dev *dev, int resource);
extern int rpaphp_enable_pci_slot(struct slot *slot); extern int rpaphp_enable_pci_slot(struct slot *slot);
extern int register_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot);
......
...@@ -30,22 +30,7 @@ ...@@ -30,22 +30,7 @@
#include "rpaphp.h" #include "rpaphp.h"
struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn) static struct pci_bus *find_bus_among_children(struct pci_bus *bus,
{
struct pci_dev *dev = NULL;
char bus_id[BUS_ID_SIZE];
sprintf(bus_id, "%04x:%02x:%02x.%d", dn->phb->global_number,
dn->busno, PCI_SLOT(dn->devfn), PCI_FUNC(dn->devfn));
for_each_pci_dev(dev) {
if (!strcmp(pci_name(dev), bus_id)) {
break;
}
}
return dev;
}
struct pci_bus *find_bus_among_children(struct pci_bus *bus,
struct device_node *dn) struct device_node *dn)
{ {
struct pci_bus *child = NULL; struct pci_bus *child = NULL;
...@@ -64,15 +49,14 @@ struct pci_bus *find_bus_among_children(struct pci_bus *bus, ...@@ -64,15 +49,14 @@ struct pci_bus *find_bus_among_children(struct pci_bus *bus,
return child; return child;
} }
struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) static struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn)
{ {
BUG_ON(!dn->phb || !dn->phb->bus); if (!dn->phb || !dn->phb->bus)
return NULL;
return find_bus_among_children(dn->phb->bus, dn); return find_bus_among_children(dn->phb->bus, dn);
} }
EXPORT_SYMBOL_GPL(rpaphp_find_pci_dev);
int rpaphp_claim_resource(struct pci_dev *dev, int resource) int rpaphp_claim_resource(struct pci_dev *dev, int resource)
{ {
struct resource *res = &dev->resource[resource]; struct resource *res = &dev->resource[resource];
...@@ -137,9 +121,8 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state) ...@@ -137,9 +121,8 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state)
*/ */
int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
{ {
struct pci_bus *bus;
int state, rc; int state, rc;
struct device_node *child_dn;
struct pci_dev *child_dev = NULL;
*value = NOT_VALID; *value = NOT_VALID;
rc = rpaphp_get_sensor_state(slot, &state); rc = rpaphp_get_sensor_state(slot, &state);
...@@ -156,20 +139,11 @@ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) ...@@ -156,20 +139,11 @@ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
/* config/unconfig adapter */ /* config/unconfig adapter */
*value = slot->state; *value = slot->state;
} else { } else {
child_dn = slot->dn->child; bus = rpaphp_find_pci_bus(slot->dn);
if (child_dn) if (bus && !list_empty(&bus->devices))
child_dev = rpaphp_find_pci_dev(child_dn); *value = CONFIGURED;
else
if (child_dev)
*value = CONFIGURED;
else if (!child_dn)
dbg("%s: %s is not valid OFDT node\n",
__FUNCTION__, slot->dn->full_name);
else {
err("%s: can't find pdev of adapter in slot[%s]\n",
__FUNCTION__, slot->dn->full_name);
*value = NOT_CONFIGURED; *value = NOT_CONFIGURED;
}
} }
} }
exit: exit:
...@@ -252,24 +226,26 @@ rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) ...@@ -252,24 +226,26 @@ rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus)
int num; int num;
dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name);
if (!dn->child)
return NULL;
if (dn->child) { slotno = PCI_SLOT(dn->child->devfn);
slotno = PCI_SLOT(dn->child->devfn);
/* pci_scan_slot should find all children */ /* pci_scan_slot should find all children */
num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
if (num) { if (num) {
rpaphp_fixup_new_pci_devices(bus, 1); rpaphp_fixup_new_pci_devices(bus, 1);
pci_bus_add_devices(bus); pci_bus_add_devices(bus);
} }
dev = rpaphp_find_pci_dev(dn->child); if (list_empty(&bus->devices)) {
if (!dev) { err("%s: No new device found\n", __FUNCTION__);
err("No new device found\n"); return NULL;
return NULL; }
} list_for_each_entry(dev, &bus->devices, bus_list) {
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
rpaphp_pci_config_bridge(dev); rpaphp_pci_config_bridge(dev);
} }
return dev; return 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