subsys/profiling: SYS_INIT not required

The timer & dwork can be statically initialized,
SYS_INIT is not strictly required.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
Yong Cong Sin 2024-08-16 13:44:24 +08:00 committed by Henrik Brix Andersen
commit 74537fc87a

View file

@ -27,7 +27,12 @@ struct perf_data_t {
bool buf_full; bool buf_full;
}; };
static struct perf_data_t perf_data; static void perf_tracer(struct k_timer *timer);
static void perf_dwork_handler(struct k_work *work);
static struct perf_data_t perf_data = {
.timer = Z_TIMER_INITIALIZER(perf_data.timer, perf_tracer, NULL),
.dwork = Z_WORK_DELAYABLE_INITIALIZER(perf_dwork_handler),
};
static void perf_tracer(struct k_timer *timer) static void perf_tracer(struct k_timer *timer)
{ {
@ -65,14 +70,6 @@ static void perf_dwork_handler(struct k_work *work)
} }
} }
static int perf_init(void)
{
k_timer_init(&perf_data.timer, perf_tracer, NULL);
k_work_init_delayable(&perf_data.dwork, perf_dwork_handler);
return 0;
}
static int cmd_perf_record(const struct shell *sh, size_t argc, char **argv) static int cmd_perf_record(const struct shell *sh, size_t argc, char **argv)
{ {
if (k_work_delayable_is_pending(&perf_data.dwork)) { if (k_work_delayable_is_pending(&perf_data.dwork)) {
@ -157,5 +154,3 @@ SHELL_STATIC_SUBCMD_SET_CREATE(m_sub_perf,
SHELL_SUBCMD_SET_END SHELL_SUBCMD_SET_END
); );
SHELL_CMD_ARG_REGISTER(perf, &m_sub_perf, "Lightweight profiler", NULL, 0, 0); SHELL_CMD_ARG_REGISTER(perf, &m_sub_perf, "Lightweight profiler", NULL, 0, 0);
SYS_INIT(perf_init, APPLICATION, 0);