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>
This commit is contained in:
Simon Glass
2021-03-15 17:25:14 +13:00
parent 851144350b
commit 607f9bcb0d
5 changed files with 179 additions and 2 deletions

View File

@@ -362,6 +362,28 @@ struct driver {
#define DM_DRIVER_GET(__name) \
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