summaryrefslogtreecommitdiff
path: root/src/include/device
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2024-01-22 15:39:46 +0100
committerLean Sheng Tan <sheng.tan@9elements.com>2024-01-24 08:46:19 +0000
commitf95dbcee713d3a8a081644ee345ce0f6fedf39ac (patch)
tree246036838430e0f3724b18cd482cface0c6c853c /src/include/device
parentd8796e50f322ea81fb61ebfce60f3f4d82d0bf2c (diff)
device: Add inline method to identify PATH_ROOT
Add and use inline method to identify the root device. Change-Id: I394c8668245bcfea6414b8ca5f14ef8135897e59 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80169 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'src/include/device')
-rw-r--r--src/include/device/device.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h
index cd0999ac94..863299c01d 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -458,6 +458,15 @@ static inline DEVTREE_CONST void *config_of(const struct device *dev)
*/
#define config_of_soc() __pci_0_00_0_config
+static inline bool is_root_device(const struct device *dev)
+{
+ if (!dev || !dev->bus)
+ return false;
+
+ return (dev->path.type == DEVICE_PATH_ROOT) ||
+ (dev->bus->dev == dev);
+}
+
void enable_static_device(struct device *dev);
void enable_static_devices(struct device *bus);
void scan_smbus(struct device *bus);