Commit 8737d6a90cd8b085c2ea9cb4c7443c87f86c3429
Committed by
Greg Kroah-Hartman
1 parent
b64a71ab5c
Exists in
master
and in
4 other branches
[PATCH] powerpc/PCI hotplug: shuffle error checking to better location.
Error checking is scattered through various layers of the dlpar code, leading to a somewhat opaque code structure. This patch consolidates error checking in one routine, simplifying the code a tad. There's also some whitespace cleanup here too. Signed-off-by: Linas Vepstas <linas@austin.ibm.com> Acked-by: John Rose <johnrose@austin.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 1 changed file with 22 additions and 22 deletions Side-by-side Diff
drivers/pci/hotplug/rpadlpar_core.c
| ... | ... | @@ -103,13 +103,13 @@ |
| 103 | 103 | struct list_head *tmp, *n; |
| 104 | 104 | struct slot *slot; |
| 105 | 105 | |
| 106 | - list_for_each_safe(tmp, n, &rpaphp_slot_head) { | |
| 107 | - slot = list_entry(tmp, struct slot, rpaphp_slot_list); | |
| 108 | - if (slot->dn == dn) | |
| 109 | - return slot; | |
| 110 | - } | |
| 106 | + list_for_each_safe(tmp, n, &rpaphp_slot_head) { | |
| 107 | + slot = list_entry(tmp, struct slot, rpaphp_slot_list); | |
| 108 | + if (slot->dn == dn) | |
| 109 | + return slot; | |
| 110 | + } | |
| 111 | 111 | |
| 112 | - return NULL; | |
| 112 | + return NULL; | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, |
| 116 | 116 | |
| ... | ... | @@ -126,9 +126,9 @@ |
| 126 | 126 | return NULL; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) | |
| 129 | +static void dlpar_pci_add_bus(struct device_node *dn) | |
| 130 | 130 | { |
| 131 | - struct pci_dn *pdn = dn->data; | |
| 131 | + struct pci_dn *pdn = PCI_DN(dn); | |
| 132 | 132 | struct pci_controller *phb = pdn->phb; |
| 133 | 133 | struct pci_dev *dev = NULL; |
| 134 | 134 | |
| ... | ... | @@ -139,7 +139,7 @@ |
| 139 | 139 | if (!dev) { |
| 140 | 140 | printk(KERN_ERR "%s: failed to create pci dev for %s\n", |
| 141 | 141 | __FUNCTION__, dn->full_name); |
| 142 | - return NULL; | |
| 142 | + return; | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | |
| ... | ... | @@ -156,32 +156,32 @@ |
| 156 | 156 | |
| 157 | 157 | /* Add new devices to global lists. Register in proc, sysfs. */ |
| 158 | 158 | pci_bus_add_devices(phb->bus); |
| 159 | - | |
| 160 | - /* Confirm new bridge dev was created */ | |
| 161 | - dev = dlpar_find_new_dev(phb->bus, dn); | |
| 162 | - if (dev) { | |
| 163 | - if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { | |
| 164 | - printk(KERN_ERR "%s: unexpected header type %d\n", | |
| 165 | - __FUNCTION__, dev->hdr_type); | |
| 166 | - return NULL; | |
| 167 | - } | |
| 168 | - } | |
| 169 | - | |
| 170 | - return dev; | |
| 171 | 159 | } |
| 172 | 160 | |
| 173 | 161 | static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) |
| 174 | 162 | { |
| 175 | 163 | struct pci_dev *dev; |
| 164 | + struct pci_controller *phb; | |
| 176 | 165 | |
| 177 | 166 | if (pcibios_find_pci_bus(dn)) |
| 178 | 167 | return -EINVAL; |
| 179 | 168 | |
| 180 | 169 | /* Add pci bus */ |
| 181 | - dev = dlpar_pci_add_bus(dn); | |
| 170 | + dlpar_pci_add_bus(dn); | |
| 171 | + | |
| 172 | + /* Confirm new bridge dev was created */ | |
| 173 | + phb = PCI_DN(dn)->phb; | |
| 174 | + dev = dlpar_find_new_dev(phb->bus, dn); | |
| 175 | + | |
| 182 | 176 | if (!dev) { |
| 183 | 177 | printk(KERN_ERR "%s: unable to add bus %s\n", __FUNCTION__, |
| 184 | 178 | drc_name); |
| 179 | + return -EIO; | |
| 180 | + } | |
| 181 | + | |
| 182 | + if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { | |
| 183 | + printk(KERN_ERR "%s: unexpected header type %d, unable to add bus %s\n", | |
| 184 | + __FUNCTION__, dev->hdr_type, drc_name); | |
| 185 | 185 | return -EIO; |
| 186 | 186 | } |
| 187 | 187 |