diff options
author | Furquan Shaikh <furquan@google.com> | 2021-09-16 16:27:10 -0700 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-09-20 12:17:50 +0000 |
commit | 26e2afdd77bae6707373c61468bc7abad9ff90b7 (patch) | |
tree | 32fbe6365233be22770acddcff421e50d4f2126a /src/include/device | |
parent | 0df32c85add990dac5e66e2ced3943e6f7e7905b (diff) |
device: Add helper macros for device pointers using alias names
This change provides helper macros for generating pointer name and
weak pointer definition for devices using alias names. This will be
helpful for developers to reference the device pointer with alias
names used in the device tree.
Change-Id: I3a5a3c7fdc2c521bac9ab3336f5a6ebecd621e04
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57738
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Diffstat (limited to 'src/include/device')
-rw-r--r-- | src/include/device/device.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h index 5a9b9e5b4e..0fadc0cd1e 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -391,4 +391,12 @@ void scan_smbus(struct device *bus); void scan_generic_bus(struct device *bus); void scan_static_bus(struct device *bus); +/* Macro to generate `struct device *` name that points to a device with the given alias. */ +#define DEV_PTR(_alias) _dev_##_alias##_ptr + +/* Macro to generate weak `struct device *` definition that points to a device with the given + alias. */ +#define WEAK_DEV_PTR(_alias) \ + __weak DEVTREE_CONST struct device *const DEV_PTR(_alias) + #endif /* DEVICE_H */ |