Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions drivers/power/pm_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ int pm_register(FAR struct pm_callback_s *callbacks)

/* Add the new entry to the end of the list of registered callbacks */

ret = pm_lock();
if (ret == OK)
if (OSINIT_OS_READY())
{
ret = pm_lock();
if (ret == OK)
{
dq_addlast(&callbacks->entry, &g_pmglobals.registry);
pm_unlock();
}
}
else
{
dq_addlast(&callbacks->entry, &g_pmglobals.registry);
pm_unlock();
ret = OK;
}

return ret;
Expand Down
4 changes: 1 addition & 3 deletions include/nuttx/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#define OSINIT_MM_READY() (g_nx_initstate >= OSINIT_MEMORY)
#define OSINIT_HW_READY() (g_nx_initstate >= OSINIT_HARDWARE)
#define OSINIT_OS_READY() (g_nx_initstate >= OSINIT_OSREADY)
#define OSINIT_IDLELOOP() (g_nx_initstate >= OSINIT_IDLELOOP)
#define OSINIT_OS_INITIALIZING() (g_nx_initstate < OSINIT_OSREADY)

/****************************************************************************
Expand All @@ -66,9 +65,8 @@ enum nx_initstate_e
* to support the hardware are also available but
* the OS has not yet completed its full
* initialization. */
OSINIT_OSREADY = 5, /* The OS is fully initialized and multi-tasking is
OSINIT_OSREADY = 5 /* The OS is fully initialized and multi-tasking is
* active. */
OSINIT_IDLELOOP = 6 /* The OS enter idle loop */
};

/****************************************************************************
Expand Down
4 changes: 0 additions & 4 deletions sched/init/nx_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,6 @@ void nx_start(void)

DEBUGVERIFY(nx_bringup());

/* Enter to idleloop */

g_nx_initstate = OSINIT_IDLELOOP;

/* Let other threads have access to the memory manager */

sched_unlock();
Expand Down
4 changes: 1 addition & 3 deletions sched/semaphore/sem_trywait.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <assert.h>
#include <errno.h>

#include <nuttx/init.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>

Expand Down Expand Up @@ -70,10 +69,9 @@ int nxsem_trywait(FAR sem_t *sem)
irqstate_t flags;
int ret;

/* This API should not be called from interrupt handlers & idleloop */
/* This API should not be called from interrupt handlers */

DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
DEBUGASSERT(OSINIT_IDLELOOP() && !sched_idletask());

if (sem != NULL)
{
Expand Down
4 changes: 1 addition & 3 deletions sched/semaphore/sem_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <errno.h>
#include <assert.h>

#include <nuttx/init.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/cancelpt.h>
Expand Down Expand Up @@ -74,10 +73,9 @@ int nxsem_wait(FAR sem_t *sem)
irqstate_t flags;
int ret = -EINVAL;

/* This API should not be called from interrupt handlers & idleloop */
/* This API should not be called from interrupt handlers */

DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
DEBUGASSERT(OSINIT_IDLELOOP() && !sched_idletask());

/* The following operations must be performed with interrupts
* disabled because nxsem_post() may be called from an interrupt
Expand Down