Skip to content

Commit

Permalink
power: clean up system power managment function names
Browse files Browse the repository at this point in the history
This commit cleans up names of system power management functions by
assuring that:
- all functions start with 'sys_pm_' prefix
- API functions which should not be exposed to the user start with '_'
- name of the function hints at its purpose

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
  • Loading branch information
mnkp authored and nashif committed Mar 26, 2019
1 parent 204311d commit 17b08ce
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion arch/arc/core/reset.S
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ done_cache_invalidate:

#if defined(CONFIG_SYS_POWER_DEEP_SLEEP_STATES) && \
!defined(CONFIG_BOOTLOADER_CONTEXT_RESTORE)
jl @sys_resume_from_deep_sleep
jl @_sys_resume_from_deep_sleep
#endif

#ifdef CONFIG_INIT_STACKS
Expand Down
12 changes: 6 additions & 6 deletions arch/x86/core/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#endif

#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
GTEXT(sys_resume_from_deep_sleep)
GTEXT(_sys_resume_from_deep_sleep)
#endif

#ifdef CONFIG_REALMODE
Expand Down Expand Up @@ -255,13 +255,13 @@ __csSet:
* the ISR stack size are some multiple of STACK_ALIGN, which
* is at least 4.
*
* This is also used to call the sys_resume_from_deep_sleep()
* This is also used to call the _sys_resume_from_deep_sleep()
* routine to avoid memory corruption if the system is resuming from
* deep sleep. It is important that sys_resume_from_deep_sleep()
* deep sleep. It is important that _sys_resume_from_deep_sleep()
* restores the stack pointer to what it was at deep sleep before
* enabling interrupts. This is necessary to avoid
* interfering with interrupt handler use of this stack.
* If it is a cold boot then sys_resume_from_deep_sleep() should
* If it is a cold boot then _sys_resume_from_deep_sleep() should
* not do anything and must return immediately.
*/
#ifdef CONFIG_INIT_STACKS
Expand All @@ -287,7 +287,7 @@ __csSet:
#if defined(CONFIG_SYS_POWER_DEEP_SLEEP_STATES) && \
!defined(CONFIG_BOOTLOADER_CONTEXT_RESTORE)
/*
* Invoke sys_resume_from_deep_sleep() hook to handle resume from
* Invoke _sys_resume_from_deep_sleep() hook to handle resume from
* deep sleep. It should first check whether system is recovering from
* deep sleep state. If it is, then this function should restore
* states and resume at the point system went to deep sleep.
Expand All @@ -298,7 +298,7 @@ __csSet:
* return and execution falls through to cold boot path.
*/

call sys_resume_from_deep_sleep
call _sys_resume_from_deep_sleep

#endif

Expand Down
24 changes: 12 additions & 12 deletions include/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ static inline bool sys_pm_is_deep_sleep_state(enum power_states state)
/**
* @brief Function to disable power management idle exit notification
*
* The sys_resume() would be called from the ISR of the event that caused
* The _sys_resume() would be called from the ISR of the event that caused
* exit from kernel idling after PM operations. For some power operations,
* this notification may not be necessary. This function can be called in
* sys_suspend to disable the corresponding sys_resume notification.
* _sys_suspend to disable the corresponding _sys_resume notification.
*
*/
static inline void sys_pm_idle_exit_notification_disable(void)
static inline void _sys_pm_idle_exit_notification_disable(void)
{
sys_pm_idle_exit_notify = 0;
}
Expand Down Expand Up @@ -231,13 +231,13 @@ extern bool sys_pm_ctrl_is_state_enabled(enum power_states state);
* function should return immediately.
*
*/
void sys_resume_from_deep_sleep(void);
void _sys_resume_from_deep_sleep(void);

