diff options
Diffstat (limited to 'src/hardware/LMI_PCIBridgeSystemDeviceProvider.c')
-rw-r--r-- | src/hardware/LMI_PCIBridgeSystemDeviceProvider.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c b/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c index de83816..2532c38 100644 --- a/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c +++ b/src/hardware/LMI_PCIBridgeSystemDeviceProvider.c @@ -26,9 +26,16 @@ static const CMPIBroker* _cb; +struct pci_access *acc_system_bridge = NULL; + static void LMI_PCIBridgeSystemDeviceInitialize() { lmi_init(provider_name, _cb, provider_config_defaults); + + if (init_pci_access(&acc_system_bridge, PCI_FILL_CLASS) != 0) { + error("Failed to access the PCI bus."); + abort(); + } } static CMPIStatus LMI_PCIBridgeSystemDeviceCleanup( @@ -36,6 +43,8 @@ static CMPIStatus LMI_PCIBridgeSystemDeviceCleanup( const CMPIContext* cc, CMPIBoolean term) { + cleanup_pci_access(&acc_system_bridge); + CMReturn(CMPI_RC_OK); } @@ -62,7 +71,6 @@ static CMPIStatus LMI_PCIBridgeSystemDeviceEnumInstances( CMPIObjectPath *o; CMPIStatus st; const char *ns = KNameSpace(cop); - struct pci_access *acc; struct pci_dev *dev; char device_id_str[PCI_DEVID_STR_SIZE]; @@ -73,15 +81,7 @@ static CMPIStatus LMI_PCIBridgeSystemDeviceEnumInstances( o = CIM_ComputerSystemRef_ToObjectPath(&cim_cs, &st); CMSetClassName(o, get_system_creation_class_name()); - if (!(acc = pci_alloc())) { - KReturn2(_cb, ERR_FAILED, "Can't access the PCI bus."); - } - pci_init(acc); - pci_scan_bus(acc); - - for (dev = acc->devices; dev; dev = dev->next) { - pci_fill_info(dev, PCI_FILL_CLASS); - + for (dev = acc_system_bridge->devices; dev; dev = dev->next) { /* Use only PCI Bridges */ /* Throw away the lower 8 bits denoting the subclass */ if (((dev->device_class) >> 8) != LMI_PCIBridge_ClassCode_Bridge) { @@ -109,8 +109,6 @@ static CMPIStatus LMI_PCIBridgeSystemDeviceEnumInstances( KReturnInstance(cr, lmi_pci_sys_device); } - pci_cleanup(acc); - CMReturn(CMPI_RC_OK); } |