diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c index 3f6416cf2ab..218e3443f3e 100644 --- a/drivers/note/note_driver.c +++ b/drivers/note/note_driver.c @@ -41,7 +41,6 @@ #include #include #include -#include #include "sched/sched.h" #include "noterpmsg.h" @@ -157,18 +156,6 @@ struct note_taskname_s * Private Data ****************************************************************************/ -#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION -static void note_driver_instrument_enter(FAR void *this_fn, - FAR void *call_site, FAR void *arg) noinstrument_function; -static void note_driver_instrument_leave(FAR void *this_fn, - FAR void *call_site, FAR void *arg) noinstrument_function; -static struct instrument_s g_note_instrument = -{ - .enter = note_driver_instrument_enter, - .leave = note_driver_instrument_leave, -}; -#endif - #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER static struct note_filter_s g_note_filter = { @@ -1997,24 +1984,6 @@ FAR const char *note_get_taskname(pid_t pid) #endif -#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION -static void note_driver_instrument_enter(FAR void *this_fn, - FAR void *call_site, - FAR void *arg) -{ - sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, - NOTE_DUMP_BEGIN, NULL, 0); -} - -static void note_driver_instrument_leave(FAR void *this_fn, - FAR void *call_site, - FAR void *arg) -{ - sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, - NOTE_DUMP_END, NULL, 0); -} -#endif - /**************************************************************************** * Name: note_driver_register ****************************************************************************/ @@ -2022,15 +1991,6 @@ static void note_driver_instrument_leave(FAR void *this_fn, int note_driver_register(FAR struct note_driver_s *driver) { int i; -#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION - static bool initialized; - - if (!initialized) - { - instrument_register(&g_note_instrument); - initialized = true; - } -#endif DEBUGASSERT(driver); for (i = 0; i < CONFIG_DRIVERS_NOTE_MAX; i++) diff --git a/drivers/note/note_initialize.c b/drivers/note/note_initialize.c index 1b933e45d7a..00383d26245 100644 --- a/drivers/note/note_initialize.c +++ b/drivers/note/note_initialize.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -34,6 +35,51 @@ #include "noterpmsg.h" +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION +static void note_driver_instrument_enter(FAR void *this_fn, + FAR void *call_site, FAR void *arg) noinstrument_function; +static void note_driver_instrument_leave(FAR void *this_fn, + FAR void *call_site, FAR void *arg) noinstrument_function; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION +static void note_driver_instrument_enter(FAR void *this_fn, + FAR void *call_site, + FAR void *arg) +{ + sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, + NOTE_DUMP_BEGIN, NULL, 0); +} + +static void note_driver_instrument_leave(FAR void *this_fn, + FAR void *call_site, + FAR void *arg) +{ + sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, + NOTE_DUMP_END, NULL, 0); +} +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION +static struct instrument_s g_note_instrument = +{ + .enter = note_driver_instrument_enter, + .leave = note_driver_instrument_leave, +}; +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -97,6 +143,10 @@ int note_initialize(void) { int ret = 0; +#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION + instrument_register(&g_note_instrument); +#endif + #ifdef CONFIG_DRIVERS_NOTERAM ret = noteram_register(); if (ret < 0)