/**
* @brief Hook function to notify exit from kernel idling after PM operations
*
* This function would notify exit from kernel idling if a corresponding
* sys_suspend() notification was handled and did not return
* _sys_suspend() notification was handled and did not return
* SYS_POWER_STATE_ACTIVE.
*
* This function would be called from the ISR context of the event
Expand All @@ -249,11 +249,11 @@ void sys_resume_from_deep_sleep(void);
* those cases, the ISR would be invoked immediately after the event wakes up
* the CPU, before code following the CPU wait, gets a chance to execute. This
* can be ignored if no operation needs to be done at the wake event
* notification. Alternatively sys_pm_idle_exit_notification_disable() can
* be called in sys_suspend to disable this notification.
* notification. Alternatively _sys_pm_idle_exit_notification_disable() can
* be called in _sys_suspend to disable this notification.
*
*/
void sys_resume(void);
void _sys_resume(void);

/**
* @brief Hook function to allow entry to power state
Expand All @@ -279,7 +279,7 @@ void sys_resume(void);
*
* @return Power state which was selected and entered.
*/
extern enum power_states sys_suspend(s32_t ticks);
extern enum power_states _sys_suspend(s32_t ticks);

/**
* @brief Put processor into power state
Expand All @@ -297,23 +297,23 @@ extern void sys_set_power_state(enum power_states state);
* interrupts after resuming from sleep state. In future, the enabling
* of interrupts may be moved into the kernel.
*/
extern void sys_power_state_post_ops(enum power_states state);
extern void _sys_pm_power_state_exit_post_ops(enum power_states state);

/**
* @brief Application defined function for power state entry
*
* Application defined function for doing any target specific operations
* for power state entry.
*/
extern void sys_pm_notify_lps_entry(enum power_states state);
extern void sys_pm_notify_power_state_entry(enum power_states state);

/**
* @brief Application defined function for sleep state exit
*
* Application defined function for doing any target specific operations
* for sleep state exit.
*/
extern void sys_pm_notify_lps_exit(enum power_states state);
extern void sys_pm_notify_power_state_exit(enum power_states state);

/**
* @}
Expand Down
12 changes: 6 additions & 6 deletions kernel/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

#ifdef CONFIG_SYS_POWER_MANAGEMENT
/*
* Used to allow sys_suspend() implementation to control notification
* Used to allow _sys_suspend() implementation to control notification
* of the event that caused exit from kernel idling after pm operations.
*/
unsigned char sys_pm_idle_exit_notify;

#if defined(CONFIG_SYS_POWER_SLEEP_STATES)
void __attribute__((weak)) sys_resume(void)
void __attribute__((weak)) _sys_resume(void)
{
}
#endif

