Skip to content
Permalink
Browse files

kernel: Fix k_*_sys_clock_always_on macro

Commit 2b8cf4c ("include: kernel: Fix documentation for
TICKLESS_KERNEL API's")' defined a macro to fix documentation when
TKCKLESS_KERNEL is not available but this macro does not return the
same the functions returns, so its use may result in compilation
error.

Another point to consider is that if one is using this function
without it be enabled is better to return a proper error like ENOTSUP
explicitly saying that this is not supported.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
  • Loading branch information...
ceolin authored and nashif committed Aug 13, 2018
1 parent 1c72121 commit f23a8cdd2d679401f87b133be756ecf127135454
Showing with 5 additions and 7 deletions.
  1. +5 −7 include/kernel.h
@@ -1669,19 +1669,19 @@ __syscall s64_t k_uptime_get(void);
*
* @retval prev_status Previous status of always on flag
*/
#ifdef CONFIG_TICKLESS_KERNEL
static inline int k_enable_sys_clock_always_on(void)
{
#ifdef CONFIG_TICKLESS_KERNEL
int prev_status = _sys_clock_always_on;

_sys_clock_always_on = 1;
_enable_sys_clock();

return prev_status;
}
#else
#define k_enable_sys_clock_always_on() do { } while ((0))
return -ENOTSUP;
#endif
}

/**
* @brief Disable clock always on in tickless kernel
@@ -1691,14 +1691,12 @@ static inline int k_enable_sys_clock_always_on(void)
* scheduling. To save power, this routine should be called
* immediately when clock is not used to track time.
*/
#ifdef CONFIG_TICKLESS_KERNEL
static inline void k_disable_sys_clock_always_on(void)
{
#ifdef CONFIG_TICKLESS_KERNEL
_sys_clock_always_on = 0;
}
#else
#define k_disable_sys_clock_always_on() do { } while ((0))
#endif
}

/**
* @brief Get system uptime (32-bit version).

0 comments on commit f23a8cd

Please sign in to comment.
You can’t perform that action at this time.