diff options
author | Simon Glass | 2021-03-15 17:25:14 +1300 |
---|---|---|
committer | Simon Glass | 2021-03-22 19:23:28 +1300 |
commit | 607f9bcb0d0af57c52bacf4d3aeb3a7d389ea206 (patch) | |
tree | 98b173750b5a254c75006a67edae4d5642017da5 /include/dm/device.h | |
parent | 851144350b6ff1d4982b9af2f9b0fe48aed24b3c (diff) |
dm: core: Add macros to access the new linker lists
Add macros which work with instantiated devices and uclasses, as created
at build time by dtoc. Include variants that can be used in data
structures.
These are mostly used by dtoc but it is worth documenting them fully for
the occasional case where they might come up in user code.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm/device.h')
-rw-r--r-- | include/dm/device.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/dm/device.h b/include/dm/device.h index 45010b4df92..5b8f27d455b 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -363,6 +363,28 @@ struct driver { ll_entry_get(struct driver, __name, driver) /** + * DM_DRIVER_REF() - Get a reference to a driver + * + * This is useful in data structures and code for referencing a driver at + * build time. Before this is used, an extern U_BOOT_DRIVER() must have been + * declared. + * + * For example: + * + * extern U_BOOT_DRIVER(sandbox_fixed_clock); + * + * struct driver *drvs[] = { + * DM_DRIVER_REF(sandbox_fixed_clock), + * }; + * + * @_name: Name of the driver. This must be a valid C identifier, used by the + * linker_list + * @returns struct driver * for the driver + */ +#define DM_DRIVER_REF(_name) \ + ll_entry_ref(struct driver, _name, driver) + +/** * Declare a macro to state a alias for a driver name. This macro will * produce no code but its information will be parsed by tools like * dtoc |