diff --git a/common/include/villas/kernel/devices/pci_device.hpp b/common/include/villas/kernel/devices/pci_device.hpp index e71fa4ecc..3213fcd93 100644 --- a/common/include/villas/kernel/devices/pci_device.hpp +++ b/common/include/villas/kernel/devices/pci_device.hpp @@ -106,23 +106,23 @@ protected: std::ios_base::out) const; }; -class DeviceList : public std::list> { +class PciDeviceList : public std::list> { private: // Initialize Linux PCI handle. // // This search for all available PCI devices under /sys/bus/pci - DeviceList(); - DeviceList &operator=(const DeviceList &); - static DeviceList *instance; + PciDeviceList(); + PciDeviceList &operator=(const PciDeviceList &); + static PciDeviceList *instance; public: - static DeviceList *getInstance(); + static PciDeviceList *getInstance(); - DeviceList::value_type lookupDevice(const Slot &s); + PciDeviceList::value_type lookupDevice(const Slot &s); - DeviceList::value_type lookupDevice(const Id &i); + PciDeviceList::value_type lookupDevice(const Id &i); - DeviceList::value_type lookupDevice(const PciDevice &f); + PciDeviceList::value_type lookupDevice(const PciDevice &f); }; } // namespace pci diff --git a/common/lib/kernel/devices/pci_device.cpp b/common/lib/kernel/devices/pci_device.cpp index 86f062114..84748b161 100644 --- a/common/lib/kernel/devices/pci_device.cpp +++ b/common/lib/kernel/devices/pci_device.cpp @@ -25,16 +25,16 @@ using namespace villas::kernel::pci; #define PCI_BASE_ADDRESS_N(n) (PCI_BASE_ADDRESS_0 + sizeof(uint32_t) * (n)) -DeviceList *DeviceList::instance = nullptr; +PciDeviceList *PciDeviceList::instance = nullptr; -DeviceList *DeviceList::getInstance() { +PciDeviceList *PciDeviceList::getInstance() { if (instance == nullptr) { - instance = new DeviceList(); + instance = new PciDeviceList(); } return instance; }; -DeviceList::DeviceList() { +PciDeviceList::PciDeviceList() { struct dirent *e; DIR *dp; FILE *f; @@ -88,21 +88,22 @@ DeviceList::DeviceList() { closedir(dp); } -DeviceList::value_type DeviceList::lookupDevice(const Slot &s) { - return *std::find_if(begin(), end(), [s](const DeviceList::value_type &d) { +PciDeviceList::value_type PciDeviceList::lookupDevice(const Slot &s) { + return *std::find_if(begin(), end(), [s](const PciDeviceList::value_type &d) { return d->slot == s; }); } -DeviceList::value_type DeviceList::lookupDevice(const Id &i) { - return *std::find_if(begin(), end(), [i](const DeviceList::value_type &d) { +PciDeviceList::value_type PciDeviceList::lookupDevice(const Id &i) { + return *std::find_if(begin(), end(), [i](const PciDeviceList::value_type &d) { return d->id == i; }); } -DeviceList::value_type DeviceList::lookupDevice(const PciDevice &d) { - auto dev = std::find_if( - begin(), end(), [d](const DeviceList::value_type &e) { return *e == d; }); +PciDeviceList::value_type PciDeviceList::lookupDevice(const PciDevice &d) { + auto dev = + std::find_if(begin(), end(), + [d](const PciDeviceList::value_type &e) { return *e == d; }); return dev == end() ? value_type() : *dev; } diff --git a/fpga/lib/dma.cpp b/fpga/lib/dma.cpp index 309ac8d60..0a89ca8c5 100644 --- a/fpga/lib/dma.cpp +++ b/fpga/lib/dma.cpp @@ -21,7 +21,7 @@ using namespace villas; -static std::shared_ptr pciDevices; +static std::shared_ptr pciDevices; static auto logger = villas::Log::get("villasfpga_dma"); struct villasfpga_handle_t { diff --git a/fpga/lib/pcie_card.cpp b/fpga/lib/pcie_card.cpp index 6a7f7b008..eb51554d7 100644 --- a/fpga/lib/pcie_card.cpp +++ b/fpga/lib/pcie_card.cpp @@ -71,7 +71,7 @@ PCIeCardFactory::make(json_t *json_card, std::string card_name, filter.slot = kernel::pci::Slot(pci_slot); // Search for FPGA card - card->pdev = kernel::pci::DeviceList::getInstance()->lookupDevice(filter); + card->pdev = kernel::pci::PciDeviceList::getInstance()->lookupDevice(filter); if (!card->pdev) { logger->warn("Failed to find PCI device"); return nullptr; diff --git a/fpga/src/villas-fpga-ctrl.cpp b/fpga/src/villas-fpga-ctrl.cpp index 8cdd424d3..a58a9afb5 100644 --- a/fpga/src/villas-fpga-ctrl.cpp +++ b/fpga/src/villas-fpga-ctrl.cpp @@ -34,7 +34,7 @@ using namespace villas; -static std::shared_ptr pciDevices; +static std::shared_ptr pciDevices; static auto logger = villas::Log::get("ctrl"); void writeToDmaFromStdIn(std::shared_ptr dma) { diff --git a/fpga/src/villas-fpga-pipe.cpp b/fpga/src/villas-fpga-pipe.cpp index 66841ea61..0c0e9e79f 100644 --- a/fpga/src/villas-fpga-pipe.cpp +++ b/fpga/src/villas-fpga-pipe.cpp @@ -27,7 +27,7 @@ using namespace villas; -static std::shared_ptr pciDevices; +static std::shared_ptr pciDevices; static auto logger = villas::Log::get("streamer"); int main(int argc, char *argv[]) { diff --git a/fpga/tests/unit/fpga.cpp b/fpga/tests/unit/fpga.cpp index d6ad32478..ae096fda2 100644 --- a/fpga/tests/unit/fpga.cpp +++ b/fpga/tests/unit/fpga.cpp @@ -27,7 +27,7 @@ using namespace villas; -static kernel::pci::DeviceList *pciDevices; +static kernel::pci::PciDeviceList *pciDevices; FpgaState state; @@ -40,7 +40,7 @@ static void init() { plugin::registry->dump(); - pciDevices = kernel::pci::DeviceList::getInstance(); + pciDevices = kernel::pci::PciDeviceList::getInstance(); auto vfioContainer = std::make_shared();