#if defined(CONFIG_SYS_POWER_DEEP_SLEEP_STATES)
void __attribute__((weak)) sys_resume_from_deep_sleep(void)
void __attribute__((weak)) _sys_resume_from_deep_sleep(void)
{
}
#endif
Expand Down Expand Up @@ -92,7 +92,7 @@ static void sys_power_save_idle(void)
* idle processing re-enables interrupts which is essential for
* the kernel's scheduling logic.
*/
if (sys_suspend(ticks) == SYS_POWER_STATE_ACTIVE) {
if (_sys_suspend(ticks) == SYS_POWER_STATE_ACTIVE) {
sys_pm_idle_exit_notify = 0U;
k_cpu_idle();
}
Expand All @@ -108,11 +108,11 @@ void z_sys_power_save_idle_exit(s32_t ticks)
/* Some CPU low power states require notification at the ISR
* to allow any operations that needs to be done before kernel
* switches task or processes nested interrupts. This can be
* disabled by calling sys_pm_idle_exit_notification_disable().
* disabled by calling _sys_pm_idle_exit_notification_disable().
* Alternatively it can be simply ignored if not required.
*/
if (sys_pm_idle_exit_notify) {
sys_resume();
_sys_resume();
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions samples/boards/nrf52/power_mgr/src/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Application defined function for doing any target specific operations
* for low power entry.
*/
void sys_pm_notify_lps_entry(enum power_states state)
void sys_pm_notify_power_state_entry(enum power_states state)
{
switch (state) {
case SYS_POWER_STATE_SLEEP_2:
Expand Down Expand Up @@ -61,7 +61,7 @@ void sys_pm_notify_lps_entry(enum power_states state)
* Application defined function for doing any target specific operations
* for low power exit.
*/
void sys_pm_notify_lps_exit(enum power_states state)
void sys_pm_notify_power_state_exit(enum power_states state)
{
switch (state) {
case SYS_POWER_STATE_SLEEP_2:
Expand Down
2 changes: 1 addition & 1 deletion soc/arc/quark_se_c1000_ss/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void sys_set_power_state(enum power_states state)
}
}

void sys_power_state_post_ops(enum power_states state)
void _sys_pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#if (defined(CONFIG_SYS_POWER_SLEEP_STATES))
Expand Down
4 changes: 2 additions & 2 deletions soc/arc/quark_se_c1000_ss/soc_power.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
GDATA(_pm_arc_context)

GTEXT(sys_resume_from_deep_sleep)
GTEXT(_sys_resume_from_deep_sleep)
GTEXT(_power_restore_cpu_context)
GTEXT(_power_soc_sleep)
GTEXT(_power_soc_deep_sleep)
Expand All @@ -24,7 +24,7 @@ GTEXT(_power_soc_lpss_mode)
#define SLEEP_INTR_ENABLED_BIT 4
#define SLEEP_MODE_RTC_ENABLED_BIT 5

SECTION_FUNC(TEXT, sys_resume_from_deep_sleep)
SECTION_FUNC(TEXT, _sys_resume_from_deep_sleep)
/* Check is this wakeup after sleep event. */
ld r0,[GPS0_REGISTER]
bbit1 r0,RESTORE_SS_BIT,restore
Expand Down
2 changes: 1 addition & 1 deletion soc/arm/nordic_nrf/nrf51/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void sys_set_power_state(enum power_states state)
}

/* Handle SOC specific activity after Low Power Mode Exit */
void sys_power_state_post_ops(enum power_states state)
void _sys_pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
Expand Down
2 changes: 1 addition & 1 deletion soc/arm/nordic_nrf/nrf52/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void sys_set_power_state(enum power_states state)
}

/* Handle SOC specific activity after Low Power Mode Exit */
void sys_power_state_post_ops(enum power_states state)
void _sys_pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
Expand Down
2 changes: 1 addition & 1 deletion soc/arm/silabs_exx32/common/soc_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void sys_set_power_state(enum power_states state)
}

/* Handle SOC specific activity after Low Power Mode Exit */
void sys_power_state_post_ops(enum power_states state)
void _sys_pm_power_state_exit_post_ops(enum power_states state)
{
ARG_UNUSED(state);
}
4 changes: 2 additions & 2 deletions soc/x86/intel_quark/quark_se/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void _deep_sleep(enum power_states state)
* is restored. If necessary, it is possible to set the
* resume vector to a location where additional processing
* can be done before cpu context is restored and control
* transferred to sys_suspend.
* transferred to _sys_suspend.
*/
qm_x86_set_resume_vector(_power_restore_cpu_context,
*__x86_restore_info);
Expand Down Expand Up @@ -82,7 +82,7 @@ void sys_set_power_state(enum power_states state)
}
}

