device: add a new macro to obtain the device object symbol name
The new SYS_GET_DEVICE_NAME macro can be used in combination with SYS_GET_DEVICE to obtain an external reference to a static device object, e.g.: extern struct device SYS_GET_DEVICE_NAME(my_device_name); struct device* dev = SYS_GET_DEVICE(my_device_name); dev is here set at compile time. Change-Id: I9094925c685177f01e0cef194ec382ad49658f9d Signed-off-by: Fabien Chereau <fabien.chereau@intel.com>
This commit is contained in:
parent
45dcfe1478
commit
49abcb3fff
1 changed files with 18 additions and 1 deletions
|
@ -85,6 +85,23 @@
|
|||
.config = &(config_##name),\
|
||||
.driver_data = data}
|
||||
|
||||
/**
|
||||
* @def SYS_GET_DEVICE_NAME
|
||||
*
|
||||
* @brief Expands to the full name of a global device object
|
||||
*
|
||||
* @details Return the full name of a device object symbol created by
|
||||
* SYS_DEFINE_DEVICE(), using the @name provided to SYS_DEFINE_DEVICE().
|
||||
*
|
||||
* It is meant to be used for declaring extern symbols pointing on device
|
||||
* objects before using the SYS_GET_DEVICE macro to get the device object.
|
||||
*
|
||||
* @param name The same name provided to SYS_DEFINE_DEVICE()
|
||||
*
|
||||
* @return The exanded name of the device object created by SYS_DEFINE_DEVICE()
|
||||
*/
|
||||
#define SYS_GET_DEVICE_NAME(name) (_CONCAT(__initconfig_, name))
|
||||
|
||||
/**
|
||||
* @def SYS_GET_DEVICE
|
||||
*
|
||||
|
@ -97,6 +114,6 @@
|
|||
*
|
||||
* @return A pointer to the device object created by SYS_DEFINE_DEVICE()
|
||||
*/
|
||||
#define SYS_GET_DEVICE(name) (&(_CONCAT(__initconfig_, name)))
|
||||
#define SYS_GET_DEVICE(name) (&SYS_GET_DEVICE_NAME(name))
|
||||
|
||||
#endif /* _INIT_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue