init: add SYS_GET_DEVICE() macro to bury &__initconfig_* names usage.
Add a macro to retrieve the device structure for a config structure by name. This avoids the very error prone activity of the developer having to *know* the way the internal object is named. Change-Id: I1d7857d5aad6dfd4b1b46f63b946aad1ae3a6dc4 Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
This commit is contained in:
parent
ad5af93f25
commit
7a1e221733
1 changed files with 18 additions and 0 deletions
|
@ -83,6 +83,24 @@
|
|||
.config = &(config_##name),\
|
||||
.driver_data = data}
|
||||
|
||||
/**
|
||||
* @def SYS_GET_DEVICE
|
||||
*
|
||||
* @brief Obtain a pointer to a device object by name
|
||||
*
|
||||
* @details Return the address of a device object created by
|
||||
* SYS_DEFINE_DEVICE(), using the @name provided to SYS_DEFINE_DEVICE().
|
||||
*
|
||||
* @param name The same name provided to SYS_DEFINE_DEVICE()
|
||||
*
|
||||
* @return A pointer to the device object created by SYS_DEFINE_DEVICE()
|
||||
*/
|
||||
|
||||
#define _PASTE2(a, b) a##b
|
||||
#define _PASTE(a, b) _PASTE2(a, b)
|
||||
|
||||
#define SYS_GET_DEVICE(name) (&(_PASTE(__initconfig_, name)))
|
||||
|
||||
/* The following legacy APIs are provided for backwards compatibility */
|
||||
|
||||
#define pre_kernel_core_init(cfg, data) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue