From 32c38ca221ff5956a81026fd0e5df330d569fcca Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 25 Jul 2024 00:05:53 +0200 Subject: 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 Change-Id: I3d79f19846cea49609f848a4c42747ac1052c288 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83644 Reviewed-by: Shuo Liu Tested-by: build bot (Jenkins) --- src/soc/amd/genoa_poc/domain.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/soc/amd/genoa_poc/domain.c') diff --git a/src/soc/amd/genoa_poc/domain.c b/src/soc/amd/genoa_poc/domain.c index 88f386c2c1..b6369a47d0 100644 --- a/src/soc/amd/genoa_poc/domain.c +++ b/src/soc/amd/genoa_poc/domain.c @@ -26,7 +26,7 @@ static void genoa_domain_set_resources(struct device *domain) { if (domain->downstream->bridge_ctrl & PCI_BRIDGE_CTL_VGA) { printk(BIOS_DEBUG, "Setting VGA decoding for domain 0x%x\n", - domain->path.domain.domain); + dev_get_domain_id(domain)); const union df_vga_en vga_en = { .ve = 1, .dst_fabric_id = get_iohc_fabric_id(domain), @@ -48,6 +48,7 @@ static void genoa_domain_set_resources(struct device *domain) static const char *genoa_domain_acpi_name(const struct device *domain) { + const unsigned int domain_id = dev_get_domain_id(domain); const char *domain_acpi_names[4] = { "S0B0", "S0B1", @@ -55,8 +56,8 @@ static const char *genoa_domain_acpi_name(const struct device *domain) "S0B3", }; - if (domain->path.domain.domain < ARRAY_SIZE(domain_acpi_names)) - return domain_acpi_names[domain->path.domain.domain]; + if (domain_id < ARRAY_SIZE(domain_acpi_names)) + return domain_acpi_names[domain_id]; return NULL; } -- cgit v1.2.3