pm: state: PM_STATE_DT_ITEMS_LEN->DT_NUM_CPU_POWER_STATES

Rename PM_STATE_DT_ITEMS_LEN to DT_NUM_CPU_POWER_STATES to make its
purpose more clear. This macro could be made part of a Devicetree API
for PM in the future.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-12-01 19:45:00 +01:00 committed by Anas Nashif
parent 5ab7d35e7c
commit 7bfd0976aa
5 changed files with 11 additions and 10 deletions

View file

@ -204,12 +204,13 @@ struct pm_state_info {
DT_ENUM_IDX(node_id, power_state_name)
/**
* @brief Length of 'cpu-power-states' property
* @brief Obtain number of CPU power states supported by the given CPU node
* identifier.
*
* @param node_id A node identifier with compatible zephyr,power-state
* @return length of 'cpu-power-states' property
* @param node_id A CPU node identifier.
* @return Number of supported CPU power states.
*/
#define PM_STATE_DT_ITEMS_LEN(node_id) \
#define DT_NUM_CPU_POWER_STATES(node_id) \
DT_PROP_LEN_OR(node_id, cpu_power_states, 0)
/**
@ -257,7 +258,7 @@ struct pm_state_info {
*/
#define PM_STATE_INFO_LIST_FROM_DT_CPU(node_id) \
{ \
UTIL_LISTIFY(PM_STATE_DT_ITEMS_LEN(node_id), \
UTIL_LISTIFY(DT_NUM_CPU_POWER_STATES(node_id), \
Z_PM_STATE_INFO_FROM_DT_CPU, node_id) \
}
@ -305,7 +306,7 @@ struct pm_state_info {
*/
#define PM_STATE_LIST_FROM_DT_CPU(node_id) \
{ \
UTIL_LISTIFY(PM_STATE_DT_ITEMS_LEN(node_id), \
UTIL_LISTIFY(DT_NUM_CPU_POWER_STATES(node_id), \
Z_PM_STATE_FROM_DT_CPU, node_id) \
}

View file

@ -50,7 +50,7 @@ struct pm_counter pm_counters[SLP_STATES_SUPPORTED];
static const struct pm_state_info residency_info[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
static size_t residency_info_len = PM_STATE_DT_ITEMS_LEN(DT_NODELABEL(cpu0));
static size_t residency_info_len = DT_NUM_CPU_POWER_STATES(DT_NODELABEL(cpu0));
/* Instrumentation to measure latency and track entry exit via gpios

View file

@ -22,7 +22,7 @@ static const struct pm_state_info *pm_min_residency[] = {
DT_FOREACH_CHILD(DT_PATH(cpus), CPU_STATES)
};
#define CPU_STATES_SIZE(n) PM_STATE_DT_ITEMS_LEN(n),
#define CPU_STATES_SIZE(n) DT_NUM_CPU_POWER_STATES(n),
static int pm_min_residency_sizes[] = {
DT_FOREACH_CHILD(DT_PATH(cpus), CPU_STATES_SIZE)

View file

@ -53,7 +53,7 @@ struct pm_counter pm_counters[SLP_STATES_SUPPORTED];
static const struct pm_state_info residency_info[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
static size_t residency_info_len = PM_STATE_DT_ITEMS_LEN(DT_NODELABEL(cpu0));
static size_t residency_info_len = DT_NUM_CPU_POWER_STATES(DT_NODELABEL(cpu0));
static void pm_latency_check(void)
{

View file

@ -25,7 +25,7 @@ void test_power_states(void)
struct pm_state_info dts_infos[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(power_states));
uint32_t dts_states_len =
PM_STATE_DT_ITEMS_LEN(DT_NODELABEL(power_states));
DT_NUM_CPU_POWER_STATES(DT_NODELABEL(power_states));
zassert_true(ARRAY_SIZE(states) == dts_states_len,
"Invalid number of pm states");