diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2024-07-25 00:05:53 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-07-31 14:32:19 +0000 |
commit | 32c38ca221ff5956a81026fd0e5df330d569fcca (patch) | |
tree | 57a07c42f641a94c51d4f71496ca8b00ec79007d /src/soc/amd/common | |
parent | 2c31e86d6b7456d542ed96eeef7cc797ddd62a8b (diff) |
device: introduce and use dev_get_domain_id
To avoid having constructs like 'dev->path.domain.domain' in the SoC
code, create the 'dev_get_domain_id' helper function that returns the
domain ID of either that device if it's a domain device or the
corresponding domain device's domain ID, and use it in the code.
If this function is called with a device other than PCI or domain type,
it won't have a domain number. In order to not need to call 'die',
'dev_get_domain_id' will print an error and return 0 which is a valid
domain number. In that case, the calling code should be fixed.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I3d79f19846cea49609f848a4c42747ac1052c288
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83644
Reviewed-by: Shuo Liu <shuo.liu@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/amd/common')
4 files changed, 4 insertions, 4 deletions
diff --git a/src/soc/amd/common/block/data_fabric/domain.c b/src/soc/amd/common/block/data_fabric/domain.c index c419fe02ce..12a7bba0e5 100644 --- a/src/soc/amd/common/block/data_fabric/domain.c +++ b/src/soc/amd/common/block/data_fabric/domain.c @@ -22,7 +22,7 @@ void amd_pci_domain_scan_bus(struct device *domain) if (segment_group >= PCI_SEGMENT_GROUP_COUNT) { printk(BIOS_ERR, "Skipping domain %u due to too large segment group %u.\n", - domain->path.domain.domain, segment_group); + dev_get_domain_id(domain), segment_group); return; } diff --git a/src/soc/amd/common/block/data_fabric/pci_segment_multi.c b/src/soc/amd/common/block/data_fabric/pci_segment_multi.c index bc680f9fff..433b0044d4 100644 --- a/src/soc/amd/common/block/data_fabric/pci_segment_multi.c +++ b/src/soc/amd/common/block/data_fabric/pci_segment_multi.c @@ -29,6 +29,6 @@ enum cb_err data_fabric_get_pci_bus_numbers(struct device *domain, uint8_t *segm } printk(BIOS_ERR, "No valid DF PCI CFG register pair found for domain %x.\n", - domain->path.domain.domain); + dev_get_domain_id(domain)); return CB_ERR; } diff --git a/src/soc/amd/common/block/data_fabric/pci_segment_single.c b/src/soc/amd/common/block/data_fabric/pci_segment_single.c index 3e02d96148..49e6b9a56d 100644 --- a/src/soc/amd/common/block/data_fabric/pci_segment_single.c +++ b/src/soc/amd/common/block/data_fabric/pci_segment_single.c @@ -27,6 +27,6 @@ enum cb_err data_fabric_get_pci_bus_numbers(struct device *domain, uint8_t *segm } printk(BIOS_ERR, "No valid DF PCI CFG register found for domain %x.\n", - domain->path.domain.domain); + dev_get_domain_id(domain)); return CB_ERR; } diff --git a/src/soc/amd/common/block/root_complex/root_complex.c b/src/soc/amd/common/block/root_complex/root_complex.c index 2bcdc1d432..72eba8a358 100644 --- a/src/soc/amd/common/block/root_complex/root_complex.c +++ b/src/soc/amd/common/block/root_complex/root_complex.c @@ -7,7 +7,7 @@ static const struct domain_iohc_info *get_domain_iohc_info(struct device *domain) { - const unsigned int domain_id = domain->path.domain.domain; + const unsigned int domain_id = dev_get_domain_id(domain); const struct domain_iohc_info *iohc; size_t iohc_count; |