Fabio Aiuto has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/68101 )
Change subject: include/device/device_util.c: add helpers to check pci device enabled ......................................................................
include/device/device_util.c: add helpers to check pci device enabled
add helper 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 --- M src/device/device_util.c M src/include/device/device.h 2 files changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/01/68101/1
diff --git a/src/device/device_util.c b/src/device/device_util.c index 0be6cfb..8bba781 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -965,3 +965,18 @@ { return is_cpu(cpu) && cpu->enabled; } + +bool is_pci(const struct device *pci) +{ + return pci->bus->dev->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; +} diff --git a/src/include/device/device.h b/src/include/device/device.h index a375639..0f9c39f 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -209,6 +209,9 @@ bool is_devfn_enabled(unsigned int devfn); bool is_cpu(const struct device *cpu); bool is_enabled_cpu(const struct device *cpu); +bool is_pci(const struct device *pci); +bool is_enabled_pci(const struct device *pci); +bool is_pci_dev_on_bus(const struct device *pci, unsigned int bus);
/* Returns whether there is a hotplug port on the path to the given device. */ extern bool dev_path_hotplug(const struct device *);