Skip to content

Commit 73b4207

Browse files
author
Alexander Antonov
committed
Add isIntelDeviceById() wrapper to pci structure
1 parent 001ffe1 commit 73b4207

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/lspci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ struct pci {
238238
bool hasChildDevices() const { return (child_pci_devs.size() != 0); }
239239

240240
bool isIntelDevice() const { return (vendor_id == PCM_INTEL_PCI_VENDOR_ID); }
241+
242+
bool isIntelDeviceById(uint16_t device_id) const { return (isIntelDevice() && (this->device_id == device_id)); }
241243
};
242244

243245
struct iio_skx {

src/pcm-iio-pmu.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,8 @@ void PurleyPlatformMapping::getUboxBusNumbers(std::vector<uint32_t>& ubox)
253253
pci_dev.bdf.busno = (uint8_t)bus;
254254
pci_dev.bdf.devno = device;
255255
pci_dev.bdf.funcno = function;
256-
if (probe_pci(&pci_dev)) {
257-
if (pci_dev.isIntelDevice() && (pci_dev.device_id == SKX_SOCKETID_UBOX_DID)) {
258-
ubox.push_back(bus);
259-
}
256+
if (probe_pci(&pci_dev) && pci_dev.isIntelDeviceById(SKX_SOCKETID_UBOX_DID)) {
257+
ubox.push_back(bus);
260258
}
261259
}
262260
}
@@ -337,7 +335,7 @@ bool IPlatformMapping10Nm::getSadIdRootBusMap(uint32_t socket_id, std::map<uint8
337335
pci_dev.bdf.busno = (uint8_t)bus;
338336
pci_dev.bdf.devno = device;
339337
pci_dev.bdf.funcno = function;
340-
if (probe_pci(&pci_dev) && pci_dev.isIntelDevice() && (pci_dev.device_id == SNR_ICX_MESH2IIO_MMAP_DID)) {
338+
if (probe_pci(&pci_dev) && pci_dev.isIntelDeviceById(SNR_ICX_MESH2IIO_MMAP_DID)) {
341339

342340
PciHandleType h(0, bus, device, function);
343341
std::uint32_t sad_ctrl_cfg;
@@ -642,12 +640,10 @@ bool EagleStreamPlatformMapping::setChopValue()
642640
{
643641
for (uint16_t b = 0; b < 256; b++) {
644642
struct pci pci_dev(0, b, SPR_PCU_CR3_REG_DEVICE, SPR_PCU_CR3_REG_FUNCTION);
645-
if (!probe_pci(&pci_dev)) {
646-
continue;
647-
}
648-
if (!(pci_dev.isIntelDevice() && (pci_dev.device_id == SPR_PCU_CR3_DID))) {
643+
if (!(probe_pci(&pci_dev) && pci_dev.isIntelDeviceById(SPR_PCU_CR3_DID))) {
649644
continue;
650645
}
646+
651647
std::uint32_t capid4;
652648
PciHandleType h(0, b, SPR_PCU_CR3_REG_DEVICE, SPR_PCU_CR3_REG_FUNCTION);
653649
h.read32(SPR_CAPID4_OFFSET, &capid4);
@@ -682,7 +678,7 @@ bool EagleStreamPlatformMapping::getRootBuses(std::map<int, std::map<int, struct
682678
if (!probe_pci(&pci_dev)) {
683679
break;
684680
}
685-
if (!(pci_dev.isIntelDevice() && (pci_dev.device_id == SPR_MSM_DEV_ID))) {
681+
if (!pci_dev.isIntelDeviceById(SPR_MSM_DEV_ID)) {
686682
continue;
687683
}
688684

@@ -940,22 +936,20 @@ bool LoganvillePlatform::loganvilleDlbStackProbe(struct iio_stacks_on_socket& ii
940936

941937
for (uint8_t bus = root_bus; bus < 255; bus++) {
942938
struct pci pci_dev(bus, 0x00, 0x00);
943-
if (probe_pci(&pci_dev)) {
944-
if ((pci_dev.isIntelDevice()) && (pci_dev.device_id == HQMV25_DID)) {
945-
dlb_part.root_pci_dev = pci_dev;
946-
// Check Virtual RPs for DLB
947-
for (uint8_t device = 0; device < 2; device++) {
948-
for (uint8_t function = 0; function < 8; function++) {
949-
struct pci child_pci_dev(bus, device, function);
950-
if (probe_pci(&child_pci_dev)) {
951-
dlb_part.child_pci_devs.push_back(child_pci_dev);
952-
}
939+
if (probe_pci(&pci_dev) && pci_dev.isIntelDeviceById(HQMV25_DID)) {
940+
dlb_part.root_pci_dev = pci_dev;
941+
// Check Virtual RPs for DLB
942+
for (uint8_t device = 0; device < 2; device++) {
943+
for (uint8_t function = 0; function < 8; function++) {
944+
struct pci child_pci_dev(bus, device, function);
945+
if (probe_pci(&child_pci_dev)) {
946+
dlb_part.child_pci_devs.push_back(child_pci_dev);
953947
}
954948
}
955-
stack.parts.push_back(dlb_part);
956-
iio_on_socket.stacks.push_back(stack);
957-
return true;
958949
}
950+
stack.parts.push_back(dlb_part);
951+
iio_on_socket.stacks.push_back(stack);
952+
return true;
959953
}
960954
}
961955

@@ -1077,7 +1071,7 @@ bool Xeon6thNextGenPlatform::getRootBuses(std::map<int, std::map<int, struct bdf
10771071
if (!probe_pci(&pci_dev)) {
10781072
break;
10791073
}
1080-
if (!(pci_dev.isIntelDevice() && (pci_dev.device_id == SPR_MSM_DEV_ID))) {
1074+
if (!pci_dev.isIntelDeviceById(SPR_MSM_DEV_ID)) {
10811075
continue;
10821076
}
10831077

0 commit comments

Comments
 (0)