aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/cpqphp_pci.c
diff options
context:
space:
mode:
authorAlex Chiang <achiang@hp.com>2009-03-31 11:24:02 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-06-11 15:04:14 -0400
commitb019ee679afde950f2d01b1af0530453aa60af3f (patch)
treed6f2cea2323cbd0b8b403ab59eec9f527a0ab026 /drivers/pci/hotplug/cpqphp_pci.c
parent1d2e8b1c58ef96b8834b139caf4357effedcb5ab (diff)
PCI Hotplug: cpqphp: clean up accesses to pcibios_get_irq_routing_table()
Instead of making multiple calls to pcibios_get_irq_routing_table, let's just do it once and save the answer. The reason we were making multiple calls is because we liked to calculate its length and perform some loop over it. Instead of open-coding the length calculation every time, provide it in an inline helper function. Finally, since pci_print_IRQ_route() is used only for debug, let's only do it when cpqhp_debug is set. Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug/cpqphp_pci.c')
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c36
1 files changed, 7 insertions, 29 deletions
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 2909e3f6caa7..6201281b9dab 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -37,7 +37,6 @@
37#include "../pci.h" 37#include "../pci.h"
38#include "cpqphp.h" 38#include "cpqphp.h"
39#include "cpqphp_nvram.h" 39#include "cpqphp_nvram.h"
40#include <asm/pci_x86.h>
41 40
42 41
43u8 cpqhp_nic_irq; 42u8 cpqhp_nic_irq;
@@ -244,39 +243,23 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev
244 243
245static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot, u8 nobridge) 244static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot, u8 nobridge)
246{ 245{
247 struct irq_routing_table *PCIIRQRoutingInfoLength; 246 int loop, len;
248 long len;
249 long loop;
250 u32 work; 247 u32 work;
251
252 u8 tbus, tdevice, tslot; 248 u8 tbus, tdevice, tslot;
253 249
254 PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table(); 250 len = cpqhp_routing_table_length();
255 if (!PCIIRQRoutingInfoLength)
256 return -1;
257
258 len = (PCIIRQRoutingInfoLength->size -
259 sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
260 /* Make sure I got at least one entry */
261 if (len == 0) {
262 kfree(PCIIRQRoutingInfoLength );
263 return -1;
264 }
265
266 for (loop = 0; loop < len; ++loop) { 251 for (loop = 0; loop < len; ++loop) {
267 tbus = PCIIRQRoutingInfoLength->slots[loop].bus; 252 tbus = cpqhp_routing_table->slots[loop].bus;
268 tdevice = PCIIRQRoutingInfoLength->slots[loop].devfn; 253 tdevice = cpqhp_routing_table->slots[loop].devfn;
269 tslot = PCIIRQRoutingInfoLength->slots[loop].slot; 254 tslot = cpqhp_routing_table->slots[loop].slot;
270 255
271 if (tslot == slot) { 256 if (tslot == slot) {
272 *bus_num = tbus; 257 *bus_num = tbus;
273 *dev_num = tdevice; 258 *dev_num = tdevice;
274 ctrl->pci_bus->number = tbus; 259 ctrl->pci_bus->number = tbus;
275 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); 260 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work);
276 if (!nobridge || (work == 0xffffffff)) { 261 if (!nobridge || (work == 0xffffffff))
277 kfree(PCIIRQRoutingInfoLength );
278 return 0; 262 return 0;
279 }
280 263
281 dbg("bus_num %d devfn %d\n", *bus_num, *dev_num); 264 dbg("bus_num %d devfn %d\n", *bus_num, *dev_num);
282 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work); 265 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work);
@@ -287,17 +270,12 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
287 dbg("Scan bus for Non Bridge: bus %d\n", tbus); 270 dbg("Scan bus for Non Bridge: bus %d\n", tbus);
288 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { 271 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) {
289 *bus_num = tbus; 272 *bus_num = tbus;
290 kfree(PCIIRQRoutingInfoLength );
291 return 0; 273 return 0;
292 } 274 }
293 } else { 275 } else
294 kfree(PCIIRQRoutingInfoLength );
295 return 0; 276 return 0;
296 }
297
298 } 277 }
299 } 278 }
300 kfree(PCIIRQRoutingInfoLength );
301 return -1; 279 return -1;
302} 280}
303 281