Skip to content

Commit 2194069

Browse files
ZhaoxiangJinnashif
authored andcommitted
cpu_freq: Validate P-states in devicetree in build time
Validate P-states in devicetree in build time. If no P-states are defined, a build error will be raised. Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
1 parent e5c0abb commit 2194069

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

subsys/cpu_freq/cpu_freq.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212

1313
LOG_MODULE_REGISTER(cpu_freq, CONFIG_CPU_FREQ_LOG_LEVEL);
1414

15+
/* Build-time validation: require performance_states node with at least one child */
16+
#define PSTATE_ROOT DT_PATH(performance_states)
17+
#define CPU_FREQ_COUNT_OKAY_CHILD(_node_id) + 1
18+
enum { CPU_FREQ_PSTATE_COUNT = 0 DT_FOREACH_CHILD_STATUS_OKAY(PSTATE_ROOT,
19+
CPU_FREQ_COUNT_OKAY_CHILD) };
20+
21+
BUILD_ASSERT(DT_NODE_EXISTS(PSTATE_ROOT),
22+
"cpu_freq: performance_states node missing in devicetree");
23+
BUILD_ASSERT(CPU_FREQ_PSTATE_COUNT > 0,
24+
"cpu_freq: No P-states defined in devicetree");
25+
1526
#if defined(CONFIG_SMP) && (CONFIG_MP_MAX_NUM_CPUS > 1)
1627

1728
static struct k_ipi_work cpu_freq_work;

0 commit comments

Comments
 (0)