void sys_power_state_post_ops(enum power_states state)
void _sys_pm_power_state_exit_post_ops(enum power_states state)
{
switch (state) {
#if (defined(CONFIG_SYS_POWER_SLEEP_STATES))
Expand Down
4 changes: 2 additions & 2 deletions soc/x86/intel_quark/quark_se/soc_power.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GDATA(_pm_save_gdtr)
GDATA(_pm_save_idtr)
GDATA(_pm_save_esp)

GTEXT(sys_resume_from_deep_sleep)
GTEXT(_sys_resume_from_deep_sleep)
GTEXT(_power_restore_cpu_context)
GTEXT(_power_soc_sleep)
GTEXT(_power_soc_deep_sleep)
Expand Down Expand Up @@ -102,7 +102,7 @@ SECTION_FUNC(TEXT, _power_soc_deep_sleep)
* Disclaimer: This can be used for debug or development purposes. This is not
* a supported feature in Quark SE boards and to be used at one's own risk.
*/
SECTION_FUNC(TEXT, sys_resume_from_deep_sleep)
SECTION_FUNC(TEXT, _sys_resume_from_deep_sleep)
movl $CONFIG_BSP_SHARED_RESTORE_INFO_RAM_ADDR, %eax
cmpl $_power_restore_cpu_context, (%eax)
je _power_restore_cpu_context
Expand Down
24 changes: 12 additions & 12 deletions subsys/power/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ static void sys_pm_log_debug_info(enum power_states state) { }
void sys_pm_dump_debug_info(void) { }
#endif

__weak void sys_pm_notify_lps_entry(enum power_states state)
__weak void sys_pm_notify_power_state_entry(enum power_states state)
{
/* This function can be overridden by the application. */
}

__weak void sys_pm_notify_lps_exit(enum power_states state)
__weak void sys_pm_notify_power_state_exit(enum power_states state)
{
/* This function can be overridden by the application. */
}
Expand All @@ -83,7 +83,7 @@ void sys_pm_force_power_state(enum power_states state)
forced_pm_state = state;
}

enum power_states sys_suspend(s32_t ticks)
enum power_states _sys_suspend(s32_t ticks)
{
bool deep_sleep;

Expand All @@ -99,14 +99,14 @@ enum power_states sys_suspend(s32_t ticks)
sys_pm_is_deep_sleep_state(pm_state) : 0;

post_ops_done = 0;
sys_pm_notify_lps_entry(pm_state);
sys_pm_notify_power_state_entry(pm_state);

if (deep_sleep) {
#if CONFIG_DEVICE_POWER_MANAGEMENT
/* Suspend peripherals. */
if (sys_pm_suspend_devices()) {
LOG_ERR("System level device suspend failed!");
sys_pm_notify_lps_exit(pm_state);
sys_pm_notify_power_state_exit(pm_state);
pm_state = SYS_POWER_STATE_ACTIVE;
return pm_state;
}
Expand All @@ -115,7 +115,7 @@ enum power_states sys_suspend(s32_t ticks)
* Disable idle exit notification as it is not needed
* in deep sleep mode.
*/
sys_pm_idle_exit_notification_disable();
_sys_pm_idle_exit_notification_disable();
}

/* Enter power state */
Expand All @@ -133,14 +133,14 @@ enum power_states sys_suspend(s32_t ticks)

if (!post_ops_done) {
post_ops_done = 1;
sys_pm_notify_lps_exit(pm_state);
sys_power_state_post_ops(pm_state);
sys_pm_notify_power_state_exit(pm_state);
_sys_pm_power_state_exit_post_ops(pm_state);
}

return pm_state;
}

void sys_resume(void)
void _sys_resume(void)
{
/*
* This notification is called from the ISR of the event
Expand All @@ -154,13 +154,13 @@ void sys_resume(void)
* The kernel scheduler will get control after the ISR finishes
* and it may schedule another thread.
*
* Call sys_pm_idle_exit_notification_disable() if this
* Call _sys_pm_idle_exit_notification_disable() if this
* notification is not required.
*/
if (!post_ops_done) {
post_ops_done = 1;
sys_pm_notify_lps_exit(pm_state);
sys_power_state_post_ops(pm_state);
sys_pm_notify_power_state_exit(pm_state);
_sys_pm_power_state_exit_post_ops(pm_state);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/kernel/profiling/profiling_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ __weak void sys_set_power_state(enum power_states state)
__ASSERT_NO_MSG(false);
}

__weak void sys_power_state_post_ops(enum power_states state)
__weak void _sys_pm_power_state_exit_post_ops(enum power_states state)
{
/* Never called. */
__ASSERT_NO_MSG(false);
Expand Down Expand Up @@ -94,7 +94,7 @@ void test_call_stacks_analyze_main(void)
*
* @ingroup kernel_profiling_tests
*
* @see k_thread_foreach(), sys_suspend(), sys_resume(),
* @see k_thread_foreach(), _sys_suspend(), _sys_resume(),
* stack_analyze()
*/
void test_call_stacks_analyze_idle(void)
Expand Down

0 comments on commit 17b08ce

Please sign in to comment.