pm: fully initialize pm_device on Z_DEVICE_STATE_DEFINE
The initialization of the struct pm_device pm field found in the device state can be statically initialized without the need of doing it at runtime. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
c5e077c48f
commit
9917de4a1b
2 changed files with 6 additions and 14 deletions
|
@ -839,6 +839,12 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
|
|||
static struct device_state Z_DEVICE_STATE_NAME(dev_name) \
|
||||
__attribute__((__section__(".z_devstate"))) = { \
|
||||
.pm = { \
|
||||
.usage = ATOMIC_INIT(0), \
|
||||
.lock = Z_MUTEX_INITIALIZER( \
|
||||
Z_DEVICE_STATE_NAME(dev_name).pm.lock), \
|
||||
.condvar = Z_CONDVAR_INITIALIZER( \
|
||||
Z_DEVICE_STATE_NAME(dev_name).pm.condvar),\
|
||||
.state = PM_DEVICE_STATE_ACTIVE, \
|
||||
.flags = ATOMIC_INIT(COND_CODE_1( \
|
||||
DT_NODE_EXISTS(node_id), \
|
||||
(DT_PROP_OR( \
|
||||
|
|
|
@ -25,19 +25,6 @@ extern const struct device __device_end[];
|
|||
|
||||
extern uint32_t __device_init_status_start[];
|
||||
|
||||
static inline void device_pm_state_init(const struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
*dev->pm = (struct pm_device){
|
||||
.usage = ATOMIC_INIT(0),
|
||||
.lock = Z_MUTEX_INITIALIZER(dev->pm->lock),
|
||||
.condvar = Z_CONDVAR_INITIALIZER(dev->pm->condvar),
|
||||
.state = PM_DEVICE_STATE_ACTIVE,
|
||||
.flags = ATOMIC_INIT(dev->pm->flags),
|
||||
};
|
||||
#endif /* CONFIG_PM_DEVICE */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize state for all static devices.
|
||||
*
|
||||
|
@ -49,7 +36,6 @@ void z_device_state_init(void)
|
|||
const struct device *dev = __device_start;
|
||||
|
||||
while (dev < __device_end) {
|
||||
device_pm_state_init(dev);
|
||||
z_object_init(dev);
|
||||
++dev;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue