Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/note: move the note formatting code from trace_dump into noteram_drivers.c #10124

Merged
merged 7 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Documentation/components/drivers/character/note.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,6 @@ Noteram Device (``/dev/note``)
:return: If success, 0 (``OK``) is returned and the given overwriter mode is set as the current settings.
If failed, a negated ``errno`` is returned.

.. c:macro:: NOTERAM_GETTASKNAME

Get task name string

:argument: A writable pointer to :c:struct:`noteram_get_taskname_s`

:return: If success, 0 (``OK``) is returned and the task name corresponding to given pid is stored into the given pointer.
If failed, a negated ``errno`` is returned.

Filter control APIs
===================

Expand Down
23 changes: 6 additions & 17 deletions drivers/note/note_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ FAR static struct note_driver_s *
static struct note_taskname_s g_note_taskname;
#endif

#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER) || \
(CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0)
#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER)
static spinlock_t g_note_lock;
#endif

Expand Down Expand Up @@ -1933,39 +1932,29 @@ void sched_note_filter_tag(FAR struct note_filter_tag_s *oldf,
*
* Input Parameters:
* PID - Task ID
* name - Task name buffer
* this buffer must be greater than CONFIG_TASK_NAME_SIZE + 1
*
* Returned Value:
* Retrun OK if task name can be retrieved, otherwise -ESRCH
*
* Retrun name if task name can be retrieved, otherwise NULL
****************************************************************************/

int note_get_taskname(pid_t pid, FAR char *buffer)
FAR const char *note_get_taskname(pid_t pid)
{
FAR struct note_taskname_info_s *ti;
FAR struct tcb_s *tcb;
irqstate_t irq_mask;

irq_mask = spin_lock_irqsave_wo_note(&g_note_lock);
tcb = nxsched_get_tcb(pid);
if (tcb != NULL)
{
strlcpy(buffer, tcb->name, CONFIG_TASK_NAME_SIZE + 1);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
return OK;
return tcb->name;
}

ti = note_find_taskname(pid);
if (ti != NULL)
{
strlcpy(buffer, ti->name, CONFIG_TASK_NAME_SIZE + 1);
spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
return OK;
return ti->name;
}

spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask);
return -ESRCH;
return NULL;
}

#endif
Expand Down
Loading
Loading