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>
This commit is contained in:
Fabio Aiuto 2022-09-30 11:22:09 +02:00 committed by Martin Roth
parent 153e526f77
commit 4fce79f69c
2 changed files with 18 additions and 0 deletions

View File

@ -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;
}

View File

@ -209,6 +209,9 @@ bool is_dev_enabled(const struct device *const dev);
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 *);