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/include/device/device.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include/device') diff --git a/src/include/device/device.h b/src/include/device/device.h index ac8a1171c5..3eee3218fa 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -183,6 +183,7 @@ const char *dev_name(const struct device *dev); const char *dev_path(const struct device *dev); u32 dev_path_encode(const struct device *dev); const struct device *dev_get_domain(const struct device *dev); +unsigned int dev_get_domain_id(const struct device *dev); void dev_set_enabled(struct device *dev, int enable); void disable_children(struct bus *bus); bool dev_is_active_bridge(struct device *dev); -- cgit v1.2.3