aboutsummaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorFabio Aiuto <fabioaiuto83@gmail.com>2022-09-30 11:22:09 +0200
committerMartin Roth <martin.roth@amd.corp-partner.google.com>2022-10-06 18:30:14 +0000
commit4fce79f69c04094fcdd6f2ee89e06a1a776a7deb (patch)
tree71b7dbddbf2a30c46ea75306ad518ed2c996bf00 /src/device
parent153e526f779323646225554f2643f8309743a0a7 (diff)
include/device/device_util.c: add predicates for pci devices
add functions to check whether a device is enabled pci device or a pci device on a specific bus number. TEST: compile and qemu run successfully Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com> Change-Id: I3257c8404017372f6cdd9f6cf9453502447343a0 Reviewed-on: https://review.coreboot.org/c/coreboot/+/68101 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/device')
-rw-r--r--src/device/device_util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 0be6cfbf36..6919f4bb39 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -965,3 +965,18 @@ bool is_enabled_cpu(const struct device *cpu)
{
return is_cpu(cpu) && cpu->enabled;
}
+
+bool is_pci(const struct device *pci)
+{
+ return pci->path.type == DEVICE_PATH_PCI;
+}
+
+bool is_enabled_pci(const struct device *pci)
+{
+ return is_pci(pci) && pci->enabled;
+}
+
+bool is_pci_dev_on_bus(const struct device *pci, unsigned int bus)
+{
+ return is_pci(pci) && pci->bus->secondary == bus;
+}