Skip to content

Commit 19851c0

Browse files
cuiziweizwxiaoxiang781216
authored andcommitted
note: Move the instrument register to note_initialize
avoid the instrument doesn't get registered in some case Signed-off-by: cuiziwei <[email protected]> Signed-off-by: yinshengkai <[email protected]>
1 parent 7246533 commit 19851c0

File tree

2 files changed

+50
-40
lines changed

2 files changed

+50
-40
lines changed

drivers/note/note_driver.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include <nuttx/note/notestream_driver.h>
4242
#include <nuttx/spinlock.h>
4343
#include <nuttx/sched_note.h>
44-
#include <nuttx/instrument.h>
4544

4645
#include "sched/sched.h"
4746
#include "noterpmsg.h"
@@ -157,18 +156,6 @@ struct note_taskname_s
157156
* Private Data
158157
****************************************************************************/
159158

160-
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
161-
static void note_driver_instrument_enter(FAR void *this_fn,
162-
FAR void *call_site, FAR void *arg) noinstrument_function;
163-
static void note_driver_instrument_leave(FAR void *this_fn,
164-
FAR void *call_site, FAR void *arg) noinstrument_function;
165-
static struct instrument_s g_note_instrument =
166-
{
167-
.enter = note_driver_instrument_enter,
168-
.leave = note_driver_instrument_leave,
169-
};
170-
#endif
171-
172159
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
173160
static struct note_filter_s g_note_filter =
174161
{
@@ -1997,40 +1984,13 @@ FAR const char *note_get_taskname(pid_t pid)
19971984

19981985
#endif
19991986

2000-
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
2001-
static void note_driver_instrument_enter(FAR void *this_fn,
2002-
FAR void *call_site,
2003-
FAR void *arg)
2004-
{
2005-
sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn,
2006-
NOTE_DUMP_BEGIN, NULL, 0);
2007-
}
2008-
2009-
static void note_driver_instrument_leave(FAR void *this_fn,
2010-
FAR void *call_site,
2011-
FAR void *arg)
2012-
{
2013-
sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn,
2014-
NOTE_DUMP_END, NULL, 0);
2015-
}
2016-
#endif
2017-
20181987
/****************************************************************************
20191988
* Name: note_driver_register
20201989
****************************************************************************/
20211990

20221991
int note_driver_register(FAR struct note_driver_s *driver)
20231992
{
20241993
int i;
2025-
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
2026-
static bool initialized;
2027-
2028-
if (!initialized)
2029-
{
2030-
instrument_register(&g_note_instrument);
2031-
initialized = true;
2032-
}
2033-
#endif
20341994

20351995
DEBUGASSERT(driver);
20361996
for (i = 0; i < CONFIG_DRIVERS_NOTE_MAX; i++)

drivers/note/note_initialize.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <debug.h>
2626

27+
#include <nuttx/instrument.h>
2728
#include <nuttx/note/note_driver.h>
2829
#include <nuttx/note/noteram_driver.h>
2930
#include <nuttx/note/notectl_driver.h>
@@ -34,6 +35,51 @@
3435

3536
#include "noterpmsg.h"
3637

38+
/****************************************************************************
39+
* Private Function Prototypes
40+
****************************************************************************/
41+
42+
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
43+
static void note_driver_instrument_enter(FAR void *this_fn,
44+
FAR void *call_site, FAR void *arg) noinstrument_function;
45+
static void note_driver_instrument_leave(FAR void *this_fn,
46+
FAR void *call_site, FAR void *arg) noinstrument_function;
47+
#endif
48+
49+
/****************************************************************************
50+
* Private Functions
51+
****************************************************************************/
52+
53+
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
54+
static void note_driver_instrument_enter(FAR void *this_fn,
55+
FAR void *call_site,
56+
FAR void *arg)
57+
{
58+
sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn,
59+
NOTE_DUMP_BEGIN, NULL, 0);
60+
}
61+
62+
static void note_driver_instrument_leave(FAR void *this_fn,
63+
FAR void *call_site,
64+
FAR void *arg)
65+
{
66+
sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn,
67+
NOTE_DUMP_END, NULL, 0);
68+
}
69+
#endif
70+
71+
/****************************************************************************
72+
* Private Data
73+
****************************************************************************/
74+
75+
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
76+
static struct instrument_s g_note_instrument =
77+
{
78+
.enter = note_driver_instrument_enter,
79+
.leave = note_driver_instrument_leave,
80+
};
81+
#endif
82+
3783
/****************************************************************************
3884
* Public Functions
3985
****************************************************************************/
@@ -97,6 +143,10 @@ int note_initialize(void)
97143
{
98144
int ret = 0;
99145

146+
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
147+
instrument_register(&g_note_instrument);
148+
#endif
149+
100150
#ifdef CONFIG_DRIVERS_NOTERAM
101151
ret = noteram_register();
102152
if (ret < 0)

0 commit comments

Comments
 (0)