From c6e67432610771fa8d2a9df9ad5f1543107e043a Mon Sep 17 00:00:00 2001 From: David Karoly Date: Sat, 13 Aug 2022 19:17:27 +0200 Subject: [PATCH] PCI: refactor root node detection Change-Id: Icc4ab0c3f7258914d798267e08c47977c0987c97 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5547 Tested-by: Commit checker robot Reviewed-by: Alex von Gluck IV Reviewed-by: David Karoly --- .../kernel/bus_managers/pci/pci_root.cpp | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/pci/pci_root.cpp b/src/add-ons/kernel/bus_managers/pci/pci_root.cpp index 50c5d2d8f1..7817f6a1a4 100644 --- a/src/add-ons/kernel/bus_managers/pci/pci_root.cpp +++ b/src/add-ons/kernel/bus_managers/pci/pci_root.cpp @@ -32,35 +32,31 @@ pci_root_supports_device(device_node* parent) return -1.0f; #if defined(__riscv) - const char* compatible; - if (gDeviceManager->get_attr_string(parent, "fdt/compatible", &compatible, - false) < B_OK) - return -1.0f; + if (strcmp(bus, "fdt") == 0) { + const char* compatible; + if (gDeviceManager->get_attr_string(parent, "fdt/compatible", &compatible, false) < B_OK) + return -1.0f; - if (strcmp(bus, "fdt") != 0) - return 0.0f; - - if (strcmp(compatible, "pci-host-ecam-generic") != 0 - && strcmp(compatible, "sifive,fu740-pcie") != 0) { - return 0.0f; + if (strcmp(compatible, "pci-host-ecam-generic") == 0 + || strcmp(compatible, "sifive,fu740-pcie") == 0) { + return 1.0f; + } } #elif defined(__aarch64__) - if (strcmp(bus, "acpi") != 0) - return -1.0f; + if (strcmp(bus, "acpi") == 0) { + const char* hid; + if (gDeviceManager->get_attr_string(parent, ACPI_DEVICE_HID_ITEM, &hid, false) < B_OK) + return -1.0f; - const char* hid; - if (gDeviceManager->get_attr_string(parent, ACPI_DEVICE_HID_ITEM, &hid, - false) < B_OK) - return -1.0f; - - if (strcmp(hid, "PNP0A03") != 0 && strcmp(hid, "PNP0A08") != 0) - return -1.0f; + if (strcmp(hid, "PNP0A03") == 0 || strcmp(hid, "PNP0A08") == 0) + return 1.0f; + } #else - if (strcmp(bus, "root") != 0) - return 0.0f; + if (strcmp(bus, "root") == 0) + return 1.0f; #endif - return 1.0; + return 0.